Select device by tag matching an attribute and update it's data

I know this is an easy one but I can’t figure it out. I have 500 devices with a tag of “MachineID” that is unique. Payloads are coming in thru Pub/Sub that can contain matching value of one device. A conditional would work but I would have 500 blocks! I just need a context variable or something to say “for the device matching this ID, set the attributes”. I can do this in programming language (a simple if/then) but can’t figure it out in “blocks”.


No problem. We can help point you in the right place. When you say “for the device matching this ID, set the attributes”. Is each device unique? Or, is there some type of grouping for devices (that may have the same set of attributes)?

If you need a simple if/then inside of a Workflow, that’s the Conditional Node.

Alternatively, you can get pretty far with a Switch Node (for the conditional logic) and Device Recipes (to make it easier to manage and create different types of devices).


I read your question again and I have a better solution for you. Using the Device: Get Node you can retrieve a device by tag.

If your unique identifier is a tag on the device, you could have a workflow that does the following:

  • Report Data
  • Get Device By Tag
  • Report State for that Device

Each device is unique set by a tag called “MachineID” (serial number). In each Pub/Sub payload (JSON) there is an attribute “{{}}” that matches a unique device tag “MachineID”. Yes, I can do with a conditional, but I would have 500 of them. I need a way to say “if the attribute {{}} in the PUB/SUB supplied payload matches the tag “MachineID” of a device, then update that device’s data with the other attributes in this payload”. I want to this in two or three “blocks” vs 500. I am missing something fundamental I assume. I did use a device recipe to bulk create the devices (bulk feature is a godsend).


I did follow up with an alternative approach, will that work for you?

YES! I did it in 3 blocks. Thank you!

Here is a before after/visual…the more you know…