So with this code, Presence Sensor 3 (the Android phone) came home tonight:
Logs:
2/3/2018, 11:53:17 PM +671ms
+1ms ╔Received event [Garage Door].contact = closed with a delay of 641ms
+169ms ║RunTime Analysis CS > 19ms > PS > 95ms > PE > 55ms > CE
+171ms ║Runtime (43685 bytes) successfully initialized in 95ms (v0.2.102.20180116) (169ms)
+172ms ║╔Execution stage started
+212ms ║║Comparison (time) 85997847 is_between (time) 1517708160000 .. (time) 1517670660000 = true (8ms)
+213ms ║║Time restriction check passed
+214ms ║║Condition #35 evaluated true (38ms)
+215ms ║║Condition group #null evaluated true (state did not change) (39ms)
+221ms ║║Comparison (enum) closed changes_to (string) open = false (0ms)
+222ms ║║Cancelling condition #39's schedules...
+223ms ║║Condition #39 evaluated false (5ms)
+224ms ║║Condition group #17 evaluated false (state did not change) (6ms)
+226ms ║║Cancelling statement #26's schedules...
+231ms ║║Log: IF statement was false.
+232ms ║║Executed virtual command log (1ms)
+234ms ║╚Execution stage complete. (62ms)
+236ms ╚Event processed successfully (235ms)
2/3/2018, 11:51:43 PM +136ms
+1ms ╔Received event [Garage Door].contact = open with a delay of 432ms
+141ms ║RunTime Analysis CS > 18ms > PS > 75ms > PE > 49ms > CE
+143ms ║Runtime (43682 bytes) successfully initialized in 75ms (v0.2.102.20180116) (141ms)
+144ms ║╔Execution stage started
+178ms ║║Comparison (time) 85903284 is_between (time) 1517708160000 .. (time) 1517670660000 = true (7ms)
+179ms ║║Time restriction check passed
+180ms ║║Condition #35 evaluated true (32ms)
+181ms ║║Condition group #null evaluated true (state did not change) (33ms)
+186ms ║║Comparison (enum) open changes_to (string) open = true (1ms)
+187ms ║║Cancelling condition #39's schedules...
+188ms ║║Condition #39 evaluated true (5ms)
+204ms ║║Comparison (enum) not present changed = false (9ms)
+205ms ║║Condition #37 evaluated false (15ms)
+205ms ║║Condition group #40 evaluated false (state did not change) (16ms)
+220ms ║║Comparison (enum) present changed = false (9ms)
+221ms ║║Condition #43 evaluated false (14ms)
+222ms ║║Condition group #42 evaluated false (state did not change) (15ms)
+222ms ║║Condition group #36 evaluated false (state did not change) (33ms)
+223ms ║║Condition group #17 evaluated false (state did not change) (40ms)
+225ms ║║Cancelling statement #26's schedules...
+230ms ║║Log: IF statement was false.
+231ms ║║Executed virtual command log (1ms)
+233ms ║╚Execution stage complete. (89ms)
+234ms ╚Event processed successfully (234ms)
It failed this time again to achieve what I wanted but I noticed that his sensor actually didn’t change state from “away” to “home” until 11:54pm according to the ST app. That’s after the Garage Door (Contact Sensor 1) open/close had happened (according to the logs above), which is really odd. I wonder if it has something to do with the Android phone’s location update being slow.
I will keep the code as is for now and see if it’ll repro the next time and see if Presence Sensor 1 (the iPhone) will have this issue.