Piston Firing with restriction in place


#1

1) Give a description of the problem
I need assistance to review my script as it appears the restriction put in place is not working and is actually causing the piston to fire.

2) What is the expected behaviour?
restriction based on 24hr time. if time is outside of the range the piston should not fire.

3) What is happening/not happening?
see piston fire and restriction not working as designed.

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

5) Attach logs after turning logging level to Full
(PASTE YOUR LOGS HERE THEN HIGHLIGHT ALL OF THE LOGS AND CLICK ON THE </> ICON TO FORMAT THEM CORRECTLY)
3/4/2020, 1:40:47 PM +15ms
+1ms ╔Starting piston… (v0.3.110.20191009)
+232ms ║╔Subscribing to devices…
+263ms ║║Subscribing to Mom.presence…
+273ms ║║Subscribing to Papa.presence…
+305ms ║╚Finished subscribing (80ms)
+331ms ║Comparison (enum) not present is (string) present = false (2ms)
+334ms ║Comparison (enum) present is (string) present = true (1ms)
+350ms ║Comparison (integer) 13 is_outside_of_range (integer) 6 … (integer) 17 = false (2ms)
+351ms ║Cancelling condition #9’s schedules…
+353ms ║Cancelling condition #7’s schedules…
+361ms ║Comparison (integer) 13 is_outside_of_range (integer) 18 … (integer) 22 = true (2ms)
+363ms ║Cancelling condition #6’s schedules…
+364ms ║Cancelling condition #4’s schedules…
+373ms ║Comparison (integer) 13 is_outside_of_range (integer) 23 … (integer) 24 = true (1ms)
+375ms ║Cancelling condition #12’s schedules…
+381ms ║Comparison (integer) 13 is_outside_of_range (integer) 1 … (integer) 5 = true (2ms)
+383ms ║Cancelling condition #14’s schedules…
+385ms ║Cancelling condition #10’s schedules…
+393ms ╚Piston successfully started (393ms)
3/4/2020, 1:34:37 PM +889ms
+1ms ╔Received event [Home].test = 1583346877889 with a delay of 0ms
+164ms ║RunTime Analysis CS > 20ms > PS > 110ms > PE > 34ms > CE
+167ms ║Runtime (41044 bytes) successfully initialized in 110ms (v0.3.110.20191009) (166ms)
+168ms ║╔Execution stage started
+182ms ║║Comparison (enum) not present is (string) present = false (1ms)
+185ms ║║Comparison (enum) present is (string) present = true (1ms)
+186ms ║║Condition #2 evaluated true (13ms)
+187ms ║║Condition group #1 evaluated true (state did not change) (15ms)
+195ms ║║Comparison (integer) 13 is_inside_of_range (integer) 6 … (integer) 17 = true (2ms)
+197ms ║║Condition #9 evaluated true (7ms)
+198ms ║║Condition group #7 evaluated true (state did not change) (9ms)
+199ms ║║Cancelling statement #7’s schedules…
+203ms ║║Skipping task 8 because of mode restrictions
+210ms ║║Comparison (integer) 13 is_inside_of_range (integer) 18 … (integer) 22 = false (2ms)
+212ms ║║Condition #6 evaluated false (7ms)
+213ms ║║Condition group #4 evaluated false (state did not change) (8ms)
+221ms ║║Comparison (integer) 13 is_inside_of_range (integer) 23 … (integer) 24 = false (1ms)
+222ms ║║Condition #12 evaluated false (6ms)
+228ms ║║Comparison (integer) 13 is_inside_of_range (integer) 1 … (integer) 5 = false (2ms)
+230ms ║║Condition #14 evaluated false (7ms)
+231ms ║║Condition group #10 evaluated false (state did not change) (16ms)
+235ms ║╚Execution stage complete. (67ms)
+236ms ╚Event processed successfully (236ms)
3/4/2020, 1:34:33 PM +805ms
+1ms ╔Starting piston… (v0.3.110.20191009)
+312ms ║╔Subscribing to devices…
+358ms ║║Subscribing to Mom.presence…
+377ms ║║Subscribing to Papa.presence…
+462ms ║╚Finished subscribing (166ms)
+497ms ║Comparison (enum) not present is (string) present = false (2ms)
+500ms ║Comparison (enum) present is (string) present = true (1ms)
+516ms ║Comparison (integer) 13 is_inside_of_range (integer) 6 … (integer) 17 = true (2ms)
+518ms ║Cancelling condition #9’s schedules…
+520ms ║Cancelling condition #7’s schedules…
+531ms ║Comparison (integer) 13 is_inside_of_range (integer) 18 … (integer) 22 = false (2ms)
+532ms ║Cancelling condition #6’s schedules…
+534ms ║Cancelling condition #4’s schedules…
+542ms ║Comparison (integer) 13 is_inside_of_range (integer) 23 … (integer) 24 = false (2ms)
+544ms ║Cancelling condition #12’s schedules…
+551ms ║Comparison (integer) 13 is_inside_of_range (integer) 1 … (integer) 5 = false (2ms)
+552ms ║Cancelling condition #14’s schedules…
+554ms ║Cancelling condition #10’s schedules…
+564ms ╚Piston successfully started (563ms)
3/4/2020, 1:29:28 PM +23ms
+2ms ╔Received event [Papa].presence = present with a delay of 65ms
+327ms ║RunTime Analysis CS > 138ms > PS > 157ms > PE > 32ms > CE
+330ms ║Runtime (41054 bytes) successfully initialized in 157ms (v0.3.110.20191009) (220ms)
+331ms ║╔Execution stage started
+343ms ║║Comparison (enum) not present is (string) present = false (1ms)
+345ms ║║Comparison (enum) present is (string) present = true (1ms)
+347ms ║║Cancelling condition #2’s schedules…
+348ms ║║Condition #2 evaluated true (13ms)
+349ms ║║Cancelling condition #1’s schedules…
+350ms ║║Condition group #1 evaluated true (state changed) (16ms)
+357ms ║║Comparison (integer) 13 is_outside_of_range (integer) 6 … (integer) 17 = false (2ms)
+359ms ║║Cancelling condition #9’s schedules…
+359ms ║║Condition #9 evaluated false (7ms)
+361ms ║║Cancelling condition #7’s schedules…
+361ms ║║Condition group #7 evaluated false (state changed) (9ms)
+368ms ║║Comparison (integer) 13 is_outside_of_range (integer) 18 … (integer) 22 = true (2ms)
+370ms ║║Cancelling condition #6’s schedules…
+371ms ║║Condition #6 evaluated true (7ms)
+372ms ║║Cancelling condition #4’s schedules…
+373ms ║║Condition group #4 evaluated true (state changed) (9ms)
+374ms ║║Cancelling statement #4’s schedules…
+434ms ║║Executed virtual command setLocationMode (57ms)
+441ms ║║Comparison (integer) 13 is_outside_of_range (integer) 23 … (integer) 24 = true (2ms)
+443ms ║║Condition #12 evaluated true (6ms)
+448ms ║║Comparison (integer) 13 is_outside_of_range (integer) 1 … (integer) 5 = true (2ms)
+450ms ║║Condition #14 evaluated true (6ms)
+451ms ║║Condition group #10 evaluated true (state did not change) (14ms)
+452ms ║║Cancelling statement #10’s schedules…
+507ms ║║Executed virtual command setLocationMode (53ms)
+510ms ║╚Execution stage complete. (179ms)
+511ms ╚Event processed successfully (511ms)
3/4/2020, 12:31:56 PM +324ms
+1ms ╔Received event [Papa].presence = not present with a delay of 53ms
+147ms ║RunTime Analysis CS > 20ms > PS > 104ms > PE > 23ms > CE
+149ms ║Runtime (41048 bytes) successfully initialized in 104ms (v0.3.110.20191009) (147ms)
+150ms ║╔Execution stage started
+162ms ║║Comparison (enum) not present is (string) present = false (2ms)
+164ms ║║Comparison (enum) not present is (string) present = false (1ms)
+166ms ║║Cancelling condition #2’s schedules…
+167ms ║║Condition #2 evaluated false (13ms)
+173ms ║║Comparison (enum) not present changes_to (string) present = false (1ms)
+174ms ║║Condition #3 evaluated false (6ms)
+175ms ║║Cancelling condition #1’s schedules…
+176ms ║║Condition group #1 evaluated false (state changed) (22ms)
+178ms ║╚Execution stage complete. (28ms)
+179ms ╚Event processed successfully (179ms)
3/3/2020, 7:42:56 PM +232ms
+1ms ╔Received event [Papa].presence = present with a delay of 53ms
+108ms ║RunTime Analysis CS > 16ms > PS > 74ms > PE > 18ms > CE
+110ms ║Runtime (41051 bytes) successfully initialized in 74ms (v0.3.110.20191009) (108ms)
+111ms ║╔Execution stage started
+121ms ║║Comparison (enum) not present is (string) present = false (1ms)
+123ms ║║Comparison (enum) present is (string) present = true (1ms)
+125ms ║║Cancelling condition #2’s schedules…
+126ms ║║Condition #2 evaluated true (10ms)
+126ms ║║Cancelling condition #1’s schedules…
+127ms ║║Condition group #1 evaluated true (state changed) (12ms)
+133ms ║║Comparison (integer) 19 is_outside_of_range (integer) 6 … (integer) 17 = true (1ms)
+135ms ║║Cancelling condition #9’s schedules…
+136ms ║║Condition #9 evaluated true (6ms)
+137ms ║║Cancelling condition #7’s schedules…
+137ms ║║Condition group #7 evaluated true (state changed) (8ms)
+138ms ║║Cancelling statement #7’s schedules…
+168ms ║║Executed virtual command setLocationMode (28ms)
+175ms ║║Comparison (integer) 19 is_outside_of_range (integer) 18 … (integer) 22 = false (1ms)
+176ms ║║Cancelling condition #6’s schedules…
+177ms ║║Condition #6 evaluated false (7ms)
+178ms ║║Cancelling condition #4’s schedules…
+179ms ║║Condition group #4 evaluated false (state changed) (9ms)
+185ms ║║Comparison (integer) 19 is_outside_of_range (integer) 23 … (integer) 24 = true (2ms)
+187ms ║║Condition #12 evaluated true (5ms)
+191ms ║║Comparison (integer) 19 is_outside_of_range (integer) 1 … (integer) 5 = true (1ms)
+193ms ║║Condition #14 evaluated true (6ms)
+194ms ║║Condition group #10 evaluated true (state did not change) (14ms)
+195ms ║║Cancelling statement #10’s schedules…
+221ms ║║Executed virtual command setLocationMode (24ms)
+223ms ║╚Execution stage complete. (112ms)
+224ms ╚Event processed successfully (224ms)
3/3/2020, 7:29:52 PM +800ms
+2ms ╔Received event [Papa].presence = not present with a delay of 62ms
+174ms ║RunTime Analysis CS > 22ms > PS > 128ms > PE > 23ms > CE
+176ms ║Runtime (41048 bytes) successfully initialized in 128ms (v0.3.110.20191009) (174ms)
+177ms ║╔Execution stage started
+189ms ║║Comparison (enum) not present is (string) present = false (1ms)
+191ms ║║Comparison (enum) not present is (string) present = false (1ms)
+192ms ║║Cancelling condition #2’s schedules…
+193ms ║║Condition #2 evaluated false (12ms)
+200ms ║║Comparison (enum) not present changes_to (string) present = false (1ms)
+201ms ║║Condition #3 evaluated false (7ms)
+202ms ║║Cancelling condition #1’s schedules…
+203ms ║║Condition group #1 evaluated false (state changed) (22ms)
+205ms ║╚Execution stage complete. (28ms)
+206ms ╚Event processed successfully (206ms)
3/3/2020, 3:47:28 PM +267ms
+1ms ╔Received event [Home].test = 1583268448267 with a delay of 0ms
+183ms ║RunTime Analysis CS > 14ms > PS > 144ms > PE > 25ms > CE
+187ms ║Runtime (41045 bytes) successfully initialized in 144ms (v0.3.110.20191009) (185ms)
+188ms ║╔Execution stage started
+201ms ║║Comparison (enum) not present is (string) present = false (1ms)
+203ms ║║Comparison (enum) present is (string) present = true (1ms)
+205ms ║║Condition #2 evaluated true (13ms)
+207ms ║║Condition group #1 evaluated true (state did not change) (14ms)
+214ms ║║Comparison (integer) 15 is_outside_of_range (integer) 6 … (integer) 17 = false (2ms)
+216ms ║║Condition #9 evaluated false (7ms)
+217ms ║║Condition group #7 evaluated false (state did not change) (9ms)
+224ms ║║Comparison (integer) 15 is_outside_of_range (integer) 18 … (integer) 22 = true (2ms)
+226ms ║║Condition #6 evaluated true (7ms)
+227ms ║║Condition group #4 evaluated true (state did not change) (8ms)
+229ms ║║Cancelling statement #4’s schedules…
+233ms ║║Skipping task 13 because of mode restrictions
+240ms ║║Comparison (integer) 15 is_outside_of_range (integer) 23 … (integer) 24 = true (2ms)
+242ms ║║Condition #12 evaluated true (7ms)
+248ms ║║Comparison (integer) 15 is_outside_of_range (integer) 1 … (integer) 5 = true (1ms)
+249ms ║║Condition #14 evaluated true (6ms)
+250ms ║║Condition group #10 evaluated true (state did not change) (15ms)
+252ms ║║Cancelling statement #10’s schedules…
+253ms ║║Skipping task 11 because of mode restrictions
+257ms ║╚Execution stage complete. (70ms)
+258ms ╚Event processed successfully (258ms)
3/3/2020, 3:45:39 PM +682ms
+1ms ╔Starting piston… (v0.3.110.20191009)
+274ms ║╔Subscribing to devices…
+296ms ║║Subscribing to Mom.presence…
+311ms ║║Subscribing to Papa.presence…
+367ms ║╚Finished subscribing (106ms)
+399ms ║Comparison (enum) not present is (string) present = false (1ms)
+401ms ║Comparison (enum) present is (string) present = true (1ms)
+419ms ║Comparison (integer) 15 is_outside_of_range (integer) 6 … (integer) 17 = false (2ms)
+429ms ║Comparison (integer) 15 is_outside_of_range (integer) 18 … (integer) 22 = true (2ms)
+439ms ║Comparison (integer) 15 is_outside_of_range (integer) 23 … (integer) 24 = true (2ms)
+446ms ║Comparison (integer) 15 is_outside_of_range (integer) 1 … (integer) 5 = true (2ms)
+453ms ╚Piston successfully started (452ms)
3/3/2020, 3:43:58 PM +675ms
+1ms ╔Received event [Home].test = 1583268238675 with a delay of 0ms
+162ms ║RunTime Analysis CS > 21ms > PS > 113ms > PE > 28ms > CE
+165ms ║Runtime (41044 bytes) successfully initialized in 113ms (v0.3.110.20191009) (163ms)
+166ms ║╔Execution stage started
+181ms ║║Comparison (enum) not present is (string) present = false (2ms)
+184ms ║║Comparison (enum) present is (string) present = true (2ms)
+186ms ║║Condition #2 evaluated true (14ms)
+187ms ║║Condition group #1 evaluated true (state did not change) (16ms)
+195ms ║║Comparison (integer) 15 is_outside_of_range (integer) 6 … (integer) 17 = false (2ms)
+197ms ║║Condition #9 evaluated false (8ms)
+198ms ║║Condition group #7 evaluated false (state did not change) (9ms)
+207ms ║║Comparison (integer) 15 is_outside_of_range (integer) 18 … (integer) 22 = true (2ms)
+209ms ║║Condition #6 evaluated true (7ms)
+210ms ║║Condition group #4 evaluated true (state did not change) (8ms)
+211ms ║║Cancelling statement #4’s schedules…
+213ms ║║Skipping task 13 because of mode restrictions
+221ms ║║Comparison (integer) 15 is_outside_of_range (integer) 23 … (integer) 24 = true (2ms)
+223ms ║║Condition #12 evaluated true (8ms)
+224ms ║║Condition group #10 evaluated true (state did not change) (9ms)
+225ms ║║Cancelling statement #10’s schedules…
+227ms ║║Skipping task 11 because of mode restrictions
+229ms ║╚Execution stage complete. (63ms)
+230ms ╚Event processed successfully (230ms)
3/3/2020, 3:43:01 PM +451ms
+0ms ╔Starting piston… (v0.3.110.20191009)
+220ms ║╔Subscribing to devices…
+260ms ║║Subscribing to Mom.presence…
+277ms ║║Subscribing to Papa.presence…
+316ms ║╚Finished subscribing (106ms)
+339ms ║Comparison (enum) not present is (string) present = false (2ms)
+342ms ║Comparison (enum) present is (string) present = true (1ms)
+357ms ║Comparison (integer) 15 is_outside_of_range (integer) 6 … (integer) 17 = false (2ms)
+368ms ║Comparison (integer) 15 is_outside_of_range (integer) 18 … (integer) 22 = true (2ms)
+377ms ║Comparison (integer) 15 is_outside_of_range (integer) 23 … (integer) 24 = true (2ms)
+384ms ║Comparison (integer) 15 is_outside_of_range (integer) 1 … (integer) 5 = true (2ms)
+392ms ╚Piston successfully started (391ms)
3/3/2020, 3:37:43 PM +243ms
+0ms ╔Starting piston… (v0.3.110.20191009)
+465ms ║╔Subscribing to devices…
+509ms ║║Subscribing to Mom.presence…
+524ms ║║Subscribing to Papa.presence…
+595ms ║╚Finished subscribing (146ms)
+629ms ║Comparison (enum) not present is (string) present = false (2ms)
+632ms ║Comparison (enum) present is (string) present = true (1ms)
+648ms ║Comparison (integer) 15 is_outside_of_range (integer) 6 … (integer) 17 = false (2ms)
+660ms ║Comparison (integer) 15 is_outside_of_range (integer) 18 … (integer) 22 = true (2ms)
+670ms ║Comparison (integer) 15 is_outside_of_range (integer) 23 … (integer) 24 = true (2ms)
+677ms ║Comparison (integer) 15 is_outside_of_range (integer) 1 … (integer) 5 = true (2ms)
+687ms ╚Piston successfully started (686ms)
3/3/2020, 1:59:37 PM +385ms
+2ms ╔Received event [Papa].presence = present with a delay of 58ms
+170ms ║RunTime Analysis CS > 24ms > PS > 124ms > PE > 22ms > CE
+173ms ║Runtime (41053 bytes) successfully initialized in 124ms (v0.3.110.20191009) (170ms)
+174ms ║╔Execution stage started
+184ms ║║Comparison (enum) not present is (string) present = false (1ms)
+187ms ║║Comparison (enum) present is (string) present = true (1ms)
+188ms ║║Cancelling condition #2’s schedules…
+189ms ║║Condition #2 evaluated true (11ms)
+190ms ║║Cancelling condition #1’s schedules…
+191ms ║║Condition group #1 evaluated true (state changed) (13ms)
+197ms ║║Comparison (integer) 13 is_outside_of_range (integer) 6 … (integer) 17 = false (2ms)
+199ms ║║Condition #9 evaluated false (6ms)
+200ms ║║Condition group #7 evaluated false (state did not change) (7ms)
+206ms ║║Comparison (integer) 13 is_outside_of_range (integer) 18 … (integer) 22 = true (2ms)
+208ms ║║Condition #6 evaluated true (6ms)
+209ms ║║Condition group #4 evaluated true (state did not change) (8ms)
+210ms ║║Cancelling statement #4’s schedules…
+339ms ║║Executed virtual command setLocationMode (126ms)
+346ms ║║Comparison (integer) 13 is_outside_of_range (integer) 23 … (integer) 24 = true (2ms)
+348ms ║║Condition #12 evaluated true (6ms)
+353ms ║║Comparison (integer) 13 is_outside_of_range (integer) 1 … (integer) 5 = true (2ms)
+354ms ║║Condition #14 evaluated true (6ms)
+355ms ║║Condition group #10 evaluated true (state did not change) (14ms)
+356ms ║║Cancelling statement #10’s schedules…
+453ms ║║Executed virtual command setLocationMode (93ms)
+455ms ║╚Execution stage complete. (282ms)
+456ms ╚Event processed successfully (456ms)

REMOVE BELOW AFTER READING


#2

First off,
change places of the trigger and the condition,
(line 19 goes to line 21 and 21 goes to 19)

Other then that I’d say get rid of ONLY when and create nested IFs
and use real times instead of numbers (just for testing purposes)

If presense sensor change to present
then 
       IF time is between this and that
       Then
       Do this do that
       
       If time is this 
       Then 
       Do this and that

#3

I might also consider dropping “XOR” and combining those two conditions into one:

IF $hour24 is outside of range 6 and 22
    Then set location to Night
END IF

This IF will be true from 11:00pm to 5:59am


#4

I had that at first but started to separate to see if maybe it was an hitting one over the other but I will recombine them.


#5

okay i will look to make these changes and retest thank you…


#6

By the way @amishtech, I love your oxymoronic user name!!


#7

Two comments spring to mind:

  1. The only time the trigger condition on line 21 is ever evaluated is if you run the piston manually (e.g. with the ‘Test’ button) when neither presence sensor is present. If neither is present then neither can have changed to present so it will always evaluate as false. Choose either line 19 or 21. Either way the piston will execute when the presence sensor changes. The only difference is that if you keep 19 you can use the ‘Test’ button to check the current state of the sensors. If you just keep 21 using the ‘Test’ button won’t cause anything interesting to happen.

  2. Your restrictions seem to be back to front. For example, if it is 5am, $hour24 is 5, which is outside of the range 6…17 so the location mode will be set to Home. However it is also outside of 18…22 so the location mode will be then be set to Evening.


#8

I appreciate it. yeah I love my choice in name I use it every where I go. I have implemented the changes and optional solution provided in your suggestions. I will test it again tomorrow but it looks very promising. Thank you for your guidance.


#9

I modified the setup to now look as the following based on the suggestions above:


#10

Because it spans midnight, I would change line 33 to:
IF $hour24 is outside of range 6 and 22.


#11

That midnight hour situation that you taught me?


#12

Yes. There may be situations where it may occasionally span as intended, but the inverted method I posted will always work!


#13

okay will do.


#14

One more observation I just noticed:

IF Sensor's presence changes to present
    Then do something (only while Away)

The “present” and “Away” portion sounds contradictory…


#15

I only want this piston to work When either presence is confirmed present and the mode is already set to away. does that make sense? the mode being changed to away occurs on another operation when both presences are not present.


#16

I think I am better understanding your setup…

… then at that point (please correct me if I am wrong), this piston is the only program that changes location to some version of “Home”…


If I am understanding you correctly, here’s one more tidbit of info that may help. Currently, if Sensor 4 & 5 stay home all day, then your location mode will stay stuck in “Night” (from yesterday).

When either Sensor 4 or 5 leaves the neighborhood, then the piston will execute for the first time that day, and finally, the location mode will correct itself.

I just thought you should know about the delay.


#17

true, I can see how that would happen, but let me throw in another insight. I have other operations throughout the day that change the modes from home, evening, and night. This is strictly to change the modes when im away to when I come back based on the time to be correctly set back to what its supposed to be at the time of day. hope this clears up a little more of my setup. :slight_smile:


#18

Perfect, as long as it’s not your “main” location setter…