Need advice on trigger not triggering


#1

1) Give a description of the problem
I’m designing a piston that will switch on the lights for a period of time on motion, and extend that period if there is subsequent motion. However, I want to also allow the lights to be controlled manually to avoid the requirement to keep moving around in the room. As far as that goes, all is fine with the piston below.

The problem occurred when I tried to add code to handle the situation where you trigger the motion, but decide you want manual control and hence not have the lights controlled by motion. My method of initiating this would be to turn off the lights using the switch once you have triggered them with motion, and then back on with the switch, at which point the lights would stay on until switched off by the switch.

I added the ‘if White Bulb 1’s switch changes away from on’ trigger to achieve this.

2) What is the expected behaviour?
The lights would go off (due to the switch press) and the control variable would be set to false so that the piston stopped controlling the lights.

3) What is happening/not happening?
The ‘if White Bulb 1’s switch changes away from on’ trigger below is not executed on switch press, until the piston is fired 60 seconds after motion ceases (by the ‘if Motion Sensor 1’s motion stays away from active for 60 seconds’ trigger) - this is when webCoRE has scheduled the next job to run according to the logs. It is behaving as if webCoRE is not subscribing to White Bulb 1’s switch (but there is a lightning bolt in the UI)

**4) Post a Green Snapshot of the piston![image|45x37]

