How to copy a devices attributes

#1

My device has two attributes. I want to set the value of one attribute to the value of another. I have a button that snapshots one attribute that is updated over the network into another that is never updated over the network. I tried using the Set Device State block but can not seem to get it to work. My device is fetched using Get Device block and is on the path data.device. In Set Device State I tried:

{{data.device.MagX}}

and

{{data.device.attributes.MagX}}

and

{{valueByKey data.device.attributes ‘MagY’}}

neither work…

Help please!

0 Likes

#2

If I understand correctly, on button press you want to take the last known value of the first attribute, and set it as the current value as the second attribute? But you don’t have that last known value in the workflow payload?

If that is the case, the Get Device node won’t get you the data you need - it only returns the the device itself, not any data for the device. You probably want to use the Gauge Query node to get the last value for the first attribute and place it on the workflow payload. Once you have that value, you can use the Device State node to store that value as the latest value for the second attribute.

0 Likes

#3

Oh, OK. I will give that a go…

0 Likes