Arrival/departure if/then or case statement?


#52

Thanks for the info. Here is what I am trying to accomplish.

I am having issues with the webCoRE presence sensor (assuming the GPS accuracy is higher then 50-100m). In my picture above, what I am seeing is that my currentPlace is momentarily changing to, “House,” for about 10 seconds when I drive past my geofence. What I am trying to accomplish is, don’t trigger the arrival/departure statements unless my currentPlace changes to, “House,” and stays that way for at least 10 seconds. I can adjust the 10 seconds if I am seeing it is not long enough.

Would this be written in the following way?

IF
Any of the presence sensors currentPlace changes to "House"
followed (Strict, Loose or Negated?) within 10 minutes by
Any of the presence sensors currentPlace stays “House” for 10 seconds

If I literally read that it looks like we are looking back 10 minutes to see if any of the presence sensors currentPlace has stayed, “House,” for 10 seconds.


#53

I think the way wecCoRE’s ‘stay’ works, you can reduce the number of statements to one. WebCoRE seems to subscribe to events for stay, so it will automatically trigger the piston on state change (negating the need for ‘if currentplace changes to house’).

Try just using:
IF presence sensor currentPlace stays House for 10 seconds.

The only problem I can see with the Stay clause, is now you could start seeing duplicate notifications. For example, if Renee was home, and then you came home an hour later - Renee also would have “stayed” home for 10 seconds.

You might need to add in a “has not changed in the last XX seconds” condition to work around that.


#54

I assume this is what you meant.

Changing the, "changes to, “House”, to stays, “House,” for 10 seconds.


#55

Yep, that was it! Hopefully that filters our your false arrivals.


#56

Well, that change broke both the departure and arrivals. I was a good test where we both left at the same time. Typically, my presence will trigger a few seconds before hers will. Maybe you can see what is happening from the logs?

Arrival logs:

