Detect Door Open and check which phone(s) arrived and Announce on GHome


#1

1) Give a description of the problem
I am writing a Piston where I want to :

  • Detect Back Door Opened, AND along with that
  • Determine which Phone or Phone(s) were away (away time to be >20 minutes (configurable)) and has now arrived home.
    Based on it, do a Google Home announcement.

I am attaching the sample Piston below which I have written, but After multiple tries it hasn’t worked.

2) What is the expected behavior?
Annnouncement/Speak on Google Home, when above criteria is met.

3) What is happening/not happening?
Expected it to do the announcement/Speak on Google Home. Doesn’t happen. Other basic Pistons work. So, the base pipeline of Piston announcing on GHome works.

4) Post a Green Snapshot of the pistonimage


Above is partial screenshot to tell the if else things I am doing.

5) Attach any logs (From ST IDE and by turning logging level to Full)
12/27/2018, 2:35:37 AM +234ms
+1ms ╔Received event [Home].test = 1545906937232 with a delay of 1ms
+141ms ║RunTime Analysis CS > 22ms > PS > 74ms > PE > 45ms > CE
+144ms ║Runtime (45399 bytes) successfully initialized in 74ms (v0.3.108.20180906) (142ms)
+146ms ║╔Execution stage started
+161ms ║║Condition #2 evaluated false (8ms)
+163ms ║║Condition group #1 evaluated false (state did not change) (9ms)
+168ms ║╚Execution stage complete. (22ms)
+170ms ╚Event processed successfully (170ms)
12/27/2018, 2:35:25 AM +279ms
+1ms ╔Received event [Home].test = 1545906925278 with a delay of 0ms
+140ms ║RunTime Analysis CS > 21ms > PS > 72ms > PE > 47ms > CE
+143ms ║Runtime (45399 bytes) successfully initialized in 72ms (v0.3.108.20180906) (141ms)
+145ms ║╔Execution stage started
+161ms ║║Condition #2 evaluated false (8ms)
+162ms ║║Condition group #1 evaluated false (state did not change) (10ms)
+167ms ║╚Execution stage complete. (23ms)
+169ms ╚Event processed successfully (169ms)
12/26/2018, 9:19:52 PM +114ms
+1ms ╔Received event [Home].time = 1545887993851 with a delay of -1738ms
+232ms ║RunTime Analysis CS > 49ms > PS > 113ms > PE > 70ms > CE
+236ms ║Runtime (45405 bytes) successfully initialized in 113ms (v0.3.108.20180906) (233ms)
+238ms ║╔Execution stage started
+239ms ║╚Execution stage complete. (2ms)
+241ms ╚Event processed successfully (241ms)
12/26/2018, 9:18:15 PM +699ms
+2ms ╔Received event [Back Door Sensor].contact = closed with a delay of 391ms
+180ms ║RunTime Analysis CS > 27ms > PS > 107ms > PE > 46ms > CE
+183ms ║Runtime (45404 bytes) successfully initialized in 107ms (v0.3.108.20180906) (179ms)
+184ms ║╔Execution stage started
+195ms ║║Comparison (enum) closed changes_to (string) open = false (0ms)
+197ms ║║Cancelling condition #2’s schedules…
+198ms ║║Condition #2 evaluated false (8ms)
+199ms ║║Cancelling condition #1’s schedules…
+201ms ║║Condition group #1 evaluated false (state changed) (10ms)
+204ms ║╚Execution stage complete. (20ms)
+206ms ╚Event processed successfully (205ms)
12/26/2018, 9:17:53 PM +493ms
+2ms ╔Received event [Back Door Sensor].contact = open with a delay of 175ms
+226ms ║RunTime Analysis CS > 29ms > PS > 152ms > PE > 46ms > CE
+229ms ║Runtime (45411 bytes) successfully initialized in 152ms (v0.3.108.20180906) (226ms)
+230ms ║╔Execution stage started
+241ms ║║Comparison (enum) open changes_to (string) open = true (1ms)
+243ms ║║Cancelling condition #2’s schedules…
+244ms ║║Condition #2 evaluated true (7ms)
+254ms ║║Comparison (string) unconfigured is_not (string) away = true (3ms)
+256ms ║║Condition #3 evaluated true (11ms)
+257ms ║║Cancelling condition #1’s schedules…
+258ms ║║Condition group #1 evaluated true (state changed) (22ms)
+279ms ║║Comparison (enum) present changed = false (11ms)
+281ms ║║Condition #5 evaluated false (20ms)
+282ms ║║Condition group #4 evaluated false (state did not change) (21ms)
+300ms ║║Comparison (enum) present changed = false (9ms)
+302ms ║║Condition #10 evaluated false (16ms)
+304ms ║║Condition group #9 evaluated false (state did not change) (18ms)
+327ms ║║Comparison (enum) present changed = true (13ms)
+329ms ║║Cancelling condition #13’s schedules…
+330ms ║║Condition #13 evaluated true (23ms)
+341ms ║║Comparison (enum) present is (string) present = true (2ms)
+344ms ║║Condition #14 evaluated true (11ms)
+345ms ║║Cancelling condition #12’s schedules…
+346ms ║║Condition group #12 evaluated true (state changed) (40ms)
+350ms ║║Cancelling statement #15’s schedules…
+355ms ║║Executed virtual command wait (1ms)
+357ms ║║Requesting a wake up for Wed, Dec 26 2018 @ 9:19:53 PM PST (in 120.0s)
+365ms ║╚Execution stage complete. (135ms)
+367ms ║Setting up scheduled job for Wed, Dec 26 2018 @ 9:19:53 PM PST (in 119.992s)
+376ms ╚Event processed successfully (375ms)


#2

if you post an actual green snapshot or portion of one it will tag all the conditions so we can tie to the log. I can see it is executing the wait but evidently not the speak. Add a console log command right after the speak to help verify if it is executing that section. This will determine if the problem is with the piston logic or just the speak command.


#3

@guxdude Thanks for responding.

GREEN SNAPSHOT:

LOGS:

Logs at the time, when “Presence Sensor 4” and “Presence Sensor 5” were AWAY, and then both sensor together Entered HOME. As per CURRENT LOGIC, ELSE at Line No. 49 should become TRUE for “Presence Sensor 4” and execute.

2/27/2018, 8:22:39 AM +408ms
+1ms ╔Received event [Back Door Sensor].contact = closed with a delay of 667ms
+190ms ║RunTime Analysis CS > 25ms > PS > 101ms > PE > 64ms > CE
+194ms ║Runtime (45406 bytes) successfully initialized in 101ms (v0.3.108.20180906) (191ms)
+195ms ║╔Execution stage started
+210ms ║║Comparison (enum) closed changes_to (string) open = false (2ms)
+213ms ║║Cancelling condition #2's schedules...
+214ms ║║Condition #2 evaluated false (10ms)
+216ms ║║Cancelling condition #1's schedules...
+218ms ║║Condition group #1 evaluated false (state changed) (14ms)
+222ms ║╚Execution stage complete. (26ms)
+224ms ╚Event processed successfully (224ms)
12/27/2018, 8:22:34 AM +17ms
+2ms ╔Received event [Back Door Sensor].contact = open with a delay of 196ms
+164ms ║RunTime Analysis CS > 24ms > PS > 97ms > PE > 43ms > CE
+167ms ║Runtime (45407 bytes) successfully initialized in 97ms (v0.3.108.20180906) (165ms)
+169ms ║╔Execution stage started
+180ms ║║Comparison (enum) open changes_to (string) open = true (1ms)
+182ms ║║Cancelling condition #2's schedules...
+183ms ║║Condition #2 evaluated true (8ms)
+192ms ║║Comparison (string) unconfigured is_not (string) away = true (2ms)
+194ms ║║Condition #3 evaluated true (10ms)
+195ms ║║Cancelling condition #1's schedules...
+196ms ║║Condition group #1 evaluated true (state changed) (21ms)
+239ms ║║Comparison (enum) present changed = false (32ms)
+241ms ║║Condition #5 evaluated false (40ms)
+242ms ║║Condition group #4 evaluated false (state did not change) (43ms)
+275ms ║║Comparison (enum) present changed = false (23ms)
+277ms ║║Condition #10 evaluated false (31ms)
+278ms ║║Condition group #9 evaluated false (state did not change) (33ms)
+324ms ║║Comparison (enum) present changed = false (35ms)
+326ms ║║Cancelling condition #13's schedules...
+328ms ║║Condition #13 evaluated false (46ms)
+330ms ║║Cancelling condition #12's schedules...
+332ms ║║Condition group #12 evaluated false (state changed) (50ms)
+478ms ║║Comparison (enum) present changed = false (133ms)
+480ms ║║Condition #28 evaluated false (143ms)
+482ms ║║Condition group #27 evaluated false (state did not change) (145ms)
+487ms ║╚Execution stage complete. (319ms)
+488ms ╚Event processed successfully (488ms)  

Please let me know if you need more information. Thanks!


#4

@guxdude update on above post : Detect Door Open and check which phone(s) arrived and Announce on GHome

Today Presence Sensor 2 and 4 arrived together, and the if Line 23 became True and announced . But still struggling with later if cases which don’t work if say “Presence Sensor 2” only arrives or Presence Sensor 4 only arrives. Looks like only 1st if works if it’s True, and subsequent ones don’t. Not sure if “if structuring” is bad.


#5

Sorry I’m not more help here. The logic seems sound but I think there are too many variables in play. Your changed in the last 20 minutes could be anything from 1 to 20 minutes so I am not sure it accomplishes what you want. This piston basically will run every time the door is opened (the lightening bolt) and the should check for whose presence has changed and is now present. I know there are some issues with multiple conditions where not all are evaluated. You might be able to overcome this by using groups. i.e., put each list of conditions into a group rather than listing them independently. This will force the checking of all conditions before deciding if true or false.


#6

@swapan check out my thread that’s near the top of this forum about a very similar subject . I’ve been working on it with ike ( actually he has been doing all the work ) and it looks like we may have cracked it .


#7

Pressing TEST on that piston won’t work because for any condition to evaluate true, at least one of your presence sensors has to change to ‘present’.

if you want to test functionality, temporarily change your “presence sensor changes to” to “presence sensor is”… then you can test and get it working. Once it’s working, go back to using the ‘changes to’ triggers.