Acting on multiple device status updates at once


#1

1) Give a description of the problem
I have a piston that is subscribed to switch changes to my bulbs/virtual light switches, presence sensors, and location mode. With each change, it sends an HTTP request to an endpoint I’m using to pass status messages to my phone for a dashboard I’m building. For the most part, it works great but I think I might be running into an issue if too many things are happening at once.

2) What is the expected behavior?
Anytime any of my devices gets switched on or off, or if either of our presence sensors arrive or depart, or if our mode changes, an HTTP request should get sent with that detail.

3) What is happening/not happening?
This morning, when my wife and I left the house, both our presence sensors changed to not present properly with another piston I have, and then another piston changed the mode from Home to Away. Based on the change to away and the time of day, I have another piston that turns off all of our smart lighting in the house. So, within a very small time window, we had status updates on two presence sensors, the location mode, and two lights. Looking at the logging for my piston, it sent HTTP requests for the sensors and the mode, but only got one of the lights. Is there a limit to parallel executions, even with parellelism on? Is there a better way for me to structure this? I could move the presence sensors and location into their own separate pistons if that would help. But even then, I’m going to be getting more lights, so as that happens, am I still going to run into issues with this piston design if multiple lights all turn off at once?

**4) Post a Green Snapshot of the piston

5) Attach any logs (From ST IDE and by turning logging level to Full)


#2

Actually, I dug into the logging on the other end, to see what made it to my mobile device, and it looks like everything got there. So the POST requests all executed, just one of the Log info “{payload}” commands didn’t work. Is it possible there was just too much trying to write to the log at once?

Regardless, I’m still curious as to whether there is a more efficient design recommendation for this.


#3

you only need one on event and each of the 3 anys can be handled with a or clause with the same on event.


#4

So, something more like this? Would I still need parallelism enabled?


#5

yes but try without if/else. just the else block should be enough. parallelism enabled.


#6

Thanks, it seems to be working great! For some reason not everything is getting written to the log, but that must just be a limitation of multiple parallel executions not being able to write the log concurrently. I’m getting all of the messages at my endpoint, so that’s the important part. Thanks for helping me simplify this one!