I can see how I could use subscribe to catch all events, then parse some of the data in a handler to determine if it’s addressed to this specific device processing the event. But is there not a better way?
I know you can use subscribe to catch your responses, but I need to send this to a select few devices, not just the one that made the publish.
When you want to publish to a specific device, the recommended method is to prefix the event name with the Device ID you are targeting. This is common for webhook responses. For example:
You just made my day. I am trying to manage 500 devices over a county, in 5 different physical locations. This really makes a massive difference. Thank you again!
Do you subscribe to the event GroupA/lcdHandler on device? That's a requirement to use that technique.
particle publish lcdHandler 00700010
This triggers all devices I am owner of.
Expected behavior.
particle publish lcdHandler 00700010 --product 121212
This triggers all devices regardless of productid.
The catch here is that if you publish the event from an access token that is also the owner of the device, then the event will go to all devices in all products owned by that user, OR the product specified. That is almost certainly not the behavior you want, but that's how it works.
The solution is to use an API user access token for the product you are targeting when you publish the event in this scenario. Because API users can't claim a device, and are specific to a product, it guarantees that the event will only go to that product.
That seems like a reasonable choice. While grouping objects within the Particle events system is feasible, it's not what it was designed for, so if you have a different, potentially simpler way to do it, that would be my first choice.