Piston not firing Echo Speaks after wait


#1

1) Give a description of the problem
I have been working on my SHM piston over the last few days. It watches for changes to the front and back door locks (based on this awesome example: Door Locks and User Codes). It also watches for changes in occupancy levels (based on another example I found a few days ago).

2) What is the expected behaviour?
When the piston is triggered to execute, it is supposed to do a few things, then wait for there to be activity on the relevant motion sensor, then speak a random welcome home phrase.

3) What is happening/not happening?
The speaking is not happening. I can’t tell if there’s something wrong with how I have the Wait command working or if there’s something wrong with the speaking itself. The rest of the piston triggers successfully.

I’m also surprised that the While command seems to be causing the entire piston to fire a second time, then it just ends. I thought While would continue running. Maybe there’s a better way to do that than using a Wait inside the White?

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

5) Attach logs after turning logging level to Full
5/17/2020, 4:11:48 PM +88ms
+0ms â•”Received event [Home].time = 1589757109440 with a delay of -1353ms
+143ms â•‘RunTime Analysis CS > 18ms > PS > 60ms > PE > 65ms > CE
+147ms â•‘Runtime (76995 bytes) successfully initialized in 60ms (v0.3.110.20191009) (146ms)
+148ms â•‘â•”Execution stage started
+154ms â•‘â•‘Evaluating switch with values [[i:2:null:0, v:[t:dynamic, v:keypad]]]
+157ms â•‘â•‘Comparison (dynamic) keypad is (string) manual = false (1ms)
+162ms â•‘â•‘Comparison (dynamic) keypad is (string) keypad = true (1ms)
+167ms â•‘â•‘Evaluating switch with values [[i:24:null:0, v:[t:boolean, v:false, d:2, vt:string]]]
+170ms â•‘â•‘Comparison (boolean) false is (boolean) false = true (1ms)
+183ms â•‘â•‘Evaluating switch with values [[i::473ef8ef2e026802057d9bd6a0fb5adf::lock, v:[t:enum, v:unlocked, d::473ef8ef2e026802057d9bd6a0fb5adf:, a:lock, i:[], x:false, vt:string]]]
+186ms â•‘â•‘Comparison (enum) unlocked is (string) locked = false (1ms)
+190ms â•‘â•‘Comparison (enum) unlocked is (string) unknown = false (1ms)
+199ms â•‘â•‘Evaluating switch with values [[i:122:null:0, v:[t:dynamic, v:keypad]]]
+201ms â•‘â•‘Comparison (dynamic) keypad is (string) manual = false (1ms)
+206ms â•‘â•‘Comparison (dynamic) keypad is (string) keypad = true (1ms)
+211ms â•‘â•‘Evaluating switch with values [[i:131:null:0, v:[t:boolean, v:false, d:2, vt:string]]]
+214ms â•‘â•‘Comparison (boolean) false is (boolean) false = true (1ms)
+225ms â•‘â•‘Evaluating switch with values [[i::473ef8ef2e026802057d9bd6a0fb5adf::lock, v:[t:enum, v:unlocked, d::473ef8ef2e026802057d9bd6a0fb5adf:, a:lock, i:[], x:false, vt:string]]]
+228ms â•‘â•‘Comparison (enum) unlocked is (string) locked = false (1ms)
+233ms â•‘â•‘Comparison (enum) unlocked is (string) unknown = false (1ms)
+313ms â•‘â•‘Comparison (enum) active is (string) inactive = false (2ms)
+314ms ║║Cancelling condition #169’s schedules…
+315ms â•‘â•‘Condition #169 evaluated false (7ms)
+316ms ║║Cancelling condition #168’s schedules…
+317ms â•‘â•‘Condition group #168 evaluated false (state changed) (10ms)
+319ms ║║Cancelling statement #172’s schedules…
+390ms ║║Executed physical command [Echo - Kitchen Echo Dot].playText([What’s up?, 5]) (60ms)
+391ms â•‘â•‘Executed [Echo - Kitchen Echo Dot].playText (61ms)
+396ms â•‘â•‘Comparison (dynamic) null changes_to (string) Keypad = false (1ms)
+397ms â•‘â•‘Condition #198 evaluated false (3ms)
+398ms â•‘â•‘Condition group #197 evaluated false (state did not change) (4ms)
+400ms â•‘â•šExecution stage complete. (253ms)
+401ms â•šEvent processed successfully (401ms)
5/17/2020, 4:11:44 PM +98ms
+1ms â•”Received event [Home].time = 1589757105436 with a delay of -1338ms
+152ms â•‘RunTime Analysis CS > 21ms > PS > 62ms > PE > 69ms > CE
+157ms â•‘Runtime (76995 bytes) successfully initialized in 62ms (v0.3.110.20191009) (154ms)
+157ms â•‘â•”Execution stage started
+163ms â•‘â•‘Evaluating switch with values [[i:2:null:0, v:[t:dynamic, v:keypad]]]
+166ms â•‘â•‘Comparison (dynamic) keypad is (string) manual = false (1ms)
+171ms â•‘â•‘Comparison (dynamic) keypad is (string) keypad = true (1ms)
+177ms â•‘â•‘Evaluating switch with values [[i:24:null:0, v:[t:boolean, v:false, d:1, vt:string]]]
+180ms â•‘â•‘Comparison (boolean) false is (boolean) false = true (2ms)
+194ms â•‘â•‘Evaluating switch with values [[i::473ef8ef2e026802057d9bd6a0fb5adf::lock, v:[t:enum, v:unlocked, d::473ef8ef2e026802057d9bd6a0fb5adf:, a:lock, i:[], x:false, vt:string]]]
+197ms â•‘â•‘Comparison (enum) unlocked is (string) locked = false (1ms)
+202ms â•‘â•‘Comparison (enum) unlocked is (string) unknown = false (1ms)
+210ms â•‘â•‘Evaluating switch with values [[i:122:null:0, v:[t:dynamic, v:keypad]]]
+213ms â•‘â•‘Comparison (dynamic) keypad is (string) manual = false (1ms)
+218ms â•‘â•‘Comparison (dynamic) keypad is (string) keypad = true (1ms)
+224ms â•‘â•‘Evaluating switch with values [[i:131:null:0, v:[t:boolean, v:false, d:1, vt:string]]]
+227ms â•‘â•‘Comparison (boolean) false is (boolean) false = true (2ms)
+240ms â•‘â•‘Evaluating switch with values [[i::473ef8ef2e026802057d9bd6a0fb5adf::lock, v:[t:enum, v:unlocked, d::473ef8ef2e026802057d9bd6a0fb5adf:, a:lock, i:[], x:false, vt:string]]]
+243ms â•‘â•‘Comparison (enum) unlocked is (string) locked = false (2ms)
+247ms â•‘â•‘Comparison (enum) unlocked is (string) unknown = false (1ms)
+332ms â•‘â•‘Comparison (enum) inactive is (string) inactive = true (2ms)
+334ms â•‘â•‘Condition #169 evaluated true (9ms)
+335ms â•‘â•‘Condition group #168 evaluated true (state did not change) (10ms)
+337ms ║║Cancelling statement #170’s schedules…
+340ms â•‘â•‘Executed virtual command wait (0ms)
+342ms â•‘â•‘Requesting a wake up for Sun, May 17 2020 @ 4:11:49 PM PDT (in 5.0s)
+346ms â•‘â•šExecution stage complete. (189ms)
+348ms â•‘Setting up scheduled job for Sun, May 17 2020 @ 4:11:49 PM PDT (in 4.995s)
+355ms â•šEvent processed successfully (355ms)
5/17/2020, 4:11:40 PM +104ms
+1ms â•”Received event [Home].time = 1589757101357 with a delay of -1253ms
+143ms â•‘RunTime Analysis CS > 20ms > PS > 55ms > PE > 68ms > CE
+148ms â•‘Runtime (76995 bytes) successfully initialized in 55ms (v0.3.110.20191009) (147ms)
+149ms â•‘â•”Execution stage started
+155ms â•‘â•‘Evaluating switch with values [[i:2:null:0, v:[t:dynamic, v:keypad]]]
+158ms â•‘â•‘Comparison (dynamic) keypad is (string) manual = false (1ms)
+163ms â•‘â•‘Comparison (dynamic) keypad is (string) keypad = true (1ms)
+169ms â•‘â•‘Evaluating switch with values [[i:24:null:0, v:[t:boolean, v:false, d:2, vt:string]]]
+172ms â•‘â•‘Comparison (boolean) false is (boolean) false = true (1ms)
+185ms â•‘â•‘Evaluating switch with values [[i::473ef8ef2e026802057d9bd6a0fb5adf::lock, v:[t:enum, v:unlocked, d::473ef8ef2e026802057d9bd6a0fb5adf:, a:lock, i:[], x:false, vt:string]]]
+188ms â•‘â•‘Comparison (enum) unlocked is (string) locked = false (2ms)
+193ms â•‘â•‘Comparison (enum) unlocked is (string) unknown = false (1ms)
+202ms â•‘â•‘Evaluating switch with values [[i:122:null:0, v:[t:dynamic, v:keypad]]]
+205ms â•‘â•‘Comparison (dynamic) keypad is (string) manual = false (2ms)
+210ms â•‘â•‘Comparison (dynamic) keypad is (string) keypad = true (1ms)
+216ms â•‘â•‘Evaluating switch with values [[i:131:null:0, v:[t:boolean, v:false, d:2, vt:string]]]
+219ms â•‘â•‘Comparison (boolean) false is (boolean) false = true (1ms)
+231ms â•‘â•‘Evaluating switch with values [[i::473ef8ef2e026802057d9bd6a0fb5adf::lock, v:[t:enum, v:unlocked, d::473ef8ef2e026802057d9bd6a0fb5adf:, a:lock, i:[], x:false, vt:string]]]
+234ms â•‘â•‘Comparison (enum) unlocked is (string) locked = false (1ms)
+239ms â•‘â•‘Comparison (enum) unlocked is (string) unknown = false (2ms)
+322ms â•‘â•‘Comparison (enum) inactive is (string) inactive = true (1ms)
+323ms â•‘â•‘Condition #169 evaluated true (8ms)
+324ms â•‘â•‘Condition group #168 evaluated true (state did not change) (10ms)
+326ms ║║Cancelling statement #170’s schedules…
+330ms â•‘â•‘Executed virtual command wait (1ms)
+331ms â•‘â•‘Requesting a wake up for Sun, May 17 2020 @ 4:11:45 PM PDT (in 5.0s)
+336ms â•‘â•šExecution stage complete. (187ms)
+337ms â•‘Setting up scheduled job for Sun, May 17 2020 @ 4:11:45 PM PDT (in 4.995s)
+346ms â•šEvent processed successfully (346ms)
5/17/2020, 4:11:26 PM +78ms
+1ms â•”Received event [Back Door].lock = unlocked with a delay of 126ms
+9984ms â•‘RunTime Analysis CS > 94ms > PS > 9822ms > PE > 69ms > CE
+9985ms â•‘Piston waited at a semaphore for 9770ms
+9989ms â•‘Runtime (77084 bytes) successfully initialized in 9822ms (v0.3.110.20191009) (9987ms)
+9990ms â•‘â•”Execution stage started
+9996ms â•‘â•‘Evaluating switch with values [[i:2:null:0, v:[t:dynamic, v:keypad]]]
+9999ms â•‘â•‘Comparison (dynamic) keypad is (string) manual = false (1ms)
+10002ms â•‘â•‘Comparison (dynamic) keypad is (string) keypad = true (1ms)
+10004ms ║║Cancelling statement #9’s schedules…
+10010ms â•‘â•‘Executed virtual command setVariable (3ms)
+10015ms â•‘â•‘Evaluating switch with values [[i:24:null:0, v:[t:boolean, v:false, d:2, vt:string]]]
+10019ms â•‘â•‘Comparison (boolean) false is (boolean) false = true (2ms)
+10021ms ║║Cancelling statement #29’s schedules…
+10026ms â•‘â•‘Executed virtual command setVariable (3ms)
+10032ms â•‘â•‘Executed virtual command setVariable (3ms)
+10036ms â•‘â•‘Evaluating switch with values [[i::473ef8ef2e026802057d9bd6a0fb5adf::lock, v:[t:enum, v:unlocked, d::473ef8ef2e026802057d9bd6a0fb5adf:, a:lock, i:[], x:false, vt:string]]]
+10040ms â•‘â•‘Comparison (enum) unlocked is (string) locked = false (2ms)
+10043ms â•‘â•‘Comparison (enum) unlocked is (string) unknown = false (2ms)
+10045ms ║║Cancelling statement #39’s schedules…
+10051ms â•‘â•‘Executed virtual command setVariable (2ms)
+10054ms ║║Cancelling statement #45’s schedules…
+10062ms â•‘â•‘Executed virtual command setVariable (4ms)
+10069ms â•‘â•‘Comparison (dynamic) 2 rises = false (1ms)
+10070ms â•‘â•‘Condition #70 evaluated false (3ms)
+10071ms â•‘â•‘Condition group #69 evaluated false (state did not change) (4ms)
+10074ms ║║Cancelling statement #56’s schedules…
+10078ms â•‘â•‘Calculating (string) Last event occurred on + (string) Sun, May 17 2020 @ 4:11:36 PM PDT >> (string) Last event occurred on Sun, May 17 2020 @ 4:11:36 PM PDT
+10081ms â•‘â•‘Executed virtual command setState (1ms)
+10086ms â•‘â•‘Comparison (dynamic) Keypad changes_to (string) Keypad = true (0ms)
+10087ms ║║Cancelling condition #119’s schedules…
+10088ms â•‘â•‘Condition #119 evaluated true (5ms)
+10092ms â•‘â•‘Comparison (dynamic) Unlocked is (string) Unlocked = true (1ms)
+10093ms â•‘â•‘Condition #156 evaluated true (4ms)
+10094ms ║║Cancelling condition #155’s schedules…
+10095ms â•‘â•‘Condition group #155 evaluated true (state changed) (12ms)
+10106ms ║║Comparison (time) 58296175 is_between (time) 79200000 … (time) 18000000 = false (7ms)
+10108ms â•‘â•‘Condition #159 evaluated false (11ms)
+10109ms â•‘â•‘Condition group #157 evaluated false (state did not change) (13ms)
+10120ms ║║Comparison (time) 58296188 is_between (time) 75600000 … (time) 79200000 = false (7ms)
+10121ms â•‘â•‘Condition #174 evaluated false (11ms)
+10122ms â•‘â•‘Condition group #158 evaluated false (state did not change) (12ms)
+10125ms ║║Cancelling statement #160’s schedules…
+10162ms â•‘â•‘Executed virtual command setAlarmSystemStatus (34ms)
+10199ms â•‘â•‘Executed virtual command setLocationMode (35ms)
+10209ms â•‘â•‘Calculating (string) Smart Home Monitor SHM is + (string) Disarmed >> (string) Smart Home Monitor SHM is Disarmed
+10211ms â•‘â•‘Calculating (string) Smart Home Monitor SHM is Disarmed + (string) . Mode is Home. >> (string) Smart Home Monitor SHM is Disarmed. Mode is Home.
+10237ms â•‘â•‘Executed virtual command sendPushNotification (22ms)
+10240ms ║║Cancelling statement #164’s schedules…
+10245ms â•‘â•‘Skipped execution of physical command [Back Door].unlock([]) because it would make no change to the device. (1ms)
+10246ms â•‘â•‘Executed [Back Door].unlock (3ms)
+10249ms ║║Cancelling statement #166’s schedules…
+10256ms â•‘â•‘Skipped execution of physical command [Kitchen Main Lights].on([]) because it would make no change to the device. (2ms)
+10256ms â•‘â•‘Executed [Kitchen Main Lights].on (4ms)
+10267ms â•‘â•‘Comparison (enum) inactive is (string) inactive = true (2ms)
+10268ms ║║Cancelling condition #169’s schedules…
+10269ms â•‘â•‘Condition #169 evaluated true (10ms)
+10270ms ║║Cancelling condition #168’s schedules…
+10271ms â•‘â•‘Condition group #168 evaluated true (state changed) (12ms)
+10274ms ║║Cancelling statement #170’s schedules…
+10277ms â•‘â•‘Executed virtual command wait (0ms)
+10279ms â•‘â•‘Requesting a wake up for Sun, May 17 2020 @ 4:11:41 PM PDT (in 5.0s)
+10283ms â•‘â•šExecution stage complete. (293ms)
+10290ms â•‘Setting up scheduled job for Sun, May 17 2020 @ 4:11:41 PM PDT (in 4.99s)
+10298ms â•šEvent processed successfully (10299ms)
5/17/2020, 4:11:25 PM +835ms
+2ms â•”Received event [Back Door].lock = unlocked with a delay of 106ms
+134ms â•‘RunTime Analysis CS > 19ms > PS > 51ms > PE > 64ms > CE
+138ms â•‘Runtime (76996 bytes) successfully initialized in 51ms (v0.3.110.20191009) (136ms)
+139ms â•‘â•”Execution stage started
+145ms â•‘â•‘Evaluating switch with values [[i:2:null:0, v:[t:dynamic, v:null]]]
+147ms â•‘â•‘Comparison (dynamic) null is (string) manual = false (1ms)
+151ms â•‘â•‘Comparison (dynamic) null is (string) keypad = false (1ms)
+153ms ║║Cancelling statement #5’s schedules…
+158ms â•‘â•‘Executed virtual command setVariable (3ms)
+163ms â•‘â•‘Executed virtual command setVariable (3ms)
+167ms â•‘â•‘Executed virtual command setVariable (2ms)
+171ms â•‘â•‘Evaluating switch with values [[i::473ef8ef2e026802057d9bd6a0fb5adf::lock, v:[t:enum, v:unlocked, d::473ef8ef2e026802057d9bd6a0fb5adf:, a:lock, i:[], x:false, vt:string]]]
+174ms â•‘â•‘Comparison (enum) unlocked is (string) locked = false (1ms)
+177ms â•‘â•‘Comparison (enum) unlocked is (string) unknown = false (1ms)
+179ms ║║Cancelling statement #39’s schedules…
+184ms â•‘â•‘Executed virtual command setVariable (3ms)
+187ms ║║Cancelling statement #45’s schedules…
+194ms â•‘â•‘Executed virtual command setVariable (3ms)
+200ms â•‘â•‘Comparison (dynamic) 2 rises = false (1ms)
+201ms â•‘â•‘Condition #70 evaluated false (3ms)
+202ms â•‘â•‘Condition group #69 evaluated false (state did not change) (4ms)
+204ms ║║Cancelling statement #56’s schedules…
+209ms â•‘â•‘Calculating (string) Last event occurred on + (string) Sun, May 17 2020 @ 4:11:26 PM PDT >> (string) Last event occurred on Sun, May 17 2020 @ 4:11:26 PM PDT
+211ms â•‘â•‘Executed virtual command setState (0ms)
+216ms â•‘â•‘Comparison (dynamic) Programically changes_to (string) Keypad = false (0ms)
+218ms â•‘â•‘Condition #119 evaluated false (3ms)
+219ms â•‘â•‘Condition group #155 evaluated false (state did not change) (4ms)
+223ms â•‘â•‘Comparison (dynamic) null changes_to (string) Keypad = false (1ms)
+224ms â•‘â•‘Condition #198 evaluated false (3ms)
+225ms â•‘â•‘Condition group #197 evaluated false (state did not change) (5ms)
+227ms â•‘â•šExecution stage complete. (88ms)
+228ms â•šEvent processed successfully (228ms)


#2

Just did a cursory look and there is a quite a bit to look through. But maybe look at the Task Cancellation Policy (TCP) of some of your code. Each time a trigger fires the Piston starts back at the beginning.
The condition you describe of the piston firing again is specifically what the TCP can help mitigate.

Maybe you already thought of this, here is a link to a wiki article.


#3

Thanks, I did think about that after posting, and I’ve changed it. I will have to test it tomorrow.


#4

Something else that may be problematic, is using a global variable as a trigger. Maybe it will work, but as I understand it globals don’t get updated in the piston until it fires? So I am not sure it will ever fire.

So I am curious if that works or not.


#5

Yes, the Occupancy variable works fine. The event is definitely triggering when that changes.


#6

Come to find out the problem with this is actually with Echo Speaks not using the speak variable. The solution was provided in this other post.

Regarding the pause, I was able to find some other details about waiting functions, and instead used the Followed By condition group to set it up to play the message when the motion detector “followed within 10 minutes” with activation.