Checking if two conditions stayed the same for a period of time


#1

1) Give a description of the problem
I am trying to use a piston to determine if someone may need assistance. In short, I want to see if someone has been home for an extended period of time but hasn’t opened a door. I have tried a number of if/then scenarios but can’t get it to work. I’ve included two screenshot with two of the many approaches I’ve tried but that haven’t worked.

2) What is the expected behavior?
If the individual’s presence hasn’t changed and they haven’t opened their back door, send an SMS alerting a family member something may be wrong.

3) What is happening/not happening?
I am not getting a notification. In one case, the log shows the piston never fired. In the other case, it looks like both conditions (presence and door not opened) were true but the notification wasn’t received.

**4) Post a Green Snapshot of the piston![image|45x37]

Note that the “2 Minute” wait is just for testing. When this is working, I will change it to a 10 hour wait. For this one, the log remains blank which suggests the conditions weren’t met:

I changed the logic in this one. The log suggests the conditions were met but no notification was received:

10/9/2017, 8:13:45 PM +499ms
+6ms ╔Starting piston… (v0.2.0e8.20170918)
+324ms ║╔Subscribing to devices…
+360ms ║║Subscribing to xxxxx’x iPhone.presence…
+373ms ║║Subscribing to Back Door.contact…
+523ms ║╚Finished subscribing (208ms)
+559ms ║Comparison (enum) present stays (string) present = true (6ms)
+571ms ║Comparison (enum) closed stays (string) closed = true (3ms)
+814ms ╚Piston successfully started (814ms)

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

For the first screenshot, no log was generated. I included the log for the second example with the second screenshot above but I’m posting here again:

10/9/2017, 8:13:45 PM +499ms
+6ms ╔Starting piston… (v0.2.0e8.20170918)
+324ms ║╔Subscribing to devices…
+360ms ║║Subscribing to xxxx’s iPhone.presence…
+373ms ║║Subscribing to Back Door.contact…
+523ms ║╚Finished subscribing (208ms)
+559ms ║Comparison (enum) present stays (string) present = true (6ms)
+571ms ║Comparison (enum) closed stays (string) closed = true (3ms)
+814ms ╚Piston successfully started (814ms)


#2

this writeup explains the meta concept of whats happening here. in the 2nd piston both conditions on the if check are both triggers so that if will never evaluate as true.


#3

What about doing it this way. This will test if the door has been opened since the presence sensor has been present for the last X minutes OR if the presence sensor changes to Not Present AND then if the door hasn’t been opened since the previous arrival.

For example, the test is if the person is home for 4 hours and hasn’t walked the dog. But they leave after 3:50 minutes. This would still check if they have walked the dog since the last time they arrived.

It isn’t perfect and there may be other use cases that need to be handled, but I ran a couple of tests and it seems to work.


#4

Thanks for the suggestions. After I figured out there would be no presence sensor available, I ended going with a very straight-forward approach. It’s probably a little clumsy but it seems to be pretty solid so far.


#5

You could also use the age of the last time a contact was opened and multiple contacts, something like this:

This gives you the ability to configure more than 1 contact (if that is an option) as well as the number of minutes to check since the contact was last opened or closed. And in the report you can include when the contact was last triggered.

This also updates the piston status when it runs, so you can always take a look and see when was the last time one of the contacts opened.