We are trying to create a device dynamically, starting with a base recipe and then adding attributes as needed for a final configuration. We use attribute tags for things such as units so need to be able to programmatically create an attribute that has attribute tags. The workflow node Device:update doesn’t seem to support this with the ‘individual fields’ option, so we are using the payload path option. Our payload is as shown below, and we use data.patch as our payload path to the Device:update node.
This works without error, but results in all existing attributes in the device being deleted. Is there somewhere this is specified in the documentation, and how can we add an attribute with tags without wiping out all other attributes already defined. We need this to be bulletproof, can’t have any possibility of attributes being deleted.
The workflow then uses the Device: Get node to retrieve the device information that is passed in as deviceIDToUpdate. It then uses the Mutate node to add a field to the payload that will act as a sort of staging area for the updates, and then uses the Loop Node to loop through the addAttributes field. Finally, it ends with a Device: Update node where the attributes are then updated for the device.
I’ve included the workflow zip below. Please let me know if you have any questions!