While loop not repeating when using Smart Home Monitor Status


#1

1) Give a description of the problem
While loop not working as expected when using Smart Home Monitor Status as the condition.

2) What is the expected behavior?
The While loop has an announcement that plays through Echo devices that I want to repeat every few seconds as long as the Smart Home Monitor status is still Armed/Stay.

3) What is happening/not happening?
In the current configuration snapshot shown. The announcement plays once but never repeats. But if I use a physical switch for the condition of the While statement, it works as expected. I can see that the $shmStatus variable is still Armed/Stay and the ST Classic app also shows that it is still in Armed/Stay mode. I have also tried using the state of $shmTripped for the While condition and it didn’t work either. I read in some other threads that the While statement might not be the best to use, but it works when a physical switch state is used for the condition, which I find confusing.

4) Post a Green Snapshot of the pistonimage

5) Attach any logs (From ST IDE and by turning logging level to Full)
1/25/2019, 11:29:02 AM +63ms
+1ms ╔Received event [Home].time = 1548437343303 with a delay of -1240ms
+183ms ║RunTime Analysis CS > 20ms > PS > 143ms > PE > 20ms > CE
+186ms ║Runtime (40783 bytes) successfully initialized in 143ms (v0.3.109.20181207) (184ms)
+187ms ║╔Execution stage started
+189ms ║╚Execution stage complete. (1ms)
+191ms ╚Event processed successfully (190ms)
1/25/2019, 11:28:33 AM +727ms
+1ms ╔Received event [Kitchen Slider].contact = closed with a delay of 86ms
+108ms ║RunTime Analysis CS > 12ms > PS > 80ms > PE > 16ms > CE
+111ms ║Runtime (40777 bytes) successfully initialized in 80ms (v0.3.109.20181207) (109ms)
+112ms ║╔Execution stage started
+141ms ║║Comparison (enum) closed changes_to (string) open = false (1ms)
+144ms ║║Cancelling condition #20’s schedules…
+145ms ║║Condition #20 evaluated false (27ms)
+146ms ║║Cancelling condition #19’s schedules…
+148ms ║║Condition group #19 evaluated false (state changed) (29ms)
+151ms ║╚Execution stage complete. (39ms)
+152ms ╚Event processed successfully (152ms)
1/25/2019, 11:28:31 AM +316ms
+1ms ╔Received event [Kitchen Slider].contact = open with a delay of 91ms
+151ms ║RunTime Analysis CS > 15ms > PS > 101ms > PE > 35ms > CE
+154ms ║Runtime (40781 bytes) successfully initialized in 101ms (v0.3.109.20181207) (151ms)
+155ms ║╔Execution stage started
+186ms ║║Comparison (enum) open changes_to (string) open = true (1ms)
+190ms ║║Cancelling condition #20’s schedules…
+191ms ║║Condition #20 evaluated true (29ms)
+200ms ║║Comparison (string) stay is (string) stay = true (2ms)
+202ms ║║Condition #28 evaluated true (9ms)
+203ms ║║Cancelling condition #19’s schedules…
+204ms ║║Condition group #19 evaluated true (state changed) (43ms)
+207ms ║║Cancelling statement #22’s schedules…
+218ms ║║Calculating (string) Intrusion Alert. + (string) Kitchen Slider >> (string) Intrusion Alert. Kitchen Slider
+222ms ║║Calculating (string) Intrusion Alert. Kitchen Slider , (string) has opened. >> (string) Intrusion Alert. Kitchen Slider has opened.
+227ms ║║Executed virtual command setVariable (2ms)
+239ms ║║Comparison (string) stay is (string) stay = true (2ms)
+241ms ║║Condition #25 evaluated true (9ms)
+242ms ║║Condition group #24 evaluated true (state did not change) (11ms)
+245ms ║║Cancelling statement #18’s schedules…
+1974ms ║║Executed physical command [Echo - Bruce’s Echo Dot].playAnnouncementAll([Intrusion Alert. Kitchen Slider has opened.]) (1722ms)
+1975ms ║║Executed [Echo - Bruce’s Echo Dot].playAnnouncementAll (1724ms)
+1979ms ║║Cancelling statement #26’s schedules…
+1984ms ║║Executed virtual command wait (1ms)
+1986ms ║║Requesting a wake up for Fri, Jan 25 2019 @ 11:29:03 AM CST (in 30.0s)
+1993ms ║╚Execution stage complete. (1837ms)
+1995ms ║Setting up scheduled job for Fri, Jan 25 2019 @ 11:29:03 AM CST (in 29.993s)
+2004ms ╚Event processed successfully (2004ms)


