How to make a piston fire only if switch is not already on


#1

1) Give a description of the problem
So I have porch lights that are turned on with motion on a camera that activates a simulated switch that turns on a wall mounted switch that turns on the lights.
There is a delay and then the light goes out. Pretty simple.
What I want to do is if the wall mounted switch is already ON, then I DON’T want the piston to fire. The reason being is if we are out on the porch, the lights will keep going on, delay, and then off again, on again with motion etc.
I would like the piston to see that the switch is already on because I physically turned it on, so it won’t run.
Seems simple (and I’m sure it is) but I can’t figure it out for the life of me.

2) What is the expected behaviour?
Piston run as motion detector only if switch isn’t already on.
3) What is happening/not happening?
Lights go on/off with motion after a delay no matter what.
I know why the posted piston doesn’t work, but posted as a starting off point.
4) Post a Green Snapshot of the pistonimage

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)


#2

Okay I just saw this thread-is this the only answer?
Sorry to clog the boards if so. I’ll experiment tomorrow.


#3

I like the simplicity here:

IF Sensor's motion changes to active
    Then Turn on SimSwitch (or Porch lights directly)
END IF

IF Sensor's motion stays inactive for 5 minutes   (or whatever)
    Then Turn off SimSwitch (or Porch lights directly)
END IF

With this method, as long as someone is still in front of the sensor, the lights will stay on…
(don’t set the time too small, or you may find yourself waving your arms to bring them back. I usually start with 3-5 min and go from there)

Don’t feel bad though… It is all part of the calibration process.
(IE: your timeout in the bathroom will not be the same as the one in the garage)


That being said, @bangali’s piston is a great way to incorporate an override switch.


#4

The way I have it set up now is I have security spy sensing camera motion-that sends a webhoook to ifttt that turns on a virtual switch (“AA porch lights virtual switch” in my example). I have a piston that immediately turns the virtual switch off so it’s ready to “turn on” with the next motion.
So it’s not actually a motion sensor.
So how would that be incorporated into your example? I like the theory-makes perfect sense.
Thank You!!


#6

Ahhh, I see…

You have a device that sees motion, and registers motion, and runs a piston at motion…

but you have no device to see inactivity… or register inactivity… or run a piston when inactive…

What method are you planning to use to determine when the porch is vacant?


#7

The lack of the sim switch being turned on?
It’s basically acting like a momentary switch as I have a piston that turns it to off a moment after it is turned on by the camera motion.


#8

If you do not have a device you can use for this, you may be forced to count each event, and compare the current time to a previous time, and then decide what to do with the porch light. (this thread may inspire you, or it may encourage you to go a different route entirely)


Pro Tip:

It is definitely possible to code this here in webCoRE, but my recommendation would be to simply install a real motion sensor on your porch, LOL


#9

This won’t work?


#10

You can try it… but the condition “did not change” never sets a schedule for me…
(maybe it is unfinished code like the trigger “stays unchanged”)


To clarify a bit:

  • The trigger “stays unchanged” is always true, regardless of how often it changes…
  • The condition “did not change” is not even checked from what I can see…

"Stays away from" and "Stays any of" triggers unexpected behavior
Preventing flapping of a devcie
New Here, does this night light look ok
#11

I’ll give it a shot and report back.


#12

This works-everytime the switch changes to “on” it resets the timer to the start of the 3 minutes.
Thanks for the idea. It’s even better than what I had in mind as it requires no interaction to achieve the required result.
Now I just need to figure out how to make the lights open to 80% before midnight and 100% after midnight.


#13

Would you be willing to post full logs showing the initial turn on, at least one extension, and the final turn off please?

I’d love to see what is happening behind the scenes.


#14

For the record, I tried using your “switch did not change” using a few variations, and they all failed for me to set the schedule. (Note: I am not looking at the Dashboard timer, I am looking at the log and the final results)

When I change your second IF to the following, it works every time.

pic

As long as “Switch1” changes to off at least once every 2m 59s, then “Switch2” will not turn off.
(IE: Switch1 changing to on cancels the timer… Switch1 changing to off begins the timer)


Note:

To make testing easier, you can reduce that 3min to 1min during testing.


#15
6/12/2020, 4:56:49 PM +184ms
+0ms ╔Received event [Charles St].time = 1591995410366 with a delay of -1183ms
+90ms ║RunTime Analysis CS &gt; 23ms &gt; PS &gt; 37ms &gt; PE &gt; 30ms &gt; CE
+92ms ║Runtime (37366 bytes) successfully initialized in 37ms (v0.3.110.20191009) (91ms)
+93ms ║╔Execution stage started
+109ms ║║Skipped execution of physical command [Porch Lights Back Porch Lights].off([]) because it would make no change to the device. (2ms)
+110ms ║║Executed [Porch Lights Back Porch Lights].off (4ms)
+113ms ║╚Execution stage complete. (19ms)
+114ms ╚Event processed successfully (113ms)
6/12/2020, 4:53:50 PM +144ms
+2ms ╔Received event [AA porch lights virtual switch].switch = off with a delay of 68ms
+109ms ║RunTime Analysis CS &gt; 21ms &gt; PS &gt; 49ms &gt; PE &gt; 39ms &gt; CE
+112ms ║Runtime (37373 bytes) successfully initialized in 49ms (v0.3.110.20191009) (109ms)
+112ms ║╔Execution stage started
+120ms ║║Comparison (enum) off is (string) on = false (1ms)
+121ms ║║Cancelling condition #2's schedules...
+122ms ║║Condition #2 evaluated false (6ms)
+123ms ║║Cancelling condition #1's schedules...
+124ms ║║Condition group #1 evaluated false (state changed) (7ms)
+211ms ║║Comparison (enum) off did_not_change = true (83ms)
+212ms ║║Condition #6 evaluated true (86ms)
+213ms ║║Condition group #5 evaluated true (state did not change) (87ms)
+215ms ║║Cancelling statement #7's schedules...
+220ms ║║Executed virtual command [Porch Lights Back Porch Lights].wait (1ms)
+221ms ║║Requesting a wake up for Fri, Jun 12 2020 @ 4:56:50 PM EDT (in 180.0s)
+225ms ║╚Execution stage complete. (113ms)
+226ms ║Setting up scheduled job for Fri, Jun 12 2020 @ 4:56:50 PM EDT (in 179.996s)
+238ms ╚Event processed successfully (238ms)
6/12/2020, 4:53:49 PM +830ms
+2ms ╔Received event [AA porch lights virtual switch].switch = on with a delay of 59ms
+97ms ║RunTime Analysis CS &gt; 18ms &gt; PS &gt; 40ms &gt; PE &gt; 38ms &gt; CE
+99ms ║Runtime (37374 bytes) successfully initialized in 40ms (v0.3.110.20191009) (97ms)
+100ms ║╔Execution stage started
+107ms ║║Comparison (enum) on is (string) on = true (1ms)
+108ms ║║Cancelling condition #2's schedules...
+109ms ║║Condition #2 evaluated true (6ms)
+110ms ║║Cancelling condition #1's schedules...
+110ms ║║Condition group #1 evaluated true (state changed) (7ms)
+112ms ║║Cancelling statement #3's schedules...
+123ms ║║Skipped execution of physical command [Porch Lights Back Porch Lights].setLevel([88]) because it would make no change to the device. (5ms)
+123ms ║║Executed [Porch Lights Back Porch Lights].setLevel (7ms)
+144ms ║║Comparison (enum) on did_not_change = true (16ms)
+145ms ║║Condition #6 evaluated true (19ms)
+146ms ║║Condition group #5 evaluated true (state did not change) (20ms)
+148ms ║║Cancelling statement #7's schedules...
+151ms ║║Executed virtual command [Porch Lights Back Porch Lights].wait (0ms)
+152ms ║║Requesting a wake up for Fri, Jun 12 2020 @ 4:56:49 PM EDT (in 180.0s)
+156ms ║╚Execution stage complete. (57ms)
+158ms ║Setting up scheduled job for Fri, Jun 12 2020 @ 4:56:49 PM EDT (in 179.996s)
+169ms ╚Event processed successfully (169ms)
6/12/2020, 4:53:16 PM +613ms
+1ms ╔Received event [AA porch lights virtual switch].switch = off with a delay of 45ms
+9846ms ║RunTime Analysis CS &gt; 16ms &gt; PS &gt; 9794ms &gt; PE &gt; 36ms &gt; CE
+9847ms ║Piston waited at a semaphore for 9764ms
+9849ms ║Runtime (37447 bytes) successfully initialized in 9794ms (v0.3.110.20191009) (9847ms)
+9850ms ║╔Execution stage started
+9857ms ║║Comparison (enum) off is (string) on = false (1ms)
+9858ms ║║Cancelling condition #2's schedules...
+9859ms ║║Condition #2 evaluated false (5ms)
+9860ms ║║Cancelling condition #1's schedules...
+9861ms ║║Condition group #1 evaluated false (state changed) (8ms)
+9883ms ║║Comparison (enum) off did_not_change = true (18ms)
+9884ms ║║Condition #6 evaluated true (21ms)
+9885ms ║║Condition group #5 evaluated true (state did not change) (22ms)
+9887ms ║║Cancelling statement #7's schedules...
+9891ms ║║Executed virtual command [Porch Lights Back Porch Lights].wait (0ms)
+9892ms ║║Requesting a wake up for Fri, Jun 12 2020 @ 4:56:26 PM EDT (in 180.0s)
+9895ms ║╚Execution stage complete. (46ms)
+9897ms ║Setting up scheduled job for Fri, Jun 12 2020 @ 4:56:26 PM EDT (in 179.996s)
+9907ms ╚Event processed successfully (9907ms)
6/12/2020, 4:53:16 PM +321ms
+1ms ╔Received event [AA porch lights virtual switch].switch = on with a delay of 59ms
+106ms ║RunTime Analysis CS &gt; 17ms &gt; PS &gt; 45ms &gt; PE &gt; 43ms &gt; CE
+108ms ║Runtime (37375 bytes) successfully initialized in 45ms (v0.3.110.20191009) (106ms)
+109ms ║╔Execution stage started
+116ms ║║Comparison (enum) on is (string) on = true (1ms)
+118ms ║║Cancelling condition #2's schedules...
+119ms ║║Condition #2 evaluated true (6ms)
+120ms ║║Cancelling condition #1's schedules...
+121ms ║║Condition group #1 evaluated true (state changed) (7ms)
+123ms ║║Cancelling statement #3's schedules...
+177ms ║║Executed physical command [Porch Lights Back Porch Lights].setLevel([88]) (50ms)
+178ms ║║Executed [Porch Lights Back Porch Lights].setLevel (51ms)
+299ms ║║Comparison (enum) on did_not_change = true (116ms)
+300ms ║║Condition #6 evaluated true (119ms)
+301ms ║║Condition group #5 evaluated true (state did not change) (121ms)
+304ms ║║Cancelling statement #7's schedules...
+307ms ║║Executed virtual command [Porch Lights Back Porch Lights].wait (1ms)
+308ms ║║Requesting a wake up for Fri, Jun 12 2020 @ 4:56:16 PM EDT (in 180.0s)
+312ms ║╚Execution stage complete. (203ms)
+314ms ║Setting up scheduled job for Fri, Jun 12 2020 @ 4:56:16 PM EDT (in 179.996s)
+325ms ╚Event processed successfully (325ms)
6/12/2020, 4:51:56 PM +55ms
+1ms ╔Received event [AA porch lights virtual switch].switch = off with a delay of 62ms
+105ms ║RunTime Analysis CS &gt; 17ms &gt; PS &gt; 43ms &gt; PE &gt; 45ms &gt; CE
+107ms ║Runtime (37373 bytes) successfully initialized in 43ms (v0.3.110.20191009) (105ms)
+108ms ║╔Execution stage started
+116ms ║║Comparison (enum) off is (string) on = false (2ms)
+117ms ║║Cancelling condition #2's schedules...
+118ms ║║Condition #2 evaluated false (6ms)
+119ms ║║Cancelling condition #1's schedules...
+120ms ║║Condition group #1 evaluated false (state changed) (8ms)
+144ms ║║Comparison (enum) off did_not_change = true (19ms)
+145ms ║║Condition #6 evaluated true (22ms)
+146ms ║║Condition group #5 evaluated true (state did not change) (24ms)
+149ms ║║Cancelling statement #7's schedules...
+153ms ║║Executed virtual command [Porch Lights Back Porch Lights].wait (0ms)
+154ms ║║Requesting a wake up for Fri, Jun 12 2020 @ 4:54:56 PM EDT (in 180.0s)
+159ms ║╚Execution stage complete. (50ms)
+160ms ║Setting up scheduled job for Fri, Jun 12 2020 @ 4:54:56 PM EDT (in 179.996s)
+171ms ╚Event processed successfully (171ms)
6/12/2020, 4:51:55 PM +733ms
+2ms ╔Received event [AA porch lights virtual switch].switch = on with a delay of 65ms
+104ms ║RunTime Analysis CS &gt; 18ms &gt; PS &gt; 47ms &gt; PE &gt; 38ms &gt; CE
+106ms ║Runtime (37375 bytes) successfully initialized in 47ms (v0.3.110.20191009) (104ms)
+107ms ║╔Execution stage started
+114ms ║║Comparison (enum) on is (string) on = true (1ms)
+116ms ║║Cancelling condition #2's schedules...
+116ms ║║Condition #2 evaluated true (5ms)
+117ms ║║Cancelling condition #1's schedules...
+118ms ║║Condition group #1 evaluated true (state changed) (8ms)
+120ms ║║Cancelling statement #3's schedules...
+130ms ║║Skipped execution of physical command [Porch Lights Back Porch Lights].setLevel([88]) because it would make no change to the device. (4ms)
+130ms ║║Executed [Porch Lights Back Porch Lights].setLevel (6ms)
+154ms ║║Comparison (enum) on did_not_change = true (19ms)
+156ms ║║Condition #6 evaluated true (22ms)
+157ms ║║Condition group #5 evaluated true (state did not change) (23ms)
+159ms ║║Cancelling statement #7's schedules...
+162ms ║║Executed virtual command [Porch Lights Back Porch Lights].wait (0ms)
+163ms ║║Requesting a wake up for Fri, Jun 12 2020 @ 4:54:55 PM EDT (in 180.0s)
+167ms ║╚Execution stage complete. (60ms)
+168ms ║Setting up scheduled job for Fri, Jun 12 2020 @ 4:54:55 PM EDT (in 179.996s)
+178ms ╚Event processed successfully (178ms)
6/12/2020, 4:51:12 PM +145ms
+1ms ╔Received event [AA porch lights virtual switch].switch = off with a delay of 69ms
+9873ms ║RunTime Analysis CS &gt; 20ms &gt; PS &gt; 9814ms &gt; PE &gt; 40ms &gt; CE
+9874ms ║Piston waited at a semaphore for 9764ms
+9876ms ║Runtime (37447 bytes) successfully initialized in 9814ms (v0.3.110.20191009) (9874ms)
+9877ms ║╔Execution stage started
+9885ms ║║Comparison (enum) off is (string) on = false (2ms)
+9886ms ║║Cancelling condition #2's schedules...
+9887ms ║║Condition #2 evaluated false (6ms)
+9888ms ║║Cancelling condition #1's schedules...
+9889ms ║║Condition group #1 evaluated false (state changed) (8ms)
+9960ms ║║Comparison (enum) off did_not_change = true (67ms)
+9961ms ║║Condition #6 evaluated true (70ms)
+9962ms ║║Condition group #5 evaluated true (state did not change) (71ms)
+9964ms ║║Cancelling statement #7's schedules...
+9969ms ║║Executed virtual command [Porch Lights Back Porch Lights].wait (1ms)
+9970ms ║║Requesting a wake up for Fri, Jun 12 2020 @ 4:54:22 PM EDT (in 180.0s)
+9974ms ║╚Execution stage complete. (97ms)
+9975ms ║Setting up scheduled job for Fri, Jun 12 2020 @ 4:54:22 PM EDT (in 179.996s)
+9986ms ╚Event processed successfully (9986ms)
6/12/2020, 4:51:11 PM +796ms
+1ms ╔Received event [AA porch lights virtual switch].switch = on with a delay of 62ms
+118ms ║RunTime Analysis CS &gt; 22ms &gt; PS &gt; 54ms &gt; PE &gt; 42ms &gt; CE
+121ms ║Runtime (37375 bytes) successfully initialized in 54ms (v0.3.110.20191009) (118ms)
+121ms ║╔Execution stage started
+129ms ║║Comparison (enum) on is (string) on = true (1ms)
+130ms ║║Cancelling condition #2's schedules...
+131ms ║║Condition #2 evaluated true (6ms)
+132ms ║║Cancelling condition #1's schedules...
+132ms ║║Condition group #1 evaluated true (state changed) (7ms)
+134ms ║║Cancelling statement #3's schedules...
+144ms ║║Skipped execution of physical command [Porch Lights Back Porch Lights].setLevel([88]) because it would make no change to the device. (5ms)
+145ms ║║Executed [Porch Lights Back Porch Lights].setLevel (6ms)
+235ms ║║Comparison (enum) on did_not_change = true (86ms)
+236ms ║║Condition #6 evaluated true (89ms)
+237ms ║║Condition group #5 evaluated true (state did not change) (90ms)
+239ms ║║Cancelling statement #7's schedules...
+242ms ║║Executed virtual command [Porch Lights Back Porch Lights].wait (1ms)
+243ms ║║Requesting a wake up for Fri, Jun 12 2020 @ 4:54:12 PM EDT (in 180.0s)
+247ms ║╚Execution stage complete. (126ms)
+248ms ║Setting up scheduled job for Fri, Jun 12 2020 @ 4:54:12 PM EDT (in 179.996s)
+359ms ╚Event processed successfully (359ms)
6/12/2020, 4:49:14 PM +797ms
+1ms ╔Received event [AA porch lights virtual switch].switch = off with a delay of 50ms
+82ms ║RunTime Analysis CS &gt; 16ms &gt; PS &gt; 28ms &gt; PE &gt; 38ms &gt; CE
+84ms ║Runtime (37372 bytes) successfully initialized in 28ms (v0.3.110.20191009) (83ms)
+85ms ║╔Execution stage started
+92ms ║║Comparison (enum) off is (string) on = false (1ms)
+93ms ║║Cancelling condition #2's schedules...
+94ms ║║Condition #2 evaluated false (5ms)
+95ms ║║Cancelling condition #1's schedules...
+96ms ║║Condition group #1 evaluated false (state changed) (8ms)
+117ms ║║Comparison (enum) off did_not_change = true (16ms)
+118ms ║║Condition #6 evaluated true (19ms)
+119ms ║║Condition group #5 evaluated true (state did not change) (20ms)
+120ms ║║Cancelling statement #7's schedules...
+124ms ║║Executed virtual command [Porch Lights Back Porch Lights].wait (0ms)
+125ms ║║Requesting a wake up for Fri, Jun 12 2020 @ 4:52:14 PM EDT (in 180.0s)
+129ms ║╚Execution stage complete. (44ms)
+130ms ║Setting up scheduled job for Fri, Jun 12 2020 @ 4:52:14 PM EDT (in 179.996s)
+141ms ╚Event processed successfully (141ms)
6/12/2020, 4:49:14 PM +505ms
+2ms ╔Received event [AA porch lights virtual switch].switch = on with a delay of 64ms
+107ms ║RunTime Analysis CS &gt; 18ms &gt; PS &gt; 49ms &gt; PE &gt; 40ms &gt; CE
+109ms ║Runtime (37375 bytes) successfully initialized in 49ms (v0.3.110.20191009) (107ms)
+110ms ║╔Execution stage started
+118ms ║║Comparison (enum) on is (string) on = true (1ms)
+119ms ║║Cancelling condition #2's schedules...
+120ms ║║Condition #2 evaluated true (6ms)
+121ms ║║Cancelling condition #1's schedules...
+121ms ║║Condition group #1 evaluated true (state changed) (7ms)
+123ms ║║Cancelling statement #3's schedules...
+133ms ║║Skipped execution of physical command [Porch Lights Back Porch Lights].setLevel([88]) because it would make no change to the device. (5ms)
+134ms ║║Executed [Porch Lights Back Porch Lights].setLevel (6ms)
+156ms ║║Comparison (enum) on did_not_change = true (18ms)
+157ms ║║Condition #6 evaluated true (21ms)
+158ms ║║Condition group #5 evaluated true (state did not change) (22ms)
+160ms ║║Cancelling statement #7's schedules...
+163ms ║║Executed virtual command [Porch Lights Back Porch Lights].wait (1ms)
+164ms ║║Requesting a wake up for Fri, Jun 12 2020 @ 4:52:14 PM EDT (in 180.0s)
+168ms ║╚Execution stage complete. (58ms)
+170ms ║Setting up scheduled job for Fri, Jun 12 2020 @ 4:52:14 PM EDT (in 179.996s)
+244ms ╚Event processed successfully (244ms)
6/12/2020, 4:48:32 PM +158ms
+1ms ╔Received event [AA porch lights virtual switch].switch = off with a delay of 46ms
+89ms ║RunTime Analysis CS &gt; 20ms &gt; PS &gt; 30ms &gt; PE &gt; 39ms &gt; CE
+92ms ║Runtime (37372 bytes) successfully initialized in 30ms (v0.3.110.20191009) (90ms)
+92ms ║╔Execution stage started
+100ms ║║Comparison (enum) off is (string) on = false (2ms)
+101ms ║║Cancelling condition #2's schedules...
+102ms ║║Condition #2 evaluated false (6ms)
+103ms ║║Cancelling condition #1's schedules...
+104ms ║║Condition group #1 evaluated false (state changed) (7ms)
+125ms ║║Comparison (enum) off did_not_change = true (16ms)
+126ms ║║Condition #6 evaluated true (20ms)
+127ms ║║Condition group #5 evaluated true (state did not change) (20ms)
+129ms ║║Cancelling statement #7's schedules...
+132ms ║║Executed virtual command [Porch Lights Back Porch Lights].wait (0ms)
+134ms ║║Requesting a wake up for Fri, Jun 12 2020 @ 4:51:32 PM EDT (in 180.0s)
+137ms ║╚Execution stage complete. (45ms)
+139ms ║Setting up scheduled job for Fri, Jun 12 2020 @ 4:51:32 PM EDT (in 179.996s)
+155ms ╚Event processed successfully (155ms)
6/12/2020, 4:48:31 PM +881ms
+2ms ╔Received event [AA porch lights virtual switch].switch = on with a delay of 64ms
+108ms ║RunTime Analysis CS &gt; 19ms &gt; PS &gt; 50ms &gt; PE &gt; 38ms &gt; CE
+110ms ║Runtime (37375 bytes) successfully initialized in 50ms (v0.3.110.20191009) (108ms)
+111ms ║╔Execution stage started
+118ms ║║Comparison (enum) on is (string) on = true (1ms)
+119ms ║║Cancelling condition #2's schedules...
+120ms ║║Condition #2 evaluated true (5ms)
+121ms ║║Cancelling condition #1's schedules...
+122ms ║║Condition group #1 evaluated true (state changed) (8ms)
+124ms ║║Cancelling statement #3's schedules...
+132ms ║║Skipped execution of physical command [Porch Lights Back Porch Lights].setLevel([88]) because it would make no change to the device. (3ms)
+132ms ║║Executed [Porch Lights Back Porch Lights].setLevel (4ms)
+205ms ║║Comparison (enum) on did_not_change = true (68ms)
+206ms ║║Condition #6 evaluated true (71ms)
+207ms ║║Condition group #5 evaluated true (state did not change) (72ms)
+209ms ║║Cancelling statement #7's schedules...
+212ms ║║Executed virtual command [Porch Lights Back Porch Lights].wait (1ms)
+213ms ║║Requesting a wake up for Fri, Jun 12 2020 @ 4:51:32 PM EDT (in 180.0s)
+217ms ║╚Execution stage complete. (106ms)
+218ms ║Setting up scheduled job for Fri, Jun 12 2020 @ 4:51:32 PM EDT (in 179.996s)
+229ms ╚Event processed successfully (229ms)
6/12/2020, 4:48:12 PM +8ms
+1ms ╔Received event [AA porch lights virtual switch].switch = off with a delay of 52ms
+86ms ║RunTime Analysis CS &gt; 15ms &gt; PS &gt; 34ms &gt; PE &gt; 37ms &gt; CE
+88ms ║Runtime (37372 bytes) successfully initialized in 34ms (v0.3.110.20191009) (86ms)
+89ms ║╔Execution stage started
+97ms ║║Comparison (enum) off is (string) on = false (1ms)
+99ms ║║Cancelling condition #2's schedules...
+99ms ║║Condition #2 evaluated false (6ms)
+100ms ║║Cancelling condition #1's schedules...
+101ms ║║Condition group #1 evaluated false (state changed) (8ms)
+171ms ║║Comparison (enum) off did_not_change = true (65ms)
+172ms ║║Condition #6 evaluated true (68ms)
+173ms ║║Condition group #5 evaluated true (state did not change) (70ms)
+175ms ║║Cancelling statement #7's schedules...
+179ms ║║Executed virtual command [Porch Lights Back Porch Lights].wait (0ms)
+181ms ║║Requesting a wake up for Fri, Jun 12 2020 @ 4:51:12 PM EDT (in 180.0s)
+185ms ║╚Execution stage complete. (95ms)
+186ms ║Setting up scheduled job for Fri, Jun 12 2020 @ 4:51:12 PM EDT (in 179.996s)
+198ms ╚Event processed successfully (198ms)
6/12/2020, 4:48:11 PM +728ms
+1ms ╔Received event [AA porch lights virtual switch].switch = on with a delay of 45ms
+79ms ║RunTime Analysis CS &gt; 14ms &gt; PS &gt; 31ms &gt; PE &gt; 34ms &gt; CE
+81ms ║Runtime (37374 bytes) successfully initialized in 31ms (v0.3.110.20191009) (79ms)
+82ms ║╔Execution stage started
+90ms ║║Comparison (enum) on is (string) on = true (1ms)
+91ms ║║Cancelling condition #2's schedules...
+92ms ║║Condition #2 evaluated true (6ms)
+93ms ║║Cancelling condition #1's schedules...
+94ms ║║Condition group #1 evaluated true (state changed) (8ms)
+96ms ║║Cancelling statement #3's schedules...
+105ms ║║Skipped execution of physical command [Porch Lights Back Porch Lights].setLevel([88]) because it would make no change to the device. (5ms)
+106ms ║║Executed [Porch Lights Back Porch Lights].setLevel (6ms)
+128ms ║║Comparison (enum) on did_not_change = true (17ms)
+129ms ║║Condition #6 evaluated true (20ms)
+130ms ║║Condition group #5 evaluated true (state did not change) (22ms)
+132ms ║║Cancelling statement #7's schedules...
+135ms ║║Executed virtual command [Porch Lights Back Porch Lights].wait (0ms)
+137ms ║║Requesting a wake up for Fri, Jun 12 2020 @ 4:51:11 PM EDT (in 180.0s)
+142ms ║╚Execution stage complete. (60ms)
+143ms ║Setting up scheduled job for Fri, Jun 12 2020 @ 4:51:11 PM EDT (in 179.994s)
+154ms ╚Event processed successfully (154ms)
6/12/2020, 4:45:18 PM +917ms
+1ms ╔Received event [AA porch lights virtual switch].switch = off with a delay of 58ms
+104ms ║RunTime Analysis CS &gt; 18ms &gt; PS &gt; 43ms &gt; PE &gt; 42ms &gt; CE
+106ms ║Runtime (37373 bytes) successfully initialized in 43ms (v0.3.110.20191009) (104ms)
+107ms ║╔Execution stage started
+115ms ║║Comparison (enum) off is (string) on = false (2ms)
+116ms ║║Cancelling condition #2's schedules...
+117ms ║║Condition #2 evaluated false (6ms)
+118ms ║║Cancelling condition #1's schedules...
+119ms ║║Condition group #1 evaluated false (state changed) (8ms)
+142ms ║║Comparison (enum) off did_not_change = true (17ms)
+143ms ║║Condition #6 evaluated true (21ms)
+144ms ║║Condition group #5 evaluated true (state did not change) (23ms)
+146ms ║║Cancelling statement #7's schedules...
+151ms ║║Executed virtual command [Porch Lights Back Porch Lights].wait (0ms)
+152ms ║║Requesting a wake up for Fri, Jun 12 2020 @ 4:48:19 PM EDT (in 180.0s)
+156ms ║╚Execution stage complete. (49ms)
+158ms ║Setting up scheduled job for Fri, Jun 12 2020 @ 4:48:19 PM EDT (in 179.996s)
+176ms ╚Event processed successfully (176ms)
6/12/2020, 4:45:18 PM +586ms
+1ms ╔Received event [AA porch lights virtual switch].switch = on with a delay of 53ms
+97ms ║RunTime Analysis CS &gt; 18ms &gt; PS &gt; 42ms &gt; PE &gt; 37ms &gt; CE
+99ms ║Runtime (37374 bytes) successfully initialized in 42ms (v0.3.110.20191009) (97ms)
+100ms ║╔Execution stage started
+107ms ║║Comparison (enum) on is (string) on = true (1ms)
+109ms ║║Cancelling condition #2's schedules...
+110ms ║║Condition #2 evaluated true (5ms)
+111ms ║║Cancelling condition #1's schedules...
+111ms ║║Condition group #1 evaluated true (state changed) (7ms)
+113ms ║║Cancelling statement #3's schedules...
+122ms ║║Skipped execution of physical command [Porch Lights Back Porch Lights].setLevel([88]) because it would make no change to the device. (4ms)
+123ms ║║Executed [Porch Lights Back Porch Lights].setLevel (6ms)
+148ms ║║Comparison (enum) on did_not_change = true (21ms)
+149ms ║║Condition #6 evaluated true (24ms)
+150ms ║║Condition group #5 evaluated true (state did not change) (25ms)
+152ms ║║Cancelling statement #7's schedules...
+155ms ║║Executed virtual command [Porch Lights Back Porch Lights].wait (0ms)
+156ms ║║Requesting a wake up for Fri, Jun 12 2020 @ 4:48:18 PM EDT (in 180.0s)
+160ms ║╚Execution stage complete. (60ms)
+162ms ║Setting up scheduled job for Fri, Jun 12 2020 @ 4:48:18 PM EDT (in 179.996s)
+171ms ╚Event processed successfully (171ms)
6/12/2020, 4:43:05 PM +132ms
+2ms ╔Received event [AA porch lights virtual switch].switch = off with a delay of 69ms
+206ms ║RunTime Analysis CS &gt; 111ms &gt; PS &gt; 49ms &gt; PE &gt; 46ms &gt; CE
+208ms ║Runtime (37374 bytes) successfully initialized in 49ms (v0.3.110.20191009) (206ms)
+209ms ║╔Execution stage started
+217ms ║║Comparison (enum) off is (string) on = false (1ms)
+218ms ║║Cancelling condition #2's schedules...
+219ms ║║Condition #2 evaluated false (6ms)
+220ms ║║Cancelling condition #1's schedules...
+221ms ║║Condition group #1 evaluated false (state changed) (8ms)
+243ms ║║Comparison (enum) off did_not_change = true (18ms)
+245ms ║║Condition #6 evaluated true (21ms)
+246ms ║║Condition group #5 evaluated true (state did not change) (22ms)
+248ms ║║Cancelling statement #7's schedules...
+253ms ║║Executed virtual command [Porch Lights Back Porch Lights].wait (0ms)
+254ms ║║Requesting a wake up for Fri, Jun 12 2020 @ 4:46:05 PM EDT (in 180.0s)
+258ms ║╚Execution stage complete. (49ms)
+260ms ║Setting up scheduled job for Fri, Jun 12 2020 @ 4:46:05 PM EDT (in 179.996s)
+270ms ╚Event processed successfully (270ms)
6/12/2020, 4:43:04 PM +571ms
+1ms ╔Received event [AA porch lights virtual switch].switch = on with a delay of 43ms
+314ms ║RunTime Analysis CS &gt; 123ms &gt; PS &gt; 154ms &gt; PE &gt; 37ms &gt; CE
+316ms ║Runtime (37378 bytes) successfully initialized in 154ms (v0.3.110.20191009) (314ms)
+317ms ║╔Execution stage started
+325ms ║║Comparison (enum) on is (string) on = true (1ms)
+327ms ║║Cancelling condition #2's schedules...
+328ms ║║Condition #2 evaluated true (5ms)
+329ms ║║Cancelling condition #1's schedules...
+329ms ║║Condition group #1 evaluated true (state changed) (8ms)
+331ms ║║Cancelling statement #3's schedules...
+339ms ║║Skipped execution of physical command [Porch Lights Back Porch Lights].setLevel([88]) because it would make no change to the device. (4ms)
+340ms ║║Executed [Porch Lights Back Porch Lights].setLevel (5ms)
+389ms ║║Comparison (enum) on did_not_change = true (44ms)
+390ms ║║Condition #6 evaluated true (47ms)
+391ms ║║Condition group #5 evaluated true (state did not change) (48ms)
+393ms ║║Cancelling statement #7's schedules...
+396ms ║║Executed virtual command [Porch Lights Back Porch Lights].wait (0ms)
+397ms ║║Requesting a wake up for Fri, Jun 12 2020 @ 4:46:04 PM EDT (in 180.0s)
+401ms ║╚Execution stage complete. (84ms)
+403ms ║Setting up scheduled job for Fri, Jun 12 2020 @ 4:46:04 PM EDT (in 179.996s)
+413ms ╚Event processed successfully (413ms)
6/12/2020, 4:42:49 PM +735ms
+1ms ╔Received event [AA porch lights virtual switch].switch = off with a delay of 73ms
+114ms ║RunTime Analysis CS &gt; 25ms &gt; PS &gt; 52ms &gt; PE &gt; 38ms &gt; CE
+117ms ║Runtime (37373 bytes) successfully initialized in 52ms (v0.3.110.20191009) (114ms)
+117ms ║╔Execution stage started
+125ms ║║Comparison (enum) off is (string) on = false (1ms)
+126ms ║║Cancelling condition #2's schedules...
+127ms ║║Condition #2 evaluated false (6ms)
+128ms ║║Cancelling condition #1's schedules...
+129ms ║║Condition group #1 evaluated false (state changed) (7ms)
+150ms ║║Comparison (enum) off did_not_change = true (17ms)
+151ms ║║Condition #6 evaluated true (20ms)
+152ms ║║Condition group #5 evaluated true (state did not change) (21ms)
+154ms ║║Cancelling statement #7's schedules...
+159ms ║║Executed virtual command [Porch Lights Back Porch Lights].wait (1ms)
+160ms ║║Requesting a wake up for Fri, Jun 12 2020 @ 4:45:49 PM EDT (in 180.0s)
+164ms ║╚Execution stage complete. (47ms)
+165ms ║Setting up scheduled job for Fri, Jun 12 2020 @ 4:45:49 PM EDT (in 179.996s)
+177ms ╚Event processed successfully (177ms)
6/12/2020, 4:42:49 PM +383ms
+1ms ╔Received event [AA porch lights virtual switch].switch = on with a delay of 58ms
+98ms ║RunTime Analysis CS &gt; 18ms &gt; PS &gt; 41ms &gt; PE &gt; 39ms &gt; CE
+101ms ║Runtime (37374 bytes) successfully initialized in 41ms (v0.3.110.20191009) (99ms)
+102ms ║╔Execution stage started
+109ms ║║Comparison (enum) on is (string) on = true (1ms)
+110ms ║║Cancelling condition #2's schedules...
+111ms ║║Condition #2 evaluated true (6ms)
+112ms ║║Cancelling condition #1's schedules...
+113ms ║║Condition group #1 evaluated true (state changed) (8ms)
+115ms ║║Cancelling statement #3's schedules...
+124ms ║║Skipped execution of physical command [Porch Lights Back Porch Lights].setLevel([88]) because it would make no change to the device. (5ms)
+125ms ║║Executed [Porch Lights Back Porch Lights].setLevel (6ms)
+225ms ║║Comparison (enum) on did_not_change = true (95ms)
+226ms ║║Condition #6 evaluated true (98ms)
+227ms ║║Condition group #5 evaluated true (state did not change) (99ms)
+229ms ║║Cancelling statement #7's schedules...
+232ms ║║Executed virtual command [Porch Lights Back Porch Lights].wait (1ms)
+233ms ║║Requesting a wake up for Fri, Jun 12 2020 @ 4:45:49 PM EDT (in 180.0s)
+237ms ║╚Execution stage complete. (136ms)
+238ms ║Setting up scheduled job for Fri, Jun 12 2020 @ 4:45:49 PM EDT (in 179.996s)
+254ms ╚Event processed successfully (253ms)
6/12/2020, 4:42:28 PM +559ms
+0ms ╔Received event [AA porch lights virtual switch].switch = off with a delay of 46ms
+9888ms ║RunTime Analysis CS &gt; 16ms &gt; PS &gt; 9839ms &gt; PE &gt; 34ms &gt; CE
+9889ms ║Piston waited at a semaphore for 9807ms
+9891ms ║Runtime (37447 bytes) successfully initialized in 9839ms (v0.3.110.20191009) (9890ms)
+9892ms ║╔Execution stage started
+9899ms ║║Comparison (enum) off is (string) on = false (2ms)
+9900ms ║║Cancelling condition #2's schedules...
+9901ms ║║Condition #2 evaluated false (6ms)
+9902ms ║║Cancelling condition #1's schedules...
+9902ms ║║Condition group #1 evaluated false (state changed) (7ms)
+9924ms ║║Comparison (enum) off did_not_change = true (18ms)
+9925ms ║║Condition #6 evaluated true (20ms)
+9926ms ║║Condition group #5 evaluated true (state did not change) (22ms)
+9928ms ║║Cancelling statement #7's schedules...
+9931ms ║║Executed virtual command [Porch Lights Back Porch Lights].wait (0ms)
+9933ms ║║Requesting a wake up for Fri, Jun 12 2020 @ 4:45:38 PM EDT (in 180.0s)
+9936ms ║╚Execution stage complete. (44ms)
+9937ms ║Setting up scheduled job for Fri, Jun 12 2020 @ 4:45:38 PM EDT (in 179.996s)
+9946ms ╚Event processed successfully (9946ms)
6/12/2020, 4:42:28 PM +298ms
+1ms ╔Received event [AA porch lights virtual switch].switch = on with a delay of 54ms
+108ms ║RunTime Analysis CS &gt; 22ms &gt; PS &gt; 40ms &gt; PE &gt; 46ms &gt; CE
+110ms ║Runtime (37375 bytes) successfully initialized in 40ms (v0.3.110.20191009) (108ms)
+111ms ║╔Execution stage started
+118ms ║║Comparison (enum) on is (string) on = true (1ms)
+120ms ║║Cancelling condition #2's schedules...
+121ms ║║Condition #2 evaluated true (5ms)
+122ms ║║Cancelling condition #1's schedules...
+123ms ║║Condition group #1 evaluated true (state changed) (7ms)
+125ms ║║Cancelling statement #3's schedules...
+135ms ║║Skipped execution of physical command [Porch Lights Back Porch Lights].setLevel([88]) because it would make no change to the device. (5ms)
+135ms ║║Executed [Porch Lights Back Porch Lights].setLevel (6ms)
+238ms ║║Comparison (enum) on did_not_change = true (98ms)
+239ms ║║Condition #6 evaluated true (101ms)
+240ms ║║Condition group #5 evaluated true (state did not change) (102ms)
+242ms ║║Cancelling statement #7's schedules...
+245ms ║║Executed virtual command [Porch Lights Back Porch Lights].wait (0ms)
+246ms ║║Requesting a wake up for Fri, Jun 12 2020 @ 4:45:28 PM EDT (in 180.0s)
+250ms ║╚Execution stage complete. (139ms)
+252ms ║Setting up scheduled job for Fri, Jun 12 2020 @ 4:45:28 PM EDT (in 179.996s)
+264ms ╚Event processed successfully (265ms)
6/12/2020, 4:41:51 PM +787ms
+1ms ╔Received event [AA porch lights virtual switch].switch = off with a delay of 266ms
+103ms ║RunTime Analysis CS &gt; 22ms &gt; PS &gt; 42ms &gt; PE &gt; 40ms &gt; CE
+105ms ║Runtime (37374 bytes) successfully initialized in 42ms (v0.3.110.20191009) (103ms)
+106ms ║╔Execution stage started
+114ms ║║Comparison (enum) off is (string) on = false (1ms)
+115ms ║║Cancelling condition #2's schedules...
+116ms ║║Condition #2 evaluated false (6ms)
+117ms ║║Cancelling condition #1's schedules...
+118ms ║║Condition group #1 evaluated false (state changed) (8ms)
+139ms ║║Comparison (enum) off did_not_change = true (17ms)
+140ms ║║Condition #6 evaluated true (20ms)
+141ms ║║Condition group #5 evaluated true (state did not change) (21ms)
+143ms ║║Cancelling statement #7's schedules...
+147ms ║║Executed virtual command [Porch Lights Back Porch Lights].wait (0ms)
+148ms ║║Requesting a wake up for Fri, Jun 12 2020 @ 4:44:51 PM EDT (in 180.0s)
+152ms ║╚Execution stage complete. (46ms)
+154ms ║Setting up scheduled job for Fri, Jun 12 2020 @ 4:44:51 PM EDT (in 179.996s)
+164ms ╚Event processed successfully (164ms)
6/12/2020, 4:41:51 PM +173ms
+1ms ╔Received event [AA porch lights virtual switch].switch = on with a delay of 60ms
+209ms ║RunTime Analysis CS &gt; 18ms &gt; PS &gt; 42ms &gt; PE &gt; 148ms &gt; CE
+211ms ║Runtime (37376 bytes) successfully initialized in 42ms (v0.3.110.20191009) (209ms)
+212ms ║╔Execution stage started
+219ms ║║Comparison (enum) on is (string) on = true (1ms)
+221ms ║║Cancelling condition #2's schedules...
+222ms ║║Condition #2 evaluated true (5ms)
+223ms ║║Cancelling condition #1's schedules...
+223ms ║║Condition group #1 evaluated true (state changed) (8ms)
+226ms ║║Cancelling statement #3's schedules...
+281ms ║║Executed physical command [Porch Lights Back Porch Lights].setLevel([88]) (51ms)
+282ms ║║Executed [Porch Lights Back Porch Lights].setLevel (53ms)
+305ms ║║Comparison (enum) on did_not_change = true (17ms)
+306ms ║║Condition #6 evaluated true (21ms)
+307ms ║║Condition group #5 evaluated true (state did not change) (22ms)
+310ms ║║Cancelling statement #7's schedules...
+314ms ║║Executed virtual command [Porch Lights Back Porch Lights].wait (1ms)
+315ms ║║Requesting a wake up for Fri, Jun 12 2020 @ 4:44:51 PM EDT (in 180.0s)

#16

Thanks for sharing your log!

Notice how at each and every event you see this:
Condition #6 evaluated true

This confirms that “does not change” is broke, and does not function at all.


In other words, your last trigger is an illusion…
The following piston should do the exact same thing…

pic

As long as Switch1 keeps on toggling, then Switch2 will not turn off


#17

If you have an HE system, I’m looking for some testers for the fixes I have for “stays *”

The HE repo is updated. If. you use Hubitat package manager, you need to do a repair on webcore as I have not updated the HPM files to force the update on everyone (but it is available to everyone)


#18

So I have been looking at all this more. I don’t think webCoRE is broken (but there are improvements in labeling I think)

‘did not change’ is a condition. (and it looks backward in time, IT DOES NOT SET A FUTURE TIMER)

  • when the piston runs (because of some other event), it looks backwards in time to see if the variable changed or not within the specified duration (assuming there are enough events (in HE for example, one could set the db that there is very limited history))

  • there is no condition ‘does not change’. (this form of writing suggests a future check, which conditions don’t do)

  • there is a trigger ‘stays unchanged’ which is forward looking in time (IE IT MAY SET A FUTURE TIMER)

    • the first time it is run, it returns FALSE, which means it either initialized the timer requested for a future check OR the timer is already active (but has not occurred)

    • if a change happens, it will cancel the timer (so it will never fire).

    • if no change happens, the timer fires, and the TRUE side of the if xxx ‘stays unchanged’ is executed

      • note the piston is not executed from the top, it picks up at the TRUE side of the if statement

      • THIS MEANS IT IS IMPORTANT TO NOT NEST ‘stays’ COMMANDS IN CODE PATHS THAT MAY NOT EXECUTE on some events (of the device in question), as the TIMER CANCEL or RESETS MAY NOT OCCUR.

        • ie every trigger of the device attribute in question needs to run over this if statement so the timers are managed correctly.

So ‘stays unchanged’ internal method comparison in the code does return TRUE, but internally this is a ‘flag’ that FALSE SHOULD BE RETURNED AND THE TIMER SET IF IT IS NOT ALREADY SET

Here is a simple trigger test of ‘stays unchanged’:

The first time it is run: (NOTE IT RETURNS FALSE - the stays unchanged has not happened yet)

And what it looks like if the timer expires (ie there is no change):

  • also note the bottom time stamp - 15 seconds into the future from the first run
  • ie there were two executions - whatever triggered the first, and then the timer later

Now the bug in webcore I fixed in HE is the trace information is not set correctly for the IDE display (it actually executes correctly, but you see strange things in the IDE). (above have the fix in HE)

  • this leads to a lot of confusion (including my own initially)

The other bug I changed in HE, is how the IDE displays other ‘stays’ commands

For example:

let’s look at simple ‘stays’

ie. if contactDevices’s contact ‘stays’ open for 2 minutes

This really means:

  • if contactDevices’ contact is open now, and stays open for 2 minutes execute the TRUE side of the if

    • again the first run, returns FALSE (and if the contact is open, it sets the timer)
    • if the timer completes, the piston picks up on the TRUE side of the if statement based on the timer
    • if the contact changes, if that event has the piston run over this if statement again, that runner will cancel the timer (and give you a false assuming the contact is NOT OPEN)

03%20AM

So I changed a couple of things

  • the IDE trace fix above is in place
  • I changed the wording to be accurate;
    • to set the timer, the attribute must be the requested value

Do something only if location mode has been set to Away for 3 minutes
Entrance hallway lighting - optimize piston(s)
Light on with contact sensor, off quickly unless motion
'stays open' evaluating true when it's not true
Piston continues to execute even arguments not met
Close garage door if there's no motion
"Stays away from" and "Stays any of" triggers unexpected behavior
Issues with "are now and stays inactive" on latest patch
All of a sudden piston if/then statement not working correctly
Door contact open then close notifications. help!
Controlling Cielo Breez Plus with Window/Door Sensors
#19

Belatedly picking up on this. I see things differently. The problem, in the ST version at least, is that a change does not cancel the timer.

If you consider something like vswitch4's switch stays on for 15 seconds, the comparison that is actually used is the equivalent of is on. So first time round if vswitch4 is on that will return true and a 15 second timer is started.

Now supposing five seconds later the piston runs again and vswitch4 is now off. The comparison now returns false and that is what ‘cancels’ the timer (I’d imagine the timer actually still occurs but there is nothing to do when it does, so lets call it cancelled).

Without making that comparison there is no way the piston can know that vswitch4 is no longer on. The piston could be running because it reported on again, or the Test button was pressed, or for any number of other reasons that don’t require the timer to be cancelled because vswitch4 is still on

When it comes to vswitch4's switch stays unchanged for 15 seconds the comparison used is actually return true. So first time around the timer starts, but if vswitch4 does change in the next 15 seconds there is no way the comparison can return false to cancel the timer. No test is actually being made to see if vswitch4 is still the same or not.

The bottom line is that it doesn’t work.


#20

I read this through twice and I still don’t think I get it all completely. But the bottom line is that we should not use stays unchanged right?


#21

My understanding of the way ‘stays’ works and my reading of the code suggests that ‘stays unchanged’ doesn’t detect when there are changes and so doesn’t work.

My testing of it a few minutes ago suggests that indeed it doesn’t work.