5) Attach logs after turning logging level to Full
24/05/2020, 14:14:47 +474ms
+2ms ╔Received event [Bathroom Lights].switch = off with a delay of 60ms
+125ms ║RunTime Analysis CS > 20ms > PS > 64ms > PE > 40ms > CE
+127ms ║Runtime (43694 bytes) successfully initialized in 64ms (v0.3.10a.20190223) (124ms)
+128ms ║╔Execution stage started
+139ms ║║Condition #2 evaluated false (7ms)
+140ms ║║Condition group #1 evaluated false (state did not change) (8ms)
+145ms ║║Comparison (enum) off changes_away_from (string) on = true (0ms)
+147ms ║║Cancelling condition #45’s schedules…
+148ms ║║Condition #45 evaluated true (4ms)
+149ms ║║Cancelling condition #44’s schedules…
+150ms ║║Condition group #44 evaluated true (state changed) (7ms)
+152ms ║║Cancelling statement #46’s schedules…
+159ms ║║Executed virtual command [Bathroom Lights].setVariable (3ms)
+170ms ║║Comparison (enum) inactive stays_away_from (string) active = true (3ms)
+174ms ║║Adding a timed trigger schedule for condition 38
+176ms ║║Cancelling condition #38’s schedules…
+177ms ║║Condition #38 evaluated false (15ms)
+178ms ║║Cancelling condition #15’s schedules…
+179ms ║║Condition group #15 evaluated false (state changed) (18ms)
+182ms ║╚Execution stage complete. (53ms)
+183ms ║Setting up scheduled job for Sun, May 24 2020 @ 2:15:47 PM BST (in 59.992s)
+191ms ╚Event processed successfully (191ms)
24/05/2020, 14:14:43 +100ms
+1ms ╔Received event [Home].time = 1590326084176 with a delay of -1076ms
+133ms ║RunTime Analysis CS > 19ms > PS > 69ms > PE > 45ms > CE
+136ms ║Runtime (43700 bytes) successfully initialized in 69ms (v0.3.10a.20190223) (135ms)
+137ms ║╔Execution stage started
+159ms ║║Cancelling condition #38’s schedules…
+160ms ║║Condition #38 evaluated true (2ms)
+164ms ║║Comparison (dynamic) true is (boolean) true = true (1ms)
+166ms ║║Cancelling condition #39’s schedules…
+167ms ║║Condition #39 evaluated true (5ms)
+168ms ║║Cancelling condition #15’s schedules…
+169ms ║║Condition group #15 evaluated true (state changed) (10ms)
+171ms ║║Cancelling statement #17’s schedules…
+188ms ║║Executed physical command [Bathroom Lights].off() (13ms)
+189ms ║║Executed [Bathroom Lights].off (15ms)
+194ms ║║Executed virtual command [Bathroom Lights].setVariable (3ms)
+197ms ║╚Execution stage complete. (61ms)
+198ms ╚Event processed successfully (198ms)
24/05/2020, 14:13:44 +21ms
+1ms ╔Received event [Bathroom TriSensor].motion = inactive with a delay of 55ms
+120ms ║RunTime Analysis CS > 21ms > PS > 62ms > PE > 38ms > CE
+122ms ║Runtime (43706 bytes) successfully initialized in 62ms (v0.3.10a.20190223) (120ms)
+123ms ║╔Execution stage started
+130ms ║║Comparison (enum) inactive changes_away_from (string) inactive = false (1ms)
+131ms ║║Condition #2 evaluated false (4ms)
+132ms ║║Condition group #1 evaluated false (state did not change) (5ms)
+143ms ║║Condition #45 evaluated false (8ms)
+144ms ║║Condition group #44 evaluated false (state did not change) (10ms)
+151ms ║║Comparison (enum) inactive stays_away_from (string) active = true (1ms)
+155ms ║║Adding a timed trigger schedule for condition 38
+157ms ║║Condition #38 evaluated false (9ms)
+158ms ║║Condition group #15 evaluated false (state did not change) (11ms)
+159ms ║╚Execution stage complete. (36ms)
+161ms ║Setting up scheduled job for Sun, May 24 2020 @ 2:14:44 PM BST (in 59.995s)
+169ms ╚Event processed successfully (169ms)
24/05/2020, 14:13:42 +582ms
+2ms ╔Received event [Bathroom Lights].switch = on with a delay of 59ms
+119ms ║RunTime Analysis CS > 20ms > PS > 60ms > PE > 39ms > CE
+121ms ║Runtime (43696 bytes) successfully initialized in 60ms (v0.3.10a.20190223) (118ms)
+122ms ║╔Execution stage started
+133ms ║║Cancelling condition #2’s schedules…
+134ms ║║Condition #2 evaluated false (8ms)
+135ms ║║Cancelling condition #1’s schedules…
+136ms ║║Condition group #1 evaluated false (state changed) (10ms)
+141ms ║║Comparison (enum) on changes_away_from (string) on = false (0ms)
+143ms ║║Condition #45 evaluated false (4ms)
+144ms ║║Condition group #44 evaluated false (state did not change) (6ms)
+152ms ║║Comparison (enum) active stays_away_from (string) active = false (1ms)
+153ms ║║Cancelling any timed trigger schedules for condition 38
+154ms ║║Cancelling statement #38’s schedules…
+155ms ║║Condition #38 evaluated false (9ms)
+156ms ║║Condition group #15 evaluated false (state did not change) (10ms)
+158ms ║╚Execution stage complete. (36ms)
+159ms ╚Event processed successfully (159ms)
24/05/2020, 14:13:38 +120ms
+2ms ╔Received event [Bathroom TriSensor].motion = active with a delay of 55ms
+118ms ║RunTime Analysis CS > 20ms > PS > 63ms > PE > 35ms > CE
+120ms ║Runtime (43706 bytes) successfully initialized in 63ms (v0.3.10a.20190223) (117ms)
+121ms ║╔Execution stage started
+128ms ║║Comparison (enum) active changes_away_from (string) inactive = true (0ms)
+129ms ║║Cancelling condition #2’s schedules…
+130ms ║║Condition #2 evaluated true (4ms)
+138ms ║║Comparison (enum) off is (string) off = true (1ms)
+139ms ║║Cancelling condition #10’s schedules…
+140ms ║║Condition #10 evaluated true (9ms)
+148ms ║║Comparison (integer) 1181 is_less_than (integer) 10000 = true (2ms)
+149ms ║║Condition #11 evaluated true (8ms)
+150ms ║║Cancelling condition #9’s schedules…
+151ms ║║Condition group #9 evaluated true (state changed) (20ms)
+152ms ║║Condition group #8 evaluated true (state did not change) (21ms)
+153ms ║║Cancelling condition #1’s schedules…
+154ms ║║Condition group #1 evaluated true (state changed) (28ms)
+156ms ║║Cancelling statement #3’s schedules…
+157ms ║║Skipping task 34 because of mode restrictions
+173ms ║║Executed physical command [Bathroom Lights].setLevel([80]) (14ms)
+174ms ║║Executed [Bathroom Lights].setLevel (15ms)
+184ms ║║Executed physical command [Bathroom Lights].on() (8ms)
+185ms ║║Executed [Bathroom Lights].on (9ms)
+190ms ║║Executed virtual command [Bathroom Lights].setVariable (2ms)
+196ms ║║Cancelling condition #45’s schedules…
+197ms ║║Condition #45 evaluated false (5ms)
+198ms ║║Cancelling condition #44’s schedules…
+199ms ║║Condition group #44 evaluated false (state changed) (7ms)
+205ms ║║Comparison (enum) active stays_away_from (string) active = false (1ms)
+207ms ║║Cancelling any timed trigger schedules for condition 38
+208ms ║║Cancelling statement #38’s schedules…
+208ms ║║Cancelling condition #38’s schedules…
+209ms ║║Condition #38 evaluated false (8ms)
+210ms ║║Condition group #15 evaluated false (state did not change) (9ms)
+212ms ║╚Execution stage complete. (91ms)
+213ms ╚Event processed successfully (213ms)