1/4/2018, 7:57:05 PM +319ms
+0ms ╔Received event [Home].time = 1515117426781 with a delay of -1463ms
+227ms ║RunTime Analysis CS > 62ms > PS > 59ms > PE > 107ms > CE
+262ms ║Runtime (58080 bytes) successfully initialized in 59ms (v0.2.101.20171227) (261ms)
+263ms ║╔Execution stage started
+267ms ║║Cancelling condition #2’s schedules…
+294ms ║║Fast executing schedules, waiting for 1170ms to sync up
+1543ms ║╚Execution stage complete. (1280ms)
+1545ms ╚Event processed successfully (1545ms)
1/4/2018, 7:56:56 PM +603ms
+1ms ╔Received event [Renee Presence Sensor].currentPlace = House with a delay of 115ms
+145ms ║RunTime Analysis CS > 12ms > PS > 39ms > PE > 94ms > CE
+151ms ║Runtime (58087 bytes) successfully initialized in 39ms (v0.2.101.20171227) (148ms)
+151ms ║╔Execution stage started
+165ms ║║Comparison (string) House stays (string) House = true (1ms)
+167ms ║║Comparison (string) House stays (string) House = true (1ms)
+177ms ║║Adding a timed trigger schedule for device :a33e14a1d9fbc2eb5253c7c8cbcc0dc1: for condition 83
+179ms ║║Adding a timed trigger schedule for device :949dab343e304a0ed7093bd8803ae97e: for condition 83
+181ms ║║Condition #83 evaluated false (24ms)
+181ms ║║Cancelling statement #2’s schedules…
+182ms ║║Cancelling condition #2’s schedules…
+183ms ║║Condition group #2 evaluated false (state changed) (27ms)
+194ms ║║Comparison (string) House stays (string) House = true (1ms)
+195ms ║║Comparison (string) House stays (string) House = true (1ms)
+197ms ║║Adding a timed trigger schedule for device :a33e14a1d9fbc2eb5253c7c8cbcc0dc1: for condition 82
+199ms ║║Adding a timed trigger schedule for device :949dab343e304a0ed7093bd8803ae97e: for condition 82
+201ms ║║Condition #82 evaluated false (15ms)
+203ms ║╚Execution stage complete. (52ms)
+205ms ║Setting up scheduled job for Thu, Jan 4 2018 @ 7:57:06 PM CST (in 9.974s), with 3 more jobs pending
+215ms ╚Event processed successfully (214ms)
1/4/2018, 7:56:29 PM +831ms
+0ms ╔Received event [Home].time = 1515117390872 with a delay of -1041ms
+177ms ║RunTime Analysis CS > 15ms > PS > 55ms > PE > 107ms > CE
+182ms ║Runtime (58076 bytes) successfully initialized in 55ms (v0.2.101.20171227) (181ms)
+183ms ║╔Execution stage started
+190ms ║║Cancelling condition #2’s schedules…
+234ms ║║Fast executing schedules, waiting for 833ms to sync up
+1113ms ║╚Execution stage complete. (930ms)
+1114ms ╚Event processed successfully (1114ms)
1/4/2018, 7:56:20 PM +626ms
+2ms ╔Received event [Keith Presence Sensor].currentPlace = House with a delay of 130ms
+214ms ║RunTime Analysis CS > 22ms > PS > 79ms > PE > 113ms > CE
+221ms ║Runtime (58085 bytes) successfully initialized in 79ms (v0.2.101.20171227) (218ms)
+223ms ║╔Execution stage started
+242ms ║║Comparison (string) House stays (string) House = true (1ms)
+244ms ║║Comparison (string) stays (string) House = false (1ms)
+246ms ║║Adding a timed trigger schedule for device :a33e14a1d9fbc2eb5253c7c8cbcc0dc1: for condition 83
+248ms ║║Cancelling any timed trigger schedules for device :949dab343e304a0ed7093bd8803ae97e: for condition 83
+251ms ║║Cancelling statement #83’s schedules…
+252ms ║║Condition #83 evaluated false (21ms)
+253ms ║║Cancelling statement #2’s schedules…
+254ms ║║Condition group #2 evaluated false (state did not change) (24ms)
+269ms ║║Comparison (string) House stays (string) House = true (1ms)
+270ms ║║Comparison (string) stays (string) House = false (1ms)
+272ms ║║Adding a timed trigger schedule for device :a33e14a1d9fbc2eb5253c7c8cbcc0dc1: for condition 82
+274ms ║║Cancelling any timed trigger schedules for device :949dab343e304a0ed7093bd8803ae97e: for condition 82
+274ms ║║Cancelling statement #82’s schedules…
+275ms ║║Condition #82 evaluated false (19ms)
+277ms ║╚Execution stage complete. (55ms)
+279ms ║Setting up scheduled job for Thu, Jan 4 2018 @ 7:56:30 PM CST (in 9.968s), with 1 more job pending
+287ms ╚Event processed successfully (287ms)

Departure logs:

