Light stays on even after no motion is detected


#1

1) Give a description of the problem
I’ve created this simple piston where when no motion is detected it suppose to turn off office light.

2) What is the expected behaviour?
While there’s motion do not turn off the light. I’m sure there’s something obvious that I missed :smirk:

3) What is happening/not happening?
But for some reason after 2 minutes light continues to stay on. I’ve tried with 10 minutes but got same results.

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


5) Attach logs after turning logging level to Full
12/26/2019, 10:02:06 AM +171ms
+1ms ╔Received event [Office Sensor].motion = active with a delay of 279ms
+127ms ║RunTime Analysis CS > 22ms > PS > 51ms > PE > 53ms > CE
+129ms ║Runtime (37905 bytes) successfully initialized in 51ms (v0.3.110.20191009) (127ms)
+130ms ║╔Execution stage started
+137ms ║║Comparison (enum) active is (string) active = true (1ms)
+139ms ║║Cancelling condition #9’s schedules…
+140ms ║║Condition #9 evaluated true (5ms)
+141ms ║║Cancelling condition #1’s schedules…
+141ms ║║Condition group #1 evaluated true (state changed) (8ms)
+143ms ║║Cancelling statement #3’s schedules…
+149ms ║║Skipped execution of physical command [Office Light].on([]) because it would make no change to the device. (2ms)
+150ms ║║Executed [Office Light].on (4ms)
+152ms ║╚Execution stage complete. (23ms)
+153ms ╚Event processed successfully (153ms)
12/26/2019, 9:50:53 AM +741ms
+2ms ╔Received event [Office Sensor].motion = inactive with a delay of 207ms
+113ms ║RunTime Analysis CS > 21ms > PS > 42ms > PE > 50ms > CE
+115ms ║Runtime (37900 bytes) successfully initialized in 42ms (v0.3.110.20191009) (112ms)
+116ms ║╔Execution stage started
+124ms ║║Comparison (enum) inactive is (string) active = false (2ms)
+125ms ║║Cancelling condition #9’s schedules…
+126ms ║║Condition #9 evaluated false (6ms)
+127ms ║║Cancelling condition #1’s schedules…
+128ms ║║Condition group #1 evaluated false (state changed) (8ms)
+129ms ║║Condition group #10 evaluated true (state did not change) (0ms)
+151ms ║║Comparison (enum) inactive did_not_change = false (18ms)
+152ms ║║Condition #14 evaluated false (21ms)
+153ms ║║Condition group #12 evaluated false (state did not change) (22ms)
+155ms ║╚Execution stage complete. (39ms)
+156ms ╚Event processed successfully (156ms)
12/26/2019, 9:50:37 AM +108ms
+2ms ╔Received event [Office Sensor].motion = active with a delay of 156ms
+169ms ║RunTime Analysis CS > 31ms > PS > 88ms > PE > 49ms > CE
+171ms ║Runtime (37905 bytes) successfully initialized in 88ms (v0.3.110.20191009) (169ms)
+172ms ║╔Execution stage started
+179ms ║║Comparison (enum) active is (string) active = true (1ms)
+180ms ║║Cancelling condition #9’s schedules…
+181ms ║║Condition #9 evaluated true (5ms)
+182ms ║║Cancelling condition #1’s schedules…
+183ms ║║Condition group #1 evaluated true (state changed) (7ms)
+185ms ║║Cancelling statement #3’s schedules…
+191ms ║║Skipped execution of physical command [Office Light].on([]) because it would make no change to the device. (2ms)
+192ms ║║Executed [Office Light].on (4ms)
+194ms ║╚Execution stage complete. (22ms)
+195ms ╚Event processed successfully (195ms)
12/26/2019, 9:49:52 AM +715ms
+1ms ╔Received event [Office Sensor].motion = inactive with a delay of 189ms
+122ms ║RunTime Analysis CS > 24ms > PS > 50ms > PE > 49ms > CE
+125ms ║Runtime (37900 bytes) successfully initialized in 50ms (v0.3.110.20191009) (123ms)
+126ms ║╔Execution stage started
+133ms ║║Comparison (enum) inactive is (string) active = false (1ms)
+135ms ║║Cancelling condition #9’s schedules…
+136ms ║║Condition #9 evaluated false (5ms)
+137ms ║║Cancelling condition #1’s schedules…
+137ms ║║Condition group #1 evaluated false (state changed) (8ms)
+139ms ║║Condition group #10 evaluated true (state did not change) (0ms)
+168ms ║║Comparison (enum) inactive did_not_change = false (24ms)
+169ms ║║Condition #14 evaluated false (28ms)
+170ms ║║Condition group #12 evaluated false (state did not change) (30ms)
+172ms ║╚Execution stage complete. (47ms)
+174ms ╚Event processed successfully (173ms)
12/26/2019, 9:48:10 AM +697ms
+2ms ╔Received event [Office Sensor].motion = active with a delay of 134ms
+110ms ║RunTime Analysis CS > 20ms > PS > 42ms > PE > 48ms > CE
+112ms ║Runtime (37905 bytes) successfully initialized in 42ms (v0.3.110.20191009) (110ms)
+113ms ║╔Execution stage started
+121ms ║║Comparison (enum) active is (string) active = true (1ms)
+122ms ║║Cancelling condition #9’s schedules…
+123ms ║║Condition #9 evaluated true (6ms)
+124ms ║║Cancelling condition #1’s schedules…
+125ms ║║Condition group #1 evaluated true (state changed) (7ms)
+127ms ║║Cancelling statement #3’s schedules…
+132ms ║║Skipped execution of physical command [Office Light].on([]) because it would make no change to the device. (2ms)
+133ms ║║Executed [Office Light].on (3ms)
+135ms ║╚Execution stage complete. (22ms)
+136ms ╚Event processed successfully (136ms)
12/26/2019, 9:47:08 AM +640ms
+1ms ╔Received event [Office Sensor].motion = inactive with a delay of 156ms
+91ms ║RunTime Analysis CS > 13ms > PS > 35ms > PE > 43ms > CE
+93ms ║Runtime (37899 bytes) successfully initialized in 35ms (v0.3.110.20191009) (92ms)
+94ms ║╔Execution stage started
+102ms ║║Comparison (enum) inactive is (string) active = false (1ms)
+103ms ║║Cancelling condition #9’s schedules…
+104ms ║║Condition #9 evaluated false (6ms)
+105ms ║║Cancelling condition #1’s schedules…
+105ms ║║Condition group #1 evaluated false (state changed) (7ms)
+107ms ║║Condition group #10 evaluated true (state did not change) (0ms)
+208ms ║║Comparison (enum) inactive did_not_change = false (98ms)
+209ms ║║Condition #14 evaluated false (101ms)
+210ms ║║Condition group #12 evaluated false (state did not change) (102ms)
+212ms ║╚Execution stage complete. (118ms)
+213ms ╚Event processed successfully (213ms)
12/26/2019, 9:46:33 AM +998ms
+2ms ╔Received event [Office Sensor].motion = active with a delay of 144ms
+121ms ║RunTime Analysis CS > 29ms > PS > 44ms > PE > 48ms > CE
+123ms ║Runtime (37905 bytes) successfully initialized in 44ms (v0.3.110.20191009) (120ms)
+124ms ║╔Execution stage started
+132ms ║║Comparison (enum) active is (string) active = true (1ms)
+133ms ║║Cancelling condition #9’s schedules…
+134ms ║║Condition #9 evaluated true (6ms)
+135ms ║║Cancelling condition #1’s schedules…
+136ms ║║Condition group #1 evaluated true (state changed) (8ms)
+138ms ║║Cancelling statement #3’s schedules…
+144ms ║║Skipped execution of physical command [Office Light].on([]) because it would make no change to the device. (2ms)
+145ms ║║Executed [Office Light].on (3ms)
+147ms ║╚Execution stage complete. (23ms)
+148ms ╚Event processed successfully (148ms)
12/26/2019, 9:45:39 AM +695ms
+0ms ╔Received event [Office Sensor].motion = inactive with a delay of 129ms
+95ms ║RunTime Analysis CS > 18ms > PS > 33ms > PE > 45ms > CE
+97ms ║Runtime (37899 bytes) successfully initialized in 33ms (v0.3.110.20191009) (96ms)
+98ms ║╔Execution stage started
+105ms ║║Comparison (enum) inactive is (string) active = false (1ms)
+107ms ║║Cancelling condition #9’s schedules…
+108ms ║║Condition #9 evaluated false (5ms)
+109ms ║║Cancelling condition #1’s schedules…
+109ms ║║Condition group #1 evaluated false (state changed) (7ms)
+111ms ║║Condition group #10 evaluated true (state did not change) (0ms)
+136ms ║║Comparison (enum) inactive did_not_change = false (22ms)
+137ms ║║Condition #14 evaluated false (25ms)
+138ms ║║Condition group #12 evaluated false (state did not change) (26ms)
+140ms ║╚Execution stage complete. (42ms)
+141ms ╚Event processed successfully (141ms)
12/26/2019, 9:45:14 AM +482ms
+1ms ╔Received event [Office Sensor].motion = active with a delay of 127ms
+105ms ║RunTime Analysis CS > 27ms > PS > 32ms > PE > 45ms > CE
+107ms ║Runtime (37905 bytes) successfully initialized in 32ms (v0.3.110.20191009) (106ms)
+108ms ║╔Execution stage started
+115ms ║║Comparison (enum) active is (string) active = true (1ms)
+117ms ║║Cancelling condition #9’s schedules…
+117ms ║║Condition #9 evaluated true (5ms)
+118ms ║║Cancelling condition #1’s schedules…
+119ms ║║Condition group #1 evaluated true (state changed) (8ms)
+121ms ║║Cancelling statement #3’s schedules…
+126ms ║║Skipped execution of physical command [Office Light].on([]) because it would make no change to the device. (2ms)
+127ms ║║Executed [Office Light].on (4ms)
+129ms ║╚Execution stage complete. (21ms)
+130ms ╚Event processed successfully (130ms)
12/26/2019, 9:44:19 AM +546ms
+1ms ╔Received event [Office Sensor].motion = inactive with a delay of 160ms
+225ms ║RunTime Analysis CS > 21ms > PS > 157ms > PE > 48ms > CE
+227ms ║Runtime (37902 bytes) successfully initialized in 157ms (v0.3.110.20191009) (225ms)
+228ms ║╔Execution stage started
+236ms ║║Comparison (enum) inactive is (string) active = false (1ms)
+238ms ║║Cancelling condition #9’s schedules…
+239ms ║║Condition #9 evaluated false (6ms)
+240ms ║║Cancelling condition #1’s schedules…
+241ms ║║Condition group #1 evaluated false (state changed) (8ms)
+242ms ║║Condition group #10 evaluated true (state did not change) (1ms)
+340ms ║║Comparison (enum) inactive did_not_change = false (94ms)
+342ms ║║Condition #14 evaluated false (98ms)
+343ms ║║Condition group #12 evaluated false (state did not change) (99ms)
+345ms ║╚Execution stage complete. (117ms)
+346ms ╚Event processed successfully (346ms)
12/26/2019, 9:44:05 AM +708ms
+1ms ╔Received event [Office Sensor].motion = active with a delay of 1477ms
+126ms ║RunTime Analysis CS > 24ms > PS > 45ms > PE > 56ms > CE
+128ms ║Runtime (37906 bytes) successfully initialized in 45ms (v0.3.110.20191009) (126ms)
+129ms ║╔Execution stage started
+137ms ║║Comparison (enum) active is (string) active = true (2ms)
+138ms ║║Cancelling condition #9’s schedules…
+139ms ║║Condition #9 evaluated true (6ms)
+140ms ║║Cancelling condition #1’s schedules…
+141ms ║║Condition group #1 evaluated true (state changed) (8ms)
+143ms ║║Cancelling statement #3’s schedules…
+150ms ║║Skipped execution of physical command [Office Light].on([]) because it would make no change to the device. (3ms)
+151ms ║║Executed [Office Light].on (4ms)
+153ms ║╚Execution stage complete. (24ms)
+154ms ╚Event processed successfully (154ms)
12/26/2019, 9:44:04 AM +972ms
+0ms ╔Received event [Office Sensor].motion = inactive with a delay of 781ms
+95ms ║RunTime Analysis CS > 17ms > PS > 33ms > PE > 46ms > CE
+98ms ║Runtime (37899 bytes) successfully initialized in 33ms (v0.3.110.20191009) (96ms)
+99ms ║╔Execution stage started
+106ms ║║Comparison (enum) inactive is (string) active = false (1ms)
+107ms ║║Cancelling condition #9’s schedules…
+108ms ║║Condition #9 evaluated false (5ms)
+109ms ║║Cancelling condition #1’s schedules…
+110ms ║║Condition group #1 evaluated false (state changed) (8ms)
+111ms ║║Condition group #10 evaluated true (state did not change) (0ms)
+132ms ║║Comparison (enum) inactive did_not_change = false (17ms)
+134ms ║║Condition #14 evaluated false (20ms)
+135ms ║║Condition group #12 evaluated false (state did not change) (21ms)
+137ms ║╚Execution stage complete. (38ms)
+138ms ╚Event processed successfully (137ms)
12/26/2019, 9:43:48 AM +560ms
+1ms ╔Received event [Office Sensor].motion = active with a delay of 214ms
+266ms ║RunTime Analysis CS > 21ms > PS > 200ms > PE > 44ms > CE
+268ms ║Runtime (37907 bytes) successfully initialized in 200ms (v0.3.110.20191009) (266ms)
+269ms ║╔Execution stage started
+276ms ║║Comparison (enum) active is (string) active = true (1ms)
+278ms ║║Cancelling condition #9’s schedules…
+278ms ║║Condition #9 evaluated true (5ms)
+279ms ║║Cancelling condition #1’s schedules…
+280ms ║║Condition group #1 evaluated true (state changed) (7ms)
+282ms ║║Cancelling statement #3’s schedules…
+287ms ║║Skipped execution of physical command [Office Light].on([]) because it would make no change to the device. (2ms)
+288ms ║║Executed [Office Light].on (3ms)
+290ms ║╚Execution stage complete. (21ms)
+291ms ╚Event processed successfully (291ms)
12/26/2019, 9:43:39 AM +852ms
+1ms ╔Received event [Office Sensor].motion = inactive with a delay of 125ms
+110ms ║RunTime Analysis CS > 21ms > PS > 44ms > PE > 46ms > CE
+112ms ║Runtime (37900 bytes) successfully initialized in 44ms (v0.3.110.20191009) (110ms)
+113ms ║╔Execution stage started
+120ms ║║Comparison (enum) inactive is (string) active = false (1ms)
+121ms ║║Cancelling condition #9’s schedules…
+122ms ║║Condition #9 evaluated false (5ms)
+123ms ║║Cancelling condition #1’s schedules…
+123ms ║║Condition group #1 evaluated false (state changed) (7ms)
+125ms ║║Condition group #10 evaluated true (state did not change) (0ms)
+260ms ║║Comparison (enum) inactive did_not_change = false (132ms)
+261ms ║║Condition #14 evaluated false (135ms)
+262ms ║║Condition group #12 evaluated false (state did not change) (136ms)
+264ms ║╚Execution stage complete. (151ms)
+265ms ╚Event processed successfully (265ms)
12/26/2019, 9:43:20 AM +735ms
+2ms ╔Received event [Office Sensor].motion = active with a delay of 133ms
+125ms ║RunTime Analysis CS > 23ms > PS > 52ms > PE > 50ms > CE
+128ms ║Runtime (37905 bytes) successfully initialized in 52ms (v0.3.110.20191009) (125ms)
+128ms ║╔Execution stage started
+136ms ║║Comparison (enum) active is (string) active = true (2ms)
+137ms ║║Cancelling condition #9’s schedules…
+138ms ║║Condition #9 evaluated true (6ms)
+139ms ║║Cancelling condition #1’s schedules…
+140ms ║║Condition group #1 evaluated true (state changed) (8ms)
+142ms ║║Cancelling statement #3’s schedules…
+148ms ║║Skipped execution of physical command [Office Light].on([]) because it would make no change to the device. (1ms)
+148ms ║║Executed [Office Light].on (3ms)
+151ms ║╚Execution stage complete. (22ms)
+152ms ╚Event processed successfully (151ms)


#2

Suspect the inital cause here to be that your line 28 is nested in the first IF block. You want to pull that out from the first IF since the second action does no react to the first action.

From there we are looking for a trigger to turn off the light. Notice how there is no lighting bolt next to line 28, meaning its a condition. Also we would want a bit more exact trigger so, I would change that to “stays inactive for x minutes”


#3

Agree with @SergL. I would also consider a change in your trigger…

If Motion Sensor 1's motion changes to active
  Then
    Turn light on
  End If

If Motion Sensor 1's motion stays inactive for 2 minutes
  Then
    Turn light off
  End If

#4

Thanks guys for the replies!

I think I was able re-create what you guys suggested but the light still stays on even after no motion is detected past 2 minutes ?

12/26/2019, 1:54:43 PM +674ms
+1ms ╔Starting piston... (v0.3.110.20191009)
+200ms ║╔Subscribing to devices...
+243ms ║║Subscribing to Office Sensor.motion...
+334ms ║║Subscribing to Office Light...
+335ms ║╚Finished subscribing (151ms)
+366ms ║Cancelling condition #1's schedules...
+380ms ║Comparison (enum) active stays (string) inactive = false (2ms)
+393ms ╚Piston successfully started (391ms)
12/26/2019, 1:54:17 PM +624ms
+1ms ╔Received event [Office Sensor].motion = active with a delay of 128ms
+94ms ║RunTime Analysis CS > 18ms > PS > 33ms > PE > 43ms > CE
+96ms ║Runtime (38259 bytes) successfully initialized in 33ms (v0.3.110.20191009) (94ms)
+97ms ║╔Execution stage started
+101ms ║║Condition group #1 evaluated true (state did not change) (0ms)
+107ms ║║Comparison (enum) active is (string) active = true (1ms)
+108ms ║║Cancelling condition #14's schedules...
+109ms ║║Condition #14 evaluated true (5ms)
+110ms ║║Cancelling condition #3's schedules...
+110ms ║║Condition group #3 evaluated true (state changed) (7ms)
+111ms ║║Cancelling statement #3's schedules...
+117ms ║║Skipped execution of physical command [Office Light].on([]) because it would make no change to the device. (3ms)
+118ms ║║Executed [Office Light].on (4ms)
+120ms ║╚Execution stage complete. (23ms)
+121ms ╚Event processed successfully (121ms)
12/26/2019, 1:54:01 PM +526ms
+2ms ╔Received event [Office Sensor].motion = inactive with a delay of 1042ms
+146ms ║RunTime Analysis CS > 38ms > PS > 50ms > PE > 57ms > CE
+148ms ║Runtime (38259 bytes) successfully initialized in 50ms (v0.3.110.20191009) (146ms)
+149ms ║╔Execution stage started
+153ms ║║Condition group #1 evaluated true (state did not change) (1ms)
+158ms ║║Comparison (enum) inactive is (string) active = false (1ms)
+160ms ║║Cancelling condition #14's schedules...
+161ms ║║Condition #14 evaluated false (6ms)
+162ms ║║Cancelling condition #3's schedules...
+163ms ║║Condition group #3 evaluated false (state changed) (7ms)
+165ms ║╚Execution stage complete. (16ms)
+166ms ╚Event processed successfully (166ms)
12/26/2019, 1:53:42 PM +977ms
+1ms ╔Received event [Office Sensor].motion = active with a delay of 122ms
+98ms ║RunTime Analysis CS > 20ms > PS > 35ms > PE > 42ms > CE
+100ms ║Runtime (38259 bytes) successfully initialized in 35ms (v0.3.110.20191009) (98ms)
+101ms ║╔Execution stage started
+105ms ║║Condition group #1 evaluated true (state did not change) (1ms)
+110ms ║║Comparison (enum) active is (string) active = true (1ms)
+111ms ║║Cancelling condition #14's schedules...
+112ms ║║Condition #14 evaluated true (5ms)
+113ms ║║Cancelling condition #3's schedules...
+114ms ║║Condition group #3 evaluated true (state changed) (8ms)
+115ms ║║Cancelling statement #3's schedules...
+120ms ║║Skipped execution of physical command [Office Light].on([]) because it would make no change to the device. (2ms)
+121ms ║║Executed [Office Light].on (4ms)
+123ms ║╚Execution stage complete. (22ms)
+124ms ╚Event processed successfully (124ms)

#5

Take your second IF out from under the ELSE and make it an IF statement by itself.


#7

@JohnnyBeGood, Here is a green shot that you can load with the code nxsp. You will need to insert your motion sensor device and your light device.


#8

Thanks! It worked few time when I tested last night before I had to leave the home. Only one time when the light was off the sensor would not pick up my motion but that has nothing to do with this piston.

I guess my problem was that I could not see option to add second IF so I had to duplicate first IF.
Where would I create another IF action when starting new piston?


#9

Finally figured it out :man_facepalming: Below is another IF I was missing