Another Arrivals Question


#1

1) Give a description of the problem
New to SmartThings and even newer to WebCoRE. I have been browsing around the forum and am coming across a number of examples for triggering pistons on presence arrivals.

However I can’t seem to find / not really sure the best way to achieve the following:

2) What is the expected behavior?
When either of 2 presence sensors (SmartThings app for iOS) arrive trigger an event as long as there is no one else home.

I.e only trigger piston if it is the first to arrive.

Also if both arrive at the same time then trigger the piston.

Finally have a safety to prevent dropout triggering the piston

3) What is happening/not happening?
N/A - piston not written yet

**4) Post a Green Snapshot of the piston!
N/a

I would really appreciate some help with where to start

Thanks

James


#2

Try something along the lines of this

If any of presence 1 or presence 2 changes to present
And 
both of presence 1 and presence 2 were not present for XX minutes
Then
Do your actions 
End if

#3

Thanks for the advice.

This is the piston, I’ve not set any action apart from sending a test message

However it its not working as expected.
When I popped out, I drive out and back into the location zone, and I received the test message despite the changes taking place within the 5 minute window.

I have posted a copy of the SmartThings presence log as well as the webcore log below.

Webcore Log:
12/01/2018, 13:15:12 +637ms
+5ms ╔Received event [James’s iPhone].presence = present with a delay of 352ms
+181ms ║RunTime Analysis CS > 40ms > PS > 94ms > PE > 51ms > CE
+191ms ║Runtime (37747 bytes) successfully initialized in 94ms (v0.2.101.20171227) (180ms)
+195ms ║╔Execution stage started
+281ms ║║Comparison (enum) present changes_to (string) present = true (9ms)
+290ms ║║Cancelling condition #5’s schedules…
+291ms ║║Condition #5 evaluated true (57ms)
+294ms ║║Cancelling condition #4’s schedules…
+296ms ║║Condition group #4 evaluated true (state changed) (62ms)
+297ms ║║Cancelling condition #1’s schedules…
+298ms ║║Condition group #1 evaluated true (state changed) (69ms)
+309ms ║║Cancelling statement #8’s schedules…
+374ms ║║Executed virtual command [James’s iPhone].sendNotificationToContacts (41ms)
+389ms ║╚Execution stage complete. (198ms)
+399ms ╚Event processed successfully (401ms)
12/01/2018, 13:13:34 +856ms
+7ms ╔Received event [James’s iPhone].presence = not present with a delay of 71ms
+109ms ║RunTime Analysis CS > 25ms > PS > 43ms > PE > 37ms > CE
+116ms ║Runtime (37740 bytes) successfully initialized in 43ms (v0.2.101.20171227) (107ms)
+120ms ║╔Execution stage started
+141ms ║║Comparison (enum) not present changes_to (string) present = false (7ms)
+146ms ║║Cancelling condition #5’s schedules…
+147ms ║║Condition #5 evaluated false (20ms)
+183ms ║║Comparison (enum) not present was_not (string) not present = false (26ms)
+185ms ║║Condition #10 evaluated false (37ms)
+186ms ║║Cancelling condition #4’s schedules…
+187ms ║║Condition group #4 evaluated false (state changed) (61ms)
+188ms ║║Cancelling condition #1’s schedules…
+189ms ║║Condition group #1 evaluated false (state changed) (64ms)
+195ms ║╚Execution stage complete. (79ms)
+199ms ╚Event processed successfully (199ms)
12/01/2018, 13:12:42 +87ms
+6ms ╔Received event [James’s iPhone].presence = present with a delay of 75ms
+104ms ║RunTime Analysis CS > 25ms > PS > 39ms > PE > 36ms > CE
+110ms ║Runtime (37746 bytes) successfully initialized in 39ms (v0.2.101.20171227) (103ms)
+114ms ║╔Execution stage started
+145ms ║║Comparison (enum) present changes_to (string) present = true (9ms)
+147ms ║║Cancelling condition #5’s schedules…
+148ms ║║Condition #5 evaluated true (23ms)
+149ms ║║Cancelling condition #4’s schedules…
+150ms ║║Condition group #4 evaluated true (state changed) (24ms)
+151ms ║║Cancelling condition #1’s schedules…
+151ms ║║Condition group #1 evaluated true (state changed) (27ms)
+154ms ║║Cancelling statement #8’s schedules…
+203ms ║║Executed virtual command [James’s iPhone].sendNotificationToContacts (39ms)
+206ms ║╚Execution stage complete. (95ms)
+210ms ╚Event processed successfully (210ms)
12/01/2018, 12:58:18 +114ms
+6ms ╔Received event [James’s iPhone].presence = not present with a delay of 58ms
+84ms ║RunTime Analysis CS > 20ms > PS > 27ms > PE > 33ms > CE
+90ms ║Runtime (37739 bytes) successfully initialized in 27ms (v0.2.101.20171227) (83ms)
+95ms ║╔Execution stage started
+115ms ║║Comparison (enum) not present changes_to (string) present = false (7ms)
+120ms ║║Cancelling condition #5’s schedules…
+121ms ║║Condition #5 evaluated false (20ms)
+239ms ║║Comparison (enum) not present was_not (string) not present = false (107ms)
+240ms ║║Condition #10 evaluated false (118ms)
+241ms ║║Cancelling condition #4’s schedules…
+242ms ║║Condition group #4 evaluated false (state changed) (141ms)
+243ms ║║Cancelling condition #1’s schedules…
+244ms ║║Condition group #1 evaluated false (state changed) (144ms)
+250ms ║╚Execution stage complete. (159ms)
+254ms ╚Event processed successfully (254ms)
12/01/2018, 12:58:04 +190ms
+7ms ╔Received event [James’s iPhone].presence = present with a delay of 82ms
+105ms ║RunTime Analysis CS > 26ms > PS > 40ms > PE > 36ms > CE
+111ms ║Runtime (37746 bytes) successfully initialized in 40ms (v0.2.101.20171227) (102ms)
+115ms ║╔Execution stage started
+139ms ║║Comparison (enum) present changes_to (string) present = true (8ms)
+144ms ║║Cancelling condition #5’s schedules…
+145ms ║║Condition #5 evaluated true (24ms)
+147ms ║║Cancelling condition #4’s schedules…
+148ms ║║Condition group #4 evaluated true (state changed) (27ms)
+149ms ║║Cancelling condition #1’s schedules…
+150ms ║║Condition group #1 evaluated true (state changed) (29ms)
+152ms ║║Cancelling statement #8’s schedules…
+203ms ║║Executed virtual command [James’s iPhone].sendNotificationToContacts (39ms)
+207ms ║╚Execution stage complete. (94ms)
+211ms ╚Event processed successfully (210ms)
12/01/2018, 12:57:22 +298ms
+7ms ╔Received event [James’s iPhone].presence = not present with a delay of 69ms
+86ms ║RunTime Analysis CS > 22ms > PS > 30ms > PE > 30ms > CE
+92ms ║Runtime (37744 bytes) successfully initialized in 30ms (v0.2.101.20171227) (84ms)
+96ms ║╔Execution stage started
+116ms ║║Comparison (enum) not present changes_to (string) present = false (6ms)
+118ms ║║Condition #5 evaluated false (16ms)
+153ms ║║Comparison (enum) not present was_not (string) not present = true (25ms)
+168ms ║║Comparison (enum) not present was_not (string) not present = false (13ms)
+169ms ║║Condition #10 evaluated false (50ms)
+170ms ║║Condition group #4 evaluated false (state did not change) (68ms)
+171ms ║║Condition group #1 evaluated false (state did not change) (70ms)
+174ms ║╚Execution stage complete. (81ms)
+178ms ╚Event processed successfully (178ms)

I can’t quite work out why this is happening as it is triggering if I leave and return within the 5 minutes as well as if it outside the 5 minute window.

Below is a screenshot of the messages received:


#4

I think I have just seen my mistake, the IF statement is OR not AND.

I’ll change this first and try again.


#5

Yeah, that was it…

Just so you know, you can also create Virtual (simulated) presence sensors in the ST IDE and then toggle them Away/Present from your phone (or from a piston). That way you don’t actually have to leave home to test things… You can use it to verify things are working and then swap it back to your real ones when done.


#6

Thanks for the tip

Saves me walking about outside for 5 mins