Help with lighting piston


#1

1) Give a description of the problem
lights not going out when lux level rises above 25

2) What is the expected behaviour?
between sunrise and sunset if i enter the room and the motion detector triggers the lights. once i open the blinds and the lux level increases then after 10 minutes the lights should go off. i would have expected it to need the motion AND lux <= 25 to reset the timer

3) What is happening/not happening?
the wait counter keeps resetting to 10 minutes every time the motion detector is triggered thus never turning the lights off once its light.

4) Post a Green Snapshot of the pistonimage

5) Attach any logs (From ST IDE and by turning logging level to Full)
23/09/2018, 08:58:21 +190ms
+2ms â•”Received event [Living Room Motion Sensor].motion = inactive with a delay of 1108ms
+128ms â•‘RunTime Analysis CS > 15ms > PS > 65ms > PE > 47ms > CE
+131ms â•‘Runtime (48949 bytes) successfully initialized in 65ms (v0.3.108.20180906) (128ms)
+132ms â•‘â•”Execution stage started
+142ms â•‘â•‘Comparison (string) :46cc155878d3427fe608e136b52dbd53: is_any_of (string) :46cc155878d3427fe608e136b52dbd53:,:7429bcb2a229229d6f1c1e6659102d4a: = true (2ms)
+144ms â•‘â•‘Condition #11 evaluated true (6ms)
+161ms â•‘â•‘Comparison (enum) closed is (string) closed = true (1ms)
+162ms â•‘â•‘Condition #36 evaluated true (17ms)
+164ms ║║Cancelling condition #1’s schedules…
+165ms â•‘â•‘Condition group #1 evaluated true (state changed) (28ms)
+175ms â•‘â•‘Comparison (integer) 34 is_less_than_or_equal_to (integer) 25 = false (2ms)
+177ms â•‘â•‘Condition #41 evaluated false (11ms)
+179ms ║║Cancelling condition #1’s schedules…
+180ms â•‘â•‘Condition group #1 evaluated false (state changed) (13ms)
+183ms ║║Cancelling statement #2’s schedules…
+189ms â•‘â•‘Executed virtual command [Living Room lamp 1, Living Room lamp 2, Living Room lamp 3].wait (1ms)
+191ms â•‘â•‘Requesting a wake up for Sun, Sep 23 2018 @ 9:08:21 AM BST (in 600.0s)
+204ms â•‘â•‘Comparison (string) :46cc155878d3427fe608e136b52dbd53: is_any_of (string) :2ebc15aa88871a4a84bd355812b2a6b6:,:c18aa990a7e4a353526560987df11955:,:22e263f6fea9d0017b40c2a0afbed100:,:7429bcb2a229229d6f1c1e6659102d4a: = false (4ms)
+206ms â•‘â•‘Condition #22 evaluated false (8ms)
+207ms â•‘â•‘Condition group #13 evaluated false (state did not change) (11ms)
+215ms â•‘â•‘Comparison (string) :46cc155878d3427fe608e136b52dbd53: is (string) :9ed33657c6130d8602b092ce335983cb: = false (3ms)
+217ms â•‘â•‘Condition #34 evaluated false (6ms)
+218ms â•‘â•‘Condition group #24 evaluated false (state did not change) (8ms)
+221ms ║╚Execution stage complete. (90ms)
+223ms â•‘Setting up scheduled job for Sun, Sep 23 2018 @ 9:08:21 AM BST (in 599.97s)
+235ms ╚Event processed successfully (234ms)
23/09/2018, 08:57:58 +988ms
+1ms â•”Received event [Living Room Motion Sensor].motion = active with a delay of 1082ms
+117ms â•‘RunTime Analysis CS > 13ms > PS > 59ms > PE > 44ms > CE
+120ms â•‘Runtime (48947 bytes) successfully initialized in 59ms (v0.3.108.20180906) (117ms)
+121ms â•‘â•”Execution stage started
+131ms â•‘â•‘Comparison (string) :46cc155878d3427fe608e136b52dbd53: is_any_of (string) :46cc155878d3427fe608e136b52dbd53:,:7429bcb2a229229d6f1c1e6659102d4a: = true (2ms)
+133ms â•‘â•‘Condition #11 evaluated true (6ms)
+143ms â•‘â•‘Comparison (enum) closed is (string) closed = true (2ms)
+145ms â•‘â•‘Condition #36 evaluated true (11ms)
+146ms ║║Cancelling condition #1’s schedules…
+147ms â•‘â•‘Condition group #1 evaluated true (state changed) (21ms)
+158ms â•‘â•‘Comparison (integer) 34 is_less_than_or_equal_to (integer) 25 = false (2ms)
+160ms â•‘â•‘Condition #41 evaluated false (11ms)
+161ms ║║Cancelling condition #1’s schedules…
+162ms â•‘â•‘Condition group #1 evaluated false (state changed) (14ms)
+165ms ║║Cancelling statement #2’s schedules…
+172ms â•‘â•‘Executed virtual command [Living Room lamp 1, Living Room lamp 2, Living Room lamp 3].wait (0ms)
+173ms â•‘â•‘Requesting a wake up for Sun, Sep 23 2018 @ 9:07:59 AM BST (in 600.0s)
+186ms â•‘â•‘Comparison (string) :46cc155878d3427fe608e136b52dbd53: is_any_of (string) :2ebc15aa88871a4a84bd355812b2a6b6:,:c18aa990a7e4a353526560987df11955:,:22e263f6fea9d0017b40c2a0afbed100:,:7429bcb2a229229d6f1c1e6659102d4a: = false (5ms)
+188ms â•‘â•‘Condition #22 evaluated false (8ms)
+189ms â•‘â•‘Condition group #13 evaluated false (state did not change) (10ms)
+197ms â•‘â•‘Comparison (string) :46cc155878d3427fe608e136b52dbd53: is (string) :9ed33657c6130d8602b092ce335983cb: = false (2ms)
+199ms â•‘â•‘Condition #34 evaluated false (6ms)
+200ms â•‘â•‘Condition group #24 evaluated false (state did not change) (8ms)
+203ms ║╚Execution stage complete. (82ms)
+205ms â•‘Setting up scheduled job for Sun, Sep 23 2018 @ 9:07:59 AM BST (in 599.97s)
+223ms ╚Event processed successfully (223ms)
23/09/2018, 08:57:44 +825ms
+1ms â•”Received event [Living Room Motion Sensor].motion = inactive with a delay of 884ms
+119ms â•‘RunTime Analysis CS > 19ms > PS > 58ms > PE > 42ms > CE
+121ms â•‘Runtime (48948 bytes) successfully initialized in 58ms (v0.3.108.20180906) (120ms)
+123ms â•‘â•”Execution stage started
+133ms â•‘â•‘Comparison (string) :46cc155878d3427fe608e136b52dbd53: is_any_of (string) :46cc155878d3427fe608e136b52dbd53:,:7429bcb2a229229d6f1c1e6659102d4a: = true (2ms)
+135ms â•‘â•‘Condition #11 evaluated true (7ms)
+144ms â•‘â•‘Comparison (enum) closed is (string) closed = true (2ms)
+146ms â•‘â•‘Condition #36 evaluated true (10ms)
+147ms ║║Cancelling condition #1’s schedules…
+148ms â•‘â•‘Condition group #1 evaluated true (state changed) (20ms)
+159ms â•‘â•‘Comparison (integer) 34 is_less_than_or_equal_to (integer) 25 = false (2ms)
+161ms â•‘â•‘Condition #41 evaluated false (11ms)
+162ms ║║Cancelling condition #1’s schedules…
+163ms â•‘â•‘Condition group #1 evaluated false (state changed) (14ms)
+166ms ║║Cancelling statement #2’s schedules…
+172ms â•‘â•‘Executed virtual command [Living Room lamp 1, Living Room lamp 2, Living Room lamp 3].wait (1ms)
+174ms â•‘â•‘Requesting a wake up for Sun, Sep 23 2018 @ 9:07:44 AM BST (in 600.0s)
+188ms â•‘â•‘Comparison (string) :46cc155878d3427fe608e136b52dbd53: is_any_of (string) :2ebc15aa88871a4a84bd355812b2a6b6:,:c18aa990a7e4a353526560987df11955:,:22e263f6fea9d0017b40c2a0afbed100:,:7429bcb2a229229d6f1c1e6659102d4a: = false (4ms)
+189ms â•‘â•‘Condition #22 evaluated false (8ms)
+191ms â•‘â•‘Condition group #13 evaluated false (state did not change) (10ms)
+198ms â•‘â•‘Comparison (string) :46cc155878d3427fe608e136b52dbd53: is (string) :9ed33657c6130d8602b092ce335983cb: = false (2ms)
+200ms â•‘â•‘Condition #34 evaluated false (6ms)
+201ms â•‘â•‘Condition group #24 evaluated false (state did not change) (8ms)
+204ms ║╚Execution stage complete. (82ms)
+206ms â•‘Setting up scheduled job for Sun, Sep 23 2018 @ 9:07:45 AM BST (in 599.97s)
+219ms ╚Event processed successfully (220ms)
23/09/2018, 08:57:34 +345ms
+1ms â•”Received event [Living Room Motion Sensor].motion = active with a delay of 884ms
+138ms â•‘RunTime Analysis CS > 15ms > PS > 83ms > PE > 41ms > CE
+141ms â•‘Runtime (48946 bytes) successfully initialized in 83ms (v0.3.108.20180906) (139ms)
+143ms â•‘â•”Execution stage started
+154ms â•‘â•‘Comparison (string) :46cc155878d3427fe608e136b52dbd53: is_any_of (string) :46cc155878d3427fe608e136b52dbd53:,:7429bcb2a229229d6f1c1e6659102d4a: = true (2ms)
+156ms â•‘â•‘Condition #11 evaluated true (6ms)
+166ms â•‘â•‘Comparison (enum) closed is (string) closed = true (2ms)
+168ms â•‘â•‘Condition #36 evaluated true (11ms)
+170ms ║║Cancelling condition #1’s schedules…
+171ms â•‘â•‘Condition group #1 evaluated true (state changed) (22ms)
+182ms â•‘â•‘Comparison (integer) 34 is_less_than_or_equal_to (integer) 25 = false (2ms)
+184ms â•‘â•‘Condition #41 evaluated false (12ms)
+185ms ║║Cancelling condition #1’s schedules…
+186ms â•‘â•‘Condition group #1 evaluated false (state changed) (14ms)
+190ms ║║Cancelling statement #2’s schedules…
+196ms â•‘â•‘Executed virtual command [Living Room lamp 1, Living Room lamp 2, Living Room lamp 3].wait (1ms)
+198ms â•‘â•‘Requesting a wake up for Sun, Sep 23 2018 @ 9:07:34 AM BST (in 600.0s)
+211ms â•‘â•‘Comparison (string) :46cc155878d3427fe608e136b52dbd53: is_any_of (string) :2ebc15aa88871a4a84bd355812b2a6b6:,:c18aa990a7e4a353526560987df11955:,:22e263f6fea9d0017b40c2a0afbed100:,:7429bcb2a229229d6f1c1e6659102d4a: = false (4ms)
+213ms â•‘â•‘Condition #22 evaluated false (9ms)
+214ms â•‘â•‘Condition group #13 evaluated false (state did not change) (10ms)
+222ms â•‘â•‘Comparison (string) :46cc155878d3427fe608e136b52dbd53: is (string) :9ed33657c6130d8602b092ce335983cb: = false (2ms)
+224ms â•‘â•‘Condition #34 evaluated false (7ms)
+225ms â•‘â•‘Condition group #24 evaluated false (state did not change) (8ms)
+229ms ║╚Execution stage complete. (86ms)
+230ms â•‘Setting up scheduled job for Sun, Sep 23 2018 @ 9:07:34 AM BST (in 599.969s)
+243ms ╚Event processed successfully (244ms)

Thanks for any help with this everything else in this piston does exactly what i want but i can’t solve this niggly bit.


#2

A timer nested inside a trigger for a motion sensor in an asynch IF statement with restrictions has just about every possible headache you could give yourself while trying to write a piston. :slight_smile:

The timer resets every time your IF condition evaluates false, meaning when your motion sensor changes to inactive the timer will reset regardless of lux value.

The easiest workaround I can think of off the top of my head would be to create a separate IF condition to turn your lights off that doesn’t include the motion sensor. A simple Boolean variable can be used to make sure the lights are on from automation and will prevent the lights from being switched off at other times that the room is well lit.

Define Variable
Boolean lightsAutoOn

After your actions to set color to white and level to 100% (line 32 as pictured in your green snapshot)
Set Variable lightsAutoOn = true

IF
lightsAutoOn = true
AND
Lux > 25

Then
Wait 10 minutes
Turn lights off
Set variable lightsAutoOn = false


#3

Thanks, i might try that but i’m also experimenting with Rooms manager to see how that goes. seems to work well in my office so far.