Custom attribute format with attribute link

Hi all,
i was wondering if there’s a way to make an attribute link and, beside filtering, customize the format of the data to send to the other attribute. e.g.

Attribute1 (linked to attribute 2)
"name" : "Rich"

Atribute 2
"nombre" : "Rich"

In this case, i change the “name” to “Nombre”.



There is no existing way to do this with an AttributeLink; it gives you limited capabilities but you can easily achieve this with rules.

Hi Rich,
im trying to achieve this with rules. Can i make a custom attribute link with groovy? Thanks


You don’t need to use attribute links in groovy you have much more capability available through a groovy rule. Generally in the when condition you wait for a particular AssetState (which is just an attribute write event) you can also react to the value of the AssetState (i.e. the value written to the attribute).

One thing to note with groovy rules is that you need to create a temporary fact to avoid an infinite loop in your rule; without this each time the engine evaluates the rule the when condition will keep matching which will then cause the then to be executed continually. The obvious temporary fact to store is the current timestamp of the AssetState and when a new AssetState comes through it will have a newer timestamp.

Hi Rich, is this reacting to a write event of the attribute?

        .name("Conectado Parq1")
            {facts ->
                new AssetQuery()
            {facts ->
            facts.updateAssetState("4HUgnoIT7ziFk1Lb9T3TWN", "estado", "Conectado")
            facts.putTemporary(HOW DO I STORE THE TIMESTAMP?)

The rule must update the value of an attribute when “lectura” (other attribute) is written. How can i generate a temporary fact with the timestamp? thanks

See other post here