#2

I wonder if it is because you set your variables after you change the switch state. As soon as you change the state that fires the piston again. Perhaps you should change the variable before you program the switch.


#3

The logs show the piston responding to the switch changing on at 14:13:42 and off at 14:14:47 and takes the appropriate response both times. So it is definitely subscribed. The switch doesn’t turn off (go away from on) until it is done by the lack of motion so I’m not sure why you don’t think it is subscribed. The switch is still on when the inactive trigger occurs since it executes the off command.


#4

Thanks - I will give that a try.


#5

But I physically set the switch to off at 14:14:00 in this case, and was expecting to see the variable become set to false then, but that didn’t happen until 14:14:47 as you say. I don’t really know if that is the physical action at 14:14:00 delayed or just because the piston turned off the lights after 60 seconds of no motion? I have tried moving this trigger to various points in the script, and also using ‘on events from’ the switch unsuccessfully.

By the way, when I run a trace on the piston, I never see the green bar go into the section where the troublesome trigger is :frowning:


#6

Have you tries ‘changes to off’ instead of ‘changes away from on’? Either way, if you actually turned it off at 14:14:00, it should have been picked up but it still seemed to be on when the timer expired. Can you look in ST for the device recent activity and confirm the switch turned off at 14:14:00?


#7

There is no off / on event being received from the switch. What exactly is the hardware?

The piston seems to be written for a smart switch controlling a dumb bulb.

The logs are more suggestive of a dumb switch controlling a smart bulb.


#8

Thanks for your replies both. You are both right in that there was no event recorded in ST for the switch being switched off physically, or back on for that matter. So that probably explains it!

The hardware is a Qubino Flush Dimmer with the lights and a retractive switch connected. I couldn’t get Eric Maycock (@erocm1231)'s Device Handler that I usually use for Qubino kit to work with this one, possibly because it is an older device that I bought from eBay (the newer replacement, the Qubino Mini Dimmer doesn’t have the 2-way switch control that I needed and the original Flush Dimmer is out of stock everywhere, so I assume it’s discontinued). So I am using a Device Handler that I cobbled together from the ST Z-Wave Metering Dimmer and Eric’s one. The temperature sensing still doesn’t work quite right with this one.

After reading your comments I did some further experiments without webCoRE in the picture and found that state changes using the physical switch don’t report to ST unless I force a refresh - so I assume the issue is with my dodgy handler. I will cobble it further!

Thanks a lot for your help, guys :slight_smile: