Design Patterns for Mesh


Hi folks,

I’m looking for some advice on design patterns within a mesh of argons/xenons. My scenario relates to the Scenes or Groups construct found in IoT systems such as Amazon Alexa, Google Assistant, etc.

Let’s say I have 3 particle devices which have an input button, and each of those devices are connected to an LED. When I click the button on device A, I want to run Scene 1. Scene 1 has the following configuration:

Scene 1 - input from button on Device A
Device A: LED On and Blue
Device B: LED Off
Device C: LED On and Green

Similarly, device B and C would have their own “Scene” for when a button is clicked:

Scene 2 - input from button on Device B
Device A: LED Off
Device B: LED On and Red
Device C: LED Off

With a lighting system such as Philips Hue for instance, the configuration of each scene would be stored in the Philips Hue hub, which acts as the brain of the network.

Going beyond a simple click input, I may also want to have different Scenes execute on a double click or have a Scene configuration executed from the cloud or a mobile device.

The scene configurations are essentially JSON documents which indicate the device to modify, the power state of the LED, and the color of the LED, and one device may be part of multiple scenes of different power and color.

I’m looking for recommendations on how to achieve the data storage and mesh communications for this scenario. Essentially I need a way to store the configuration of every scene across the mesh, and then have each device aware of the scenes it belongs too. Over time, the buttons might be changed to trigger different scenes as well.

I’m considered some logic where the click of a button on Device A is set to trigger Scene 1. On the click of that button a publish event is broadcasted across the network for the runScene event, passing the the scene name “Scene1”. Each device in the network would be subscribed to the runScene topic, thus receiving the event. Upon receipt each device would do an internal lookup to determine if its ID is part of the scene that was called, and would modify it’s LED if the lookup was true. This setup would require every device storing a master list of all scene configurations which would grow over time and would likely create storage issues in the long-run.

I appreciate any feedback on this topic.