Design for multiple presence sensors leaving at the same time


#1

1) Give a description of the problem
Looking to receive one notification when one or multiple presence sensors leave at the same time.

2) What is the expected behavior?
Wife and I leave in the same car and both phones report presence within 1 minute of one another. I want one notification to indicate we’ve both left, which will also include other info about SHM and thermostat setting.

3) What is happening/not happening?
N/A - Looking for design help

The presence change on both phones would fire two separate instances of the same piston (correct?). I’m ok with adding a delay of 1 minute to ensure that both phones report in their presence. But how do I only fire the notification if two instances of the piston run?


#2

This is how I envision it… completely untested :slight_smile: and under the influence :smiley:


#3

Something like this might work for you:

When the first presence changes to not present the one minute wait will start. If during that time the second presence changes to not present, the statements in the first/outside then clause (including the wait) will effectively start over. (They’re not cancelled, per se, but replaced since their Task Scheduling Policy is the default of Override.) Now once the (new) one minute wait expires the second if statement will run. If at that time any of the presence’s are still not present then the rest will run. I show how you can do something with all the presence’s that are not present, and how you can do something with each individually.

You’ll notice I also set the Task Cancellation Policy (TCP) of everything inside the first/outside then clause to Never. This is necessary for two reasons. 1) If the piston subscribes to other events, when they happen the first if will not be true and the statements inside it would be canceled (since the default TCP is on condition state change.) 2) The same thing would happen if after one or more of the presence’s changed to not present one changed back to present during the wait.