1/4/2018, 6:09:29 PM +351ms
+1ms ╔Received event [Home].time = 1515110970075 with a delay of -724ms
+204ms ║RunTime Analysis CS > 22ms > PS > 55ms > PE > 127ms > CE
+210ms ║Runtime (58070 bytes) successfully initialized in 55ms (v0.2.101.20171227) (208ms)
+211ms ║╔Execution stage started
+212ms ║╚Execution stage complete. (1ms)
+214ms ╚Event processed successfully (213ms)
1/4/2018, 6:09:22 PM +197ms
+1ms ╔Received event [Keith Presence Sensor].currentPlace = with a delay of 124ms
+183ms ║RunTime Analysis CS > 16ms > PS > 62ms > PE > 106ms > CE
+188ms ║Runtime (58085 bytes) successfully initialized in 62ms (v0.2.101.20171227) (187ms)
+189ms ║╔Execution stage started
+206ms ║║Comparison (string) stays (string) House = false (1ms)
+208ms ║║Comparison (string) stays (string) House = false (1ms)
+210ms ║║Cancelling any timed trigger schedules for device :a33e14a1d9fbc2eb5253c7c8cbcc0dc1: for condition 83
+211ms ║║Cancelling statement #83’s schedules…
+211ms ║║Cancelling any timed trigger schedules for device :949dab343e304a0ed7093bd8803ae97e: for condition 83
+212ms ║║Cancelling statement #83’s schedules…
+213ms ║║Condition #83 evaluated false (17ms)
+213ms ║║Cancelling statement #2’s schedules…
+214ms ║║Condition group #2 evaluated false (state did not change) (20ms)
+224ms ║║Comparison (string) stays (string) House = false (1ms)
+225ms ║║Comparison (string) stays (string) House = false (1ms)
+227ms ║║Cancelling any timed trigger schedules for device :a33e14a1d9fbc2eb5253c7c8cbcc0dc1: for condition 82
+228ms ║║Cancelling statement #82’s schedules…
+228ms ║║Cancelling any timed trigger schedules for device :949dab343e304a0ed7093bd8803ae97e: for condition 82
+229ms ║║Cancelling statement #82’s schedules…
+230ms ║║Condition #82 evaluated false (13ms)
+232ms ║╚Execution stage complete. (43ms)
+233ms ╚Event processed successfully (234ms)
1/4/2018, 6:09:19 PM +843ms
+1ms ╔Received event [Renee Presence Sensor].currentPlace = with a delay of 75ms
+206ms ║RunTime Analysis CS > 17ms > PS > 66ms > PE > 123ms > CE
+210ms ║Runtime (57929 bytes) successfully initialized in 66ms (v0.2.101.20171227) (209ms)
+211ms ║╔Execution stage started
+228ms ║║Comparison (string) House stays (string) House = true (1ms)
+230ms ║║Comparison (string) stays (string) House = false (1ms)
+232ms ║║Adding a timed trigger schedule for device :a33e14a1d9fbc2eb5253c7c8cbcc0dc1: for condition 83
+233ms ║║Cancelling any timed trigger schedules for device :949dab343e304a0ed7093bd8803ae97e: for condition 83
+234ms ║║Cancelling statement #83’s schedules…
+235ms ║║Condition #83 evaluated false (16ms)
+236ms ║║Cancelling statement #2’s schedules…
+236ms ║║Cancelling condition #2’s schedules…
+237ms ║║Condition group #2 evaluated false (state changed) (20ms)
+248ms ║║Comparison (string) House stays (string) House = true (1ms)
+250ms ║║Comparison (string) stays (string) House = false (1ms)
+252ms ║║Adding a timed trigger schedule for device :a33e14a1d9fbc2eb5253c7c8cbcc0dc1: for condition 82
+254ms ║║Cancelling any timed trigger schedules for device :949dab343e304a0ed7093bd8803ae97e: for condition 82
+254ms ║║Cancelling statement #82’s schedules…
+255ms ║║Cancelling condition #82’s schedules…
+256ms ║║Condition #82 evaluated false (16ms)
+258ms ║╚Execution stage complete. (47ms)
+260ms ║Setting up scheduled job for Thu, Jan 4 2018 @ 6:09:30 PM CST (in 9.973s), with 1 more job pending
+278ms ╚Event processed successfully (277ms)

Piston:


#57

Don’t make any changes based on results today. My presence sensor didn’t work today either… and it seems we’re not alone:


#58

I saw the update that everything should be working, but the piston is still not working with the screenshot above. I did turn on debugging in the presence app. Logs below:

Then here are the logs when I left:

1/5/2018, 11:05:16 AM +796ms

+1ms ╔Received event [Home].time = 1515171917258 with a delay of -462ms
+190ms ║RunTime Analysis CS > 21ms > PS > 69ms > PE > 99ms > CE
+197ms ║Runtime (58073 bytes) successfully initialized in 69ms (v0.2.101.20171227) (196ms)
+198ms ║╔Execution stage started
+204ms ║║Cancelling condition #2’s schedules…
+242ms ║║Fast executing schedules, waiting for 239ms to sync up
+527ms ║╚Execution stage complete. (329ms)
+528ms ╚Event processed successfully (528ms)

1/5/2018, 11:05:07 AM +41ms

+2ms ╔Received event [Keith Presence Sensor].currentPlace = with a delay of 272ms
+189ms ║RunTime Analysis CS > 25ms > PS > 56ms > PE > 108ms > CE
+195ms ║Runtime (58089 bytes) successfully initialized in 56ms (v0.2.101.20171227) (193ms)
+196ms ║╔Execution stage started
+212ms ║║Comparison (string) stays (string) House = false (2ms)
+213ms ║║Comparison (string) House stays (string) House = true (1ms)
+215ms ║║Cancelling any timed trigger schedules for device :a33e14a1d9fbc2eb5253c7c8cbcc0dc1: for condition 83
+216ms ║║Cancelling statement #83’s schedules…
+216ms ║║Adding a timed trigger schedule for device :949dab343e304a0ed7093bd8803ae97e: for condition 83
+218ms ║║Condition #83 evaluated false (17ms)
+219ms ║║Cancelling statement #2’s schedules…
+220ms ║║Cancelling condition #2’s schedules…
+220ms ║║Condition group #2 evaluated false (state changed) (19ms)
+231ms ║║Comparison (string) stays (string) House = false (1ms)
+233ms ║║Comparison (string) House stays (string) House = true (0ms)
+234ms ║║Cancelling any timed trigger schedules for device :a33e14a1d9fbc2eb5253c7c8cbcc0dc1: for condition 82
+235ms ║║Cancelling statement #82’s schedules…
+236ms ║║Adding a timed trigger schedule for device :949dab343e304a0ed7093bd8803ae97e: for condition 82
+237ms ║║Condition #82 evaluated false (14ms)
+240ms ║╚Execution stage complete. (43ms)
+241ms ║Setting up scheduled job for Fri, Jan 5 2018 @ 11:05:17 AM CST (in 9.976s), with 1 more job pending
+250ms ╚Event processed successfully (249ms)

And when I arrived:

1/5/2018, 11:48:51 AM +577ms

+1ms ╔Received event [Home].time = 1515174532689 with a delay of -1112ms
+192ms ║RunTime Analysis CS > 17ms > PS > 58ms > PE > 117ms > CE
+198ms ║Runtime (58080 bytes) successfully initialized in 58ms (v0.2.101.20171227) (197ms)
+200ms ║╔Execution stage started
+208ms ║║Cancelling condition #2’s schedules…
+265ms ║║Fast executing schedules, waiting for 848ms to sync up
+1308ms ║╚Execution stage complete. (1109ms)
+1310ms ╚Event processed successfully (1310ms)

1/5/2018, 11:48:42 AM +475ms

+2ms ╔Received event [Keith Presence Sensor].currentPlace = House with a delay of 135ms
+188ms ║RunTime Analysis CS > 24ms > PS > 53ms > PE > 111ms > CE
+194ms ║Runtime (58089 bytes) successfully initialized in 53ms (v0.2.101.20171227) (191ms)
+195ms ║╔Execution stage started
+210ms ║║Comparison (string) House stays (string) House = true (1ms)
+211ms ║║Comparison (string) House stays (string) House = true (1ms)
+213ms ║║Adding a timed trigger schedule for device :a33e14a1d9fbc2eb5253c7c8cbcc0dc1: for condition 83
+215ms ║║Adding a timed trigger schedule for device :949dab343e304a0ed7093bd8803ae97e: for condition 83
+217ms ║║Condition #83 evaluated false (16ms)
+217ms ║║Cancelling statement #2’s schedules…
+218ms ║║Cancelling condition #2’s schedules…
+219ms ║║Condition group #2 evaluated false (state changed) (18ms)
+227ms ║║Comparison (string) House stays (string) House = true (1ms)
+229ms ║║Comparison (string) House stays (string) House = true (1ms)
+230ms ║║Adding a timed trigger schedule for device :a33e14a1d9fbc2eb5253c7c8cbcc0dc1: for condition 82
+232ms ║║Adding a timed trigger schedule for device :949dab343e304a0ed7093bd8803ae97e: for condition 82
+234ms ║║Condition #82 evaluated false (13ms)
+236ms ║╚Execution stage complete. (41ms)
+238ms ║Setting up scheduled job for Fri, Jan 5 2018 @ 11:48:52 AM CST (in 9.977s), with 3 more jobs pending
+335ms ╚Event processed successfully (334ms)


#59

That’s hard to discern what is happening when it wakes up 10 seconds later.

What about it isn’t working? Presence in SmartThings is right? Presence in webCoRE? Arrival departure messages not triggering?

If we can answer all those we’ll have some direction for what is or isn’t working. it might be helpful to turn on Trace and force it to execute… see what part(s) of the piston are run when you first arrive and when it wakes up 10 seconds later to see if you’re still there. I’d change “on events from presence sensor” to something easy to trigger while you’re at the computer, like a light.


#60

With the new, "currentPlace stays “House”, nothing works. No messages, not status changes.

I have the trace on and ran it. This is the result:

1/5/2018, 3:05:51 PM +43ms
+2ms ╔Received event [Home].test = 1515186351040 with a delay of 2ms
+166ms ║RunTime Analysis CS > 16ms > PS > 35ms > PE > 114ms > CE
+172ms ║Runtime (58074 bytes) successfully initialized in 35ms (v0.2.101.20171227) (169ms)
+176ms ║╔Execution stage started
+181ms ║╚Execution stage complete. (7ms)
+185ms ╚Event processed successfully (185ms)


#61

Yeah, test won’t break into the “on events from presence sensors” so none of the piston will execute. That’s why you don’t see any conditions being evaluated.

The easiest way to get around it for testing is to change your “On events from any presence senors 1 or 2” to “on events from light switch” and cycling that. Then the rest of the piston should execute.

Option 2 is to drag your two main IF statements outside of the “on events” block. Then they’ll be processed when you click ‘test’.

Trace is actually the red, green, and blue lines you see to the left of your piston as it executes. You’d have to grab snapshots (printscreen, not the green or red camera buttons) of it on initial execution, and then again when it wakes up ten seconds later to see what part(s) of the piston are running each time. That, combined with the log, will make it possible to fix whatever isn’t working.


#62

Ok, I noticed something when we both came home this evening… My presence sensor was picked up first and the first condition worked, light came on.

I was hoping the ASYNC IF would fire at the same time, which would be perfect, but it is waiting for the 5 minutes to lapse on the entryway light before it moved to the ASYNC IF. Once the 5 minutes lapsed, it did evaluate the section that sets the location status.

Do I need to move the location status IF or make both the light and location status ASYNC IFs?


#63

I tried to create a new piston based on your suggestion with light switches in the house. I thought I was getting the results I wanted by using the, “not followed by (negated)”, in the statements, but I am lost in the logic now.

I am starting to lose hope that I’ll ever get this working. It sucks that I can’t ignore these, “false,” location changes in the webCoRE app :unamused:


#64

Bangali, I’ve been using a modified version of your piston (using events from currentplace) for presence notifications/mode switches for my hubby and me. However, I can’t figure out how to send arrival/departure notifications if we BOTH leave at the same time.

Currently, I get “Hubby has left /arrived at X time” and within a minute a get “Lisa has left/arrived at X time.” Is there a way to use a wait time/variable combination that both of our currentplaces have changed within a minute of each other, so I can get the message “Hubby and Lisa have left/arrived at X time?”

Thanks!!


#65

the challenge as you have figured out is that for ST both of you are leaving and arriving separately. seconds apart but separately.

yes. but that will also delay these notifications by that many seconds.


#66

I don’t mind delaying the notification by by up to a minute. Here’s what I came up with. I have a 70 second wait at the top (async) to give this part of the piston time to complete before moving on to the home/away actions:


#67

so does it work? :slight_smile:


#68

Nope. I immediately got a push notification when the first sensor triggered without waiting the full 70 seconds to “see” if the second sensor triggered.

Where should I put in a “wait” to be sure the variable doesn’t “fire” on the first sensor trigger?


#69

give this a try … change all presence to currentplace … i dont use wC presence sensor so had to change it:


#70

Looks like it’s going to be a winner! I was testing with virtual presence, as well… don’t know yet how to create a virtual WebCore presence sensor that can be manually triggered for currentPlace. I have no doubt it’ll work with Ady’s WebCore sensor. Many thanks!!!


#71

sometimes things that should work dont … so give it a try first. :slight_smile: