Someone Coming Home AND Garage Door Opens condition/trigger?


#1

Hi all,

I’m relatively new to STs and WebCore so any help is appreciated. I learned that you can’t have two triggers in a piston, so trying to workaround that and satisfy my scenario in a different way but it’s still not working. Please see below:

1) Give a description of the problem
Trying to figure out a way to:

  1. When it is dark (between sunset and sunrise)
    AND
  2. When one of the two of us is coming home (presence sensor)
    AND
  3. Garage door opens (the trigger)
    THEN
    Turn on the Garage & Kitchen lights.

However, my piston (screenshot below) isn’t working. The IF condition always never satisfies even when one or both of us come home at night and opens the garage door.

2) What is the expected behavior?
Garage & Kitchen lights to turn on when those 3 conditions are satisfied.

3) What is happening/not happening?
The IF condition always never satisfies even when one or both of us come home at night and opens the garage door.

4) Post a Green Snapshot of the pistonimage

Any ideas?


#2

Alright…let me introduce you to some new concepts in WC. First, your piston is a good candidate for a restriction. That’s the “only when” part at the top. So that will satisfy your when requirement.

Next, you can actually have two triggers in a piston…but the important thing to note is that they can NEVER both be true at the exact same time (I’m talking milliseconds here) as one will always report happening first. However, you can have them chained together as I’m showing here. If you want to adjust the time in the followed by part then you click on the “Contact sensor changes to open” line and you can adjust it as necessary.

Edit: I changed the example piston here. Just realized that the false trigger check that I had in it would not have worked properly. To really make it work the previousAge of the $currentEventdevice would need to be used instead. But since he’s not using that anyway I just left that out.


#3

Thank you @Mike1616 for the explanation! I will try this out!


#4

Updated my piston and tested it tonight. Was able to use the “only when” restriction and the “followed within” to join the trigger of presence sensors arriving and contact sensor opening as shown by @Mike1616 above.

I also removed the second check of “presence sensor was not present for at least x min” since that isn’t necessary now given the “followed within” makes both triggers true when we come home from dark.

Working great! Thanks again @Mike1616!


#5

Looks like I ran into another issue.

So this is what I have right now and what I thought was working perfectly per my previous reply. However, it somehow only works when Presence Sensor 1 arrives and not when Presence Sensor 3 arrives.

I’ve enabled full logging (see below), but can’t figure out why the IF condition was false. Didn’t find any logging around whether the “followed within” worked or not. Any pointers? Thanks!

Below’s the full logging of when Presence Sensor 3 arrived home between sunset and sunrise, and then opened the garage door (Contact Sensor 2) within a min, which should have satisfied the IF condition which uses “followed within 10 min”:

1/30/2018, 6:55:36 PM +363ms
+2ms ╔Received event [Contact Sensor 2].contact = closed with a delay of 384ms
+187ms ║RunTime Analysis CS > 20ms > PS > 98ms > PE > 69ms > CE
+190ms ║Runtime (42259 bytes) successfully initialized in 98ms (v0.2.102.20180116) (188ms)
+191ms ║╔Execution stage started
+233ms ║║Comparison (time) 68136558 is_between (time) 1517362260000 … (time) 1517325300000 = true (7ms)
+234ms ║║Time restriction check passed
+235ms ║║Condition #35 evaluated true (41ms)
+236ms ║║Condition group #null evaluated true (state did not change) (42ms)
+249ms ║║Condition #37 evaluated false (10ms)
+250ms ║║Condition group #36 evaluated false (state did not change) (11ms)
+251ms ║║Cancelling statement #17’s schedules…
+252ms ║║Condition group #17 evaluated false (state did not change) (14ms)
+254ms ║║Cancelling statement #26’s schedules…
+259ms ║║Log: IF statement was false.
+259ms ║║Executed virtual command log (1ms)
+262ms ║╚Execution stage complete. (70ms)
+263ms ╚Event processed successfully (262ms)

1/30/2018, 6:48:59 PM +966ms
+2ms ╔Received event [Contact Sensor 2].contact = open with a delay of 414ms
+416ms ║RunTime Analysis CS > 21ms > PS > 320ms > PE > 74ms > CE
+418ms ║Runtime (42259 bytes) successfully initialized in 320ms (v0.2.102.20180116) (416ms)
+419ms ║╔Execution stage started
+468ms ║║Comparison (time) 67740391 is_between (time) 1517362260000 … (time) 1517325300000 = true (9ms)
+469ms ║║Time restriction check passed
+471ms ║║Condition #35 evaluated true (47ms)
+472ms ║║Condition group #null evaluated true (state did not change) (47ms)
+486ms ║║Condition #37 evaluated false (11ms)
+487ms ║║Condition group #36 evaluated false (state did not change) (13ms)
+488ms ║║Cancelling statement #17’s schedules…
+489ms ║║Condition group #17 evaluated false (state did not change) (16ms)
+491ms ║║Cancelling statement #26’s schedules…
+497ms ║║Log: IF statement was false.
+497ms ║║Executed virtual command log (1ms)
+500ms ║╚Execution stage complete. (80ms)
+501ms ╚Event processed successfully (501ms)

1/30/2018, 6:48:14 PM +272ms
+1ms ╔Received event [Presence Sensor 3].presence = present with a delay of 109ms
+147ms ║RunTime Analysis CS > 14ms > PS > 70ms > PE > 63ms > CE
+149ms ║Runtime (42266 bytes) successfully initialized in 70ms (v0.2.102.20180116) (147ms)
+150ms ║╔Execution stage started
+187ms ║║Comparison (time) 67694426 is_between (time) 1517362260000 … (time) 1517325300000 = true (6ms)
+188ms ║║Time restriction check passed
+189ms ║║Cancelling condition #35’s schedules…
+190ms ║║Condition #35 evaluated true (36ms)
+191ms ║║Cancelling condition #null’s schedules…
+191ms ║║Condition group #null evaluated true (state changed) (37ms)
+201ms ║║Comparison (enum) present changes_to (string) present = false (1ms)
+202ms ║║Condition #37 evaluated false (8ms)
+203ms ║║Condition group #36 evaluated false (state did not change) (9ms)
+204ms ║║Cancelling statement #17’s schedules…
+205ms ║║Cancelling condition #17’s schedules…
+205ms ║║Condition group #17 evaluated false (state changed) (12ms)
+207ms ║║Cancelling statement #26’s schedules…
+213ms ║║Log: IF statement was false.
+213ms ║║Executed virtual command log (1ms)
+216ms ║╚Execution stage complete. (66ms)
+217ms ╚Event processed successfully (217ms)


#6

Hmm… I need more info. I see the events in the logs but it looks like the IF’s are evaluating to false (clearly) but I cant’ tell which one it is that’s failing.

So…I either need a green snapshot of the piston with the logs for a failed event, or a Trace snip of it so that I can see the little numbers next to the events so that I can tell which one is the problem.

Odd that it would work with one presence sensor and not the other tough. The logs clearly show that it’s getting the proper events in what looks to be the correct amount of time. So it looks like it should work…but since it isn’t the only way to really dig into this is to see the the whole details.


#7

Thanks @Mike1616. I’ll turn on full logging and trace and will post the green screenshot tomorrow when this happens again. (Since it looks like the trace can’t go back further than the last time the piston triggered).


#8

@Mike1616 Here’s my trace and log from today that had the same reproducible problem.
I’m not sure why Condition #37 evaluated false when Presence Sensor 3’s presence was changed to present. It looks like that could be the issue though?

2/1/2018, 8:22:31 PM +310ms
+1ms ╔Received event [Garage Door].contact = closed with a delay of 428ms
+253ms ║RunTime Analysis CS > 15ms > PS > 147ms > PE > 91ms > CE
+255ms ║Runtime (42263 bytes) successfully initialized in 147ms (v0.2.102.20180116) (253ms)
+256ms ║╔Execution stage started
+303ms ║║Comparison (time) 73351570 is_between (time) 1517535180000 … (time) 1517497980000 = true (7ms)
+305ms ║║Time restriction check passed
+306ms ║║Condition #35 evaluated true (46ms)
+307ms ║║Condition group #null evaluated true (state did not change) (48ms)
+319ms ║║Condition #37 evaluated false (8ms)
+319ms ║║Condition group #36 evaluated false (state did not change) (9ms)
+320ms ║║Cancelling statement #17’s schedules…
+321ms ║║Condition group #17 evaluated false (state did not change) (12ms)
+323ms ║║Cancelling statement #26’s schedules…
+328ms ║║Log: IF statement was false.
+328ms ║║Executed virtual command log (1ms)
+330ms ║╚Execution stage complete. (74ms)
+331ms ╚Event processed successfully (331ms)

2/1/2018, 8:21:45 PM +128ms
+1ms ╔Received event [Garage Door].contact = open with a delay of 624ms
+209ms ║RunTime Analysis CS > 14ms > PS > 101ms > PE > 94ms > CE
+211ms ║Runtime (42261 bytes) successfully initialized in 101ms (v0.2.102.20180116) (209ms)
+212ms ║╔Execution stage started
+260ms ║║Comparison (time) 73305345 is_between (time) 1517535180000 … (time) 1517497980000 = true (7ms)
+261ms ║║Time restriction check passed
+263ms ║║Condition #35 evaluated true (47ms)
+264ms ║║Condition group #null evaluated true (state did not change) (47ms)
+277ms ║║Condition #37 evaluated false (9ms)
+277ms ║║Condition group #36 evaluated false (state did not change) (11ms)
+278ms ║║Cancelling statement #17’s schedules…
+279ms ║║Condition group #17 evaluated false (state did not change) (14ms)
+281ms ║║Cancelling statement #26’s schedules…
+287ms ║║Log: IF statement was false.
+287ms ║║Executed virtual command log (1ms)
+290ms ║╚Execution stage complete. (77ms)
+291ms ╚Event processed successfully (291ms)

2/1/2018, 8:21:00 PM +179ms
+2ms ╔Received event [Presence Sensor 3].presence = present with a delay of 92ms
+243ms ║RunTime Analysis CS > 20ms > PS > 128ms > PE > 94ms > CE
+245ms ║Runtime (42269 bytes) successfully initialized in 128ms (v0.2.102.20180116) (242ms)
+246ms ║╔Execution stage started
+296ms ║║Comparison (time) 73260429 is_between (time) 1517535180000 … (time) 1517497980000 = true (7ms)
+297ms ║║Time restriction check passed
+298ms ║║Cancelling condition #35’s schedules…
+299ms ║║Condition #35 evaluated true (50ms)
+300ms ║║Cancelling condition #null’s schedules…
+301ms ║║Condition group #null evaluated true (state changed) (51ms)
+311ms ║║Comparison (enum) present changes_to (string) present = false (1ms)
+312ms ║║Condition #37 evaluated false (9ms)
+313ms ║║Condition group #36 evaluated false (state did not change) (10ms)
+314ms ║║Cancelling statement #17’s schedules…
+314ms ║║Cancelling condition #17’s schedules…
+315ms ║║Condition group #17 evaluated false (state changed) (13ms)
+317ms ║║Cancelling statement #26’s schedules…
+323ms ║║Log: IF statement was false.
+324ms ║║Executed virtual command log (1ms)
+326ms ║╚Execution stage complete. (80ms)
+327ms ╚Event processed successfully (327ms)


#9

Alright, I think we need to elevate this one up. The lines I’ve highlighted below are concerning. I don’t know what cancelling a #null schedule is either. Perhaps @Robin can shed some light on this one for us.


#10

Did this piston ever work? My first thought is this is another clash with triggers and waits/followed by commands:

  1. Your presence changes and triggers your piston to run. Your Presence Changes evaluates true.

  2. Within 10 minutes, your garage door opens. As you can see, it evaluates whether or not your Presence Changes to True again… right here:

Since your piston was triggered by your garage door opening, not your presence change, it evaluates False for “Presence changes to present” and the aborts the rest of your piston.

To get around this, I would make the trigger the event you want to initiate actions in your piston. In this case, the garage door opening.

IF
Garage door Changes to Open
AND
Any presence sensors have changed to present in the last 10 minutes
Then
Welcome home and light up the house


#11

Since there is no option for “and presence changed TO”, this will achieve the same thing:

Now you have a trigger that evaluates true when you want to start lighting up your house, and two conditions to prove out you arrived home within 10 minutes of the garage door opening.


#12

This method would work too… I did some testing on “Followed by” and got some odd results. Bu this way does work.


#13

I think it’s related to a restriction. The only time I’ve seen that in the logs is immediately following a restriction passing. The example below (see 126ms line) from another thread is right after a restriction for “Location Mode is Home” passes:


#14

Interesting, but what about this… I don’t get this one at all.

image

I mean, that’s right away too. It’s in the Event for Presence Sensor 3. Presence = present, and then 311ms later you get that where it seems like it’s just not evaluating a string compare properly.


#15

That one, I have no idea. It’s right at the top of the piston, except for the time restriction… so there goes my usual my first suggestion when I see triggers evaluate incorrectly.

I’d be curious if either of the samples we posted would get around that or suffer the same.


#16

@webCoRE_Minions


#17

I know the one that I posted works. I have a virtual presence sensor in the ST app setup and I confirmed that it works just fine with that.

However, I can reproduce these results that he has in his logs if I build a simple piston with

Presence changes to present
followed by a switch turning on.


#18

This doesn’t even work…

image


#19

Thanks guys. Yeah, it’s really strange. What’s more strange is the “follow by” method somehow works for Presence Sensor 1 but not Presence Sensor 3. The only difference I see in the two presence sensor is that Sensor 1 is on iOS and is named “V’s iPhone”, Sensor 3 is on Android and is named “D’s Android” (note the apostrophe differences). But I have both sensors running other pistons with more simple conditions and they work just fine.

I will try what @michicago proposed earlier using the “in the last 10 min” condition and see if that’ll work first.


#20

That’s really odd and way beyond my understanding of webcore. Hopefully one of the minions can shed some light on it. I’m curious to hear why now too!