#2

You need to group with your ‘changes to open’ an ‘or is open’. the second time through, this if will fail because the sensor will no longer be in the changed to open state. If you want it to keep going even if the door is closed, you will need to add a Boolean variable you set to true and then false as soon as shm is turned off.


#3

I modified the piston to include a Boolean as you suggested. But it only plays the message once. When the piston is triggered the second time after the 30s wait, nothing happens. The trace doesn’t show that anything was evaluated at all.


1/25/2019, 6:10:07 PM +164ms
+1ms ╔Received event [Home].time = 1548461408047 with a delay of -884ms
+486ms ║RunTime Analysis CS > 204ms > PS > 262ms > PE > 20ms > CE
+489ms ║Runtime (43291 bytes) successfully initialized in 262ms (v0.3.109.20181207) (486ms)
+490ms ║╔Execution stage started
+519ms ║╚Execution stage complete. (29ms)
+521ms ╚Event processed successfully (521ms)
1/25/2019, 6:09:35 PM +915ms
+2ms ╔Received event [Mailbox].contact = open with a delay of 112ms
+199ms ║RunTime Analysis CS > 22ms > PS > 135ms > PE > 43ms > CE
+202ms ║Runtime (43301 bytes) successfully initialized in 135ms (v0.3.109.20181207) (198ms)
+203ms ║╔Execution stage started
+281ms ║║Comparison (enum) open changes_to (string) open = true (1ms)
+284ms ║║Cancelling condition #38’s schedules…
+286ms ║║Condition #38 evaluated true (73ms)
+294ms ║║Comparison (string) stay is (string) stay = true (2ms)
+297ms ║║Condition #39 evaluated true (9ms)
+298ms ║║Cancelling condition #37’s schedules…
+300ms ║║Condition group #37 evaluated true (state changed) (88ms)
+301ms ║║Cancelling condition #36’s schedules…
+302ms ║║Condition group #36 evaluated true (state changed) (92ms)
+304ms ║║Cancelling condition #19’s schedules…
+305ms ║║Condition group #19 evaluated true (state changed) (96ms)
+316ms ║║Comparison (boolean) false is (boolean) false = true (2ms)
+318ms ║║Condition #34 evaluated true (10ms)
+320ms ║║Condition group #33 evaluated true (state did not change) (11ms)
+323ms ║║Cancelling statement #22’s schedules…
+336ms ║║Executed virtual command setVariable (3ms)
+342ms ║║Executed virtual command setVariable (1ms)
+354ms ║║Comparison (string) stay is (string) stay = true (2ms)
+356ms ║║Condition #43 evaluated true (10ms)
+357ms ║║Condition group #42 evaluated true (state did not change) (12ms)
+360ms ║║Cancelling statement #18’s schedules…
+2119ms ║║Executed physical command [Echo - Bruce’s Echo Dot].playAnnouncementAll([Intrusion Alert. Mailbox has opened.]) (1751ms)
+2121ms ║║Executed [Echo - Bruce’s Echo Dot].playAnnouncementAll (1753ms)
+2125ms ║║Cancelling statement #26’s schedules…
+2129ms ║║Executed virtual command wait (1ms)
+2131ms ║║Requesting a wake up for Fri, Jan 25 2019 @ 6:10:08 PM CST (in 30.0s)
+2138ms ║╚Execution stage complete. (1935ms)
+2140ms ║Setting up scheduled job for Fri, Jan 25 2019 @ 6:10:08 PM CST (in 29.993s)
+2149ms ╚Event processed successfully (2149ms)


#4

Just a few observations about piston HJQS4:

  • Line 19 will force the variable to be false each time the piston runs.

  • Also, line 42 is pointless because for the code to reach that line, SHM must be Armed/Stay.

  • This also means line 51 will never execute.


#5

Thanks for your help (again) @WCmore
The piston seems to be doing what I want it to do now.