Intrusion Piston Help


#1

1) Give a description of the problem
(PUT YOUR INFO HERE)
This piston triggers and outputs the announcement to the Echos; however, the loop controls don’t work. I don’t see in the trace where the loop counter is being decremented, nor is the loop flag being set TRUE.

Please note that several of the conditions set are just for testing (loop count = 3 => 20, Disarmed =>Armed)

2) What is the expected behavior?
(PUT YOUR INFO HERE)
I expected the loop to expire after a count of 3 OR if changed from Disarmed. Also, the loop would persist even when the contact sensor was closed.

3) What is happening/not happening?
(PUT YOUR INFO HERE)
None of these conditions executed as planned.

4) Post a Green Snapshot of the pistonimage
(UPLOAD YOUR IMAGE HERE)

**5) Attach any logs:

4/12/2019, 7:39:13 AM +83ms
    +1ms	╔Received event [Home].time = 1555069154703 with a delay of -1620ms
    +125ms	║RunTime Analysis CS > 31ms > PS > 59ms > PE > 34ms > CE
    +129ms	║Runtime (43147 bytes) successfully initialized in 59ms (v0.3.10a.20190223) (127ms)
    +131ms	║╔Execution stage started
    +133ms	║╚Execution stage complete. (3ms)
    +136ms	╚Event processed successfully (135ms)
    4/12/2019, 7:39:04 AM +353ms
    +1ms	╔Received event [Desk Chair].contact = closed with a delay of 825ms
    +185ms	║RunTime Analysis CS > 14ms > PS > 145ms > PE > 26ms > CE
    +188ms	║Runtime (43141 bytes) successfully initialized in 145ms (v0.3.10a.20190223) (186ms)
    +190ms	║╔Execution stage started
    +203ms	║║Comparison (boolean) false is (boolean) true = false (2ms)
    +207ms	║║Condition #13 evaluated false (8ms)
    +216ms	║║Comparison (string) off is (string) off = true (2ms)
    +218ms	║║Condition #15 evaluated true (9ms)
    +224ms	║║Comparison (enum) closed changes_to (string) open = false (1ms)
    +226ms	║║Cancelling condition #16's schedules...
    +227ms	║║Condition #16 evaluated false (8ms)
    +229ms	║║Cancelling condition #14's schedules...
    +230ms	║║Condition group #14 evaluated false (state changed) (21ms)
    +231ms	║║Cancelling condition #1's schedules...
    +232ms	║║Condition group #1 evaluated false (state changed) (37ms)
    +242ms	║║Comparison (boolean) false is (boolean) true = false (2ms)
    +244ms	║║Condition #19 evaluated false (8ms)
    +245ms	║║Condition group #18 evaluated false (state did not change) (10ms)
    +249ms	║╚Execution stage complete. (59ms)
    +250ms	╚Event processed successfully (250ms)
    4/12/2019, 7:38:59 AM +87ms
    +1ms	╔Received event [Home].time = 1555069140832 with a delay of -1745ms
    +94ms	║RunTime Analysis CS > 18ms > PS > 51ms > PE > 24ms > CE
    +97ms	║Runtime (43138 bytes) successfully initialized in 51ms (v0.3.10a.20190223) (95ms)
    +98ms	║╔Execution stage started
    +127ms	║║Comparison (integer) 3 is_equal_to (integer) 0 = false (2ms)
    +129ms	║║Condition #5 evaluated false (10ms)
    +136ms	║║Comparison (string) off changes_away_from (string) off = false (1ms)
    +138ms	║║Condition #6 evaluated false (8ms)
    +139ms	║║Condition group #4 evaluated false (state did not change) (21ms)
    +143ms	║║Cancelling statement #7's schedules...
    +152ms	║║Executed virtual command [Echo - Living Room Echo, Echo - Master Bath Echo, Echo - Master Bedroom Echo, Echo - Small Bedroom Echo Dot].setVariable (1ms)
    +162ms	║║Calculating (integer) 3 - (integer) 1 >> (integer) 2
    +167ms	║║Executed virtual command [Echo - Living Room Echo, Echo - Master Bath Echo, Echo - Master Bedroom Echo, Echo - Small Bedroom Echo Dot].setVariable (2ms)
    +305ms	║║Executed physical command [Echo - Living Room Echo].setVolumeSpeakAndRestore([30, Video Cameras Are on and Police have been notified]) (129ms)
    +307ms	║║Executed [Echo - Living Room Echo].setVolumeSpeakAndRestore (131ms)
    +408ms	║║Executed physical command [Echo - Master Bath Echo].setVolumeSpeakAndRestore([30, Video Cameras Are on and Police have been notified]) (97ms)
    +410ms	║║Executed [Echo - Master Bath Echo].setVolumeSpeakAndRestore (99ms)
    +507ms	║║Executed physical command [Echo - Master Bedroom Echo].setVolumeSpeakAndRestore([30, Video Cameras Are on and Police have been notified]) (93ms)
    +509ms	║║Executed [Echo - Master Bedroom Echo].setVolumeSpeakAndRestore (95ms)
    +606ms	║║Executed physical command [Echo - Small Bedroom Echo Dot].setVolumeSpeakAndRestore([30, Video Cameras Are on and Police have been notified]) (93ms)
    +607ms	║║Executed [Echo - Small Bedroom Echo Dot].setVolumeSpeakAndRestore (95ms)
    +614ms	║║Executed virtual command [Echo - Living Room Echo, Echo - Master Bath Echo, Echo - Master Bedroom Echo, Echo - Small Bedroom Echo Dot].wait (1ms)
    +615ms	║║Requesting a wake up for Fri, Apr 12 2019 @ 7:39:14 AM EDT (in 15.0s)
    +621ms	║╚Execution stage complete. (524ms)
    +623ms	║Setting up scheduled job for Fri, Apr 12 2019 @ 7:39:14 AM EDT (in 14.994s)
    +631ms	╚Event processed successfully (631ms)
    4/12/2019, 7:38:45 AM +121ms
    +1ms	╔Received event [Home].time = 1555069126054 with a delay of -933ms
    +116ms	║RunTime Analysis CS > 30ms > PS > 63ms > PE > 23ms > CE
    +119ms	║Runtime (43138 bytes) successfully initialized in 63ms (v0.3.10a.20190223) (117ms)
    +120ms	║╔Execution stage started
    +148ms	║║Comparison (integer) 3 is_equal_to (integer) 0 = false (2ms)
    +150ms	║║Condition #5 evaluated false (10ms)
    +157ms	║║Comparison (string) off changes_away_from (string) off = false (1ms)
    +159ms	║║Condition #6 evaluated false (7ms)
    +160ms	║║Condition group #4 evaluated false (state did not change) (21ms)
    +163ms	║║Cancelling statement #7's schedules...
    +174ms	║║Executed virtual command [Echo - Living Room Echo, Echo - Master Bath Echo, Echo - Master Bedroom Echo, Echo - Small Bedroom Echo Dot].setVariable (1ms)
    +185ms	║║Calculating (integer) 3 - (integer) 1 >> (integer) 2
    +189ms	║║Executed virtual command [Echo - Living Room Echo, Echo - Master Bath Echo, Echo - Master Bedroom Echo, Echo - Small Bedroom Echo Dot].setVariable (2ms)
    +374ms	║║Executed physical command [Echo - Living Room Echo].setVolumeSpeakAndRestore([30, Video Cameras Are on and Police have been notified]) (174ms)
    +375ms	║║Executed [Echo - Living Room Echo].setVolumeSpeakAndRestore (177ms)
    +489ms	║║Executed physical command [Echo - Master Bath Echo].setVolumeSpeakAndRestore([30, Video Cameras Are on and Police have been notified]) (110ms)
    +491ms	║║Executed [Echo - Master Bath Echo].setVolumeSpeakAndRestore (113ms)
    +601ms	║║Executed physical command [Echo - Master Bedroom Echo].setVolumeSpeakAndRestore([30, Video Cameras Are on and Police have been notified]) (103ms)
    +603ms	║║Executed [Echo - Master Bedroom Echo].setVolumeSpeakAndRestore (107ms)
    +701ms	║║Executed physical command [Echo - Small Bedroom Echo Dot].setVolumeSpeakAndRestore([30, Video Cameras Are on and Police have been notified]) (92ms)
    +702ms	║║Executed [Echo - Small Bedroom Echo Dot].setVolumeSpeakAndRestore (95ms)
    +709ms	║║Executed virtual command [Echo - Living Room Echo, Echo - Master Bath Echo, Echo - Master Bedroom Echo, Echo - Small Bedroom Echo Dot].wait (0ms)
    +710ms	║║Requesting a wake up for Fri, Apr 12 2019 @ 7:39:00 AM EDT (in 15.0s)
    +717ms	║╚Execution stage complete. (597ms)
    +719ms	║Setting up scheduled job for Fri, Apr 12 2019 @ 7:39:00 AM EDT (in 14.993s)
    +728ms	╚Event processed successfully (727ms)
    4/12/2019, 7:38:30 AM +342ms
    +1ms	╔Received event [Desk Chair].contact = open with a delay of 810ms
    +89ms	║RunTime Analysis CS > 16ms > PS > 37ms > PE > 36ms > CE
    +91ms	║Runtime (43144 bytes) successfully initialized in 37ms (v0.3.10a.20190223) (89ms)
    +93ms	║╔Execution stage started
    +106ms	║║Comparison (boolean) false is (boolean) true = false (2ms)
    +108ms	║║Condition #13 evaluated false (9ms)
    +117ms	║║Comparison (string) off is (string) off = true (2ms)
    +119ms	║║Condition #15 evaluated true (9ms)
    +125ms	║║Comparison (enum) open changes_to (string) open = true (1ms)
    +127ms	║║Cancelling condition #16's schedules...
    +128ms	║║Condition #16 evaluated true (8ms)
    +130ms	║║Cancelling condition #14's schedules...
    +131ms	║║Condition group #14 evaluated true (state changed) (21ms)
    +132ms	║║Cancelling condition #1's schedules...
    +133ms	║║Condition group #1 evaluated true (state changed) (35ms)
    +138ms	║║Cancelling statement #7's schedules...
    +147ms	║║Executed virtual command [Echo - Living Room Echo, Echo - Master Bath Echo, Echo - Master Bedroom Echo, Echo - Small Bedroom Echo Dot].setVariable (1ms)
    +158ms	║║Calculating (integer) 3 - (integer) 1 >> (integer) 2
    +162ms	║║Executed virtual command [Echo - Living Room Echo, Echo - Master Bath Echo, Echo - Master Bedroom Echo, Echo - Small Bedroom Echo Dot].setVariable (1ms)
    +417ms	║║Executed physical command [Echo - Living Room Echo].setVolumeSpeakAndRestore([30, Video Cameras Are on and Police have been notified]) (244ms)
    +418ms	║║Executed [Echo - Living Room Echo].setVolumeSpeakAndRestore (248ms)
    +519ms	║║Executed physical command [Echo - Master Bath Echo].setVolumeSpeakAndRestore([30, Video Cameras Are on and Police have been notified]) (96ms)
    +521ms	║║Executed [Echo - Master Bath Echo].setVolumeSpeakAndRestore (98ms)
    +614ms	║║Executed physical command [Echo - Master Bedroom Echo].setVolumeSpeakAndRestore([30, Video Cameras Are on and Police have been notified]) (87ms)
    +615ms	║║Executed [Echo - Master Bedroom Echo].setVolumeSpeakAndRestore (91ms)
    +702ms	║║Executed physical command [Echo - Small Bedroom Echo Dot].setVolumeSpeakAndRestore([30, Video Cameras Are on and Police have been notified]) (82ms)
    +703ms	║║Executed [Echo - Small Bedroom Echo Dot].setVolumeSpeakAndRestore (84ms)
    +709ms	║║Executed virtual command [Echo - Living Room Echo, Echo - Master Bath Echo, Echo - Master Bedroom Echo, Echo - Small Bedroom Echo Dot].wait (1ms)
    +711ms	║║Requesting a wake up for Fri, Apr 12 2019 @ 7:38:46 AM EDT (in 15.0s)
    +718ms	║╚Execution stage complete. (625ms)
    +719ms	║Setting up scheduled job for Fri, Apr 12 2019 @ 7:38:46 AM EDT (in 14.993s)
    +729ms	╚Event processed successfully (728ms)

#2

You have hard coded the variables up top, so each time the piston fires, both Loop_Count and Loop_Counter return to ‘3’. Also, your Repeat_Message_Flag will always start off as false, so line 27 will never be true.

In general, I leave all my variables up top as (not set) so the piston has full control over when they change. The only time I force data into a variable up top is if it rarely changes.


You might also want to change line 54 to a condition instead of a trigger.
IE: IF SHM status IS NOT Disarmed


#3

Thank you for your reply.

Having the Loop_counter return to 3 and the Repeat_Message_Flag at piston invocation is as a planned.

It was my hope that the piston should then decrement the Loop_Counter and set the Repeat_Message_Flag TRUE while it executed the DO UNTIL Loop

Does this make sense?


#4

With your Waits, I think the piston is resetting the numbers back to 3 on each loop.

7:38:30 AM = Calculating (integer) 3 - (integer) 1 >> (integer) 2
7:38:45 AM = Calculating (integer) 3 - (integer) 1 >> (integer) 2
7:38:59 AM = Calculating (integer) 3 - (integer) 1 >> (integer) 2

In the “define” section, I highly recommend turning any changing variables to (not set). Once that is done, then you can be more strategic in your programming to make any variable anything, at anytime.


As far as resetting your variables to your default:

  • It can be done at the very end (after the loop completes)
  • or towards the beginning (after the trigger, yet before the loop)

I usually choose at the end… Kind of my “clean-up” block to prepare for the next execution.
(this method also guarantees that mini loops will not reset it until after it runs to completion)


#5

Thank you for your advice I will implement the suggestions. Not sure that I can do it until Monday. I’ll be back.

Again thanks.

Ray


#6

I’m away so I can’t yet make changes or test. However with your help I looked more closely at the trace and find some unexpected operation. For example when it runs there is a 30 sec wait between each audio output yet no waits are shown in the trance between each. Also the counter is only decremented once as is the the flag only set once

This is in the beginning of a group

Master Bedroom Echo, Echo - Small Bedroom Echo Dot].setVariable (1ms)

+162ms ║║Calculating (integer) 3 - (integer) 1 >> (integer) 2

+167ms ║║Executed virtual command [Echo - Living Room Echo, Echo - Master Bath Echo, Echo - Master Bedroom Echo, Echo - Small Bedroom Echo Dot].setVariable (2ms)

This is where the wait seems execute as you say and reset the variables.

614ms ║║Executed virtual command [Echo - Living Room Echo, Echo - Master Bath Echo, Echo - Master Bedroom Echo, Echo - Small Bedroom Echo Dot].wait (1ms)

+615ms ║║Requesting a wake up for Fri, Apr 12 2019 @ 7:39:14 AM EDT (in 15.0s)

+621ms ║╚Execution stage complete. (524ms)

+623ms ║Setting up scheduled job for Fri, Apr 12 2019 @ 7:39:14 AM EDT (in 14.994s)

+631ms ╚Event processed successfully (631ms)

I look forward to fixing it with your help but surely this is unexpected behavior

Thanks again


#7

I found that your assumption of the Wait loop causing the Loop_Counter variable to be reset back to its initial defined values of 3 is what is happening. That’s the good news.

The bad news is that even when I remove the hard define initialization of the Loop_Counter and initialize it before (but outside of the loop) the repeat loop fails, just differently. Before it would be reset back to 3 and the repeat loop would not end. Now, after the Wait interval, the Loop_Counter becomes initialized to 0 (default value) and the repeat loop ends after one cycle.

I preformed another test to be sure that the Wait instruction is the problem and not the code structure. When the Wait time is changed from 15 sec to 15 milliseconds it works as coded. The short Wait never has a need for rescheduling and the execution works as planned.

Isn’t this a failure of the Wait instruction? Is there a way to report this as needing to be fixed?

I will provide green copies and trace logs to document any or all of what I have noted above, however, I thought that I would run it by you for your thoughts first.

Thanks for your help.


#8

I must apologize for my error(s). I have been trying several things to get this working. Some where in my efforts I must have corrected a bug. The end result is that it is working and restructured as you suggested. Thanks again for your efforts.