Front Motion Light Not Staying On


#1

1) Give a description of the problem
Piston turns on exterior lights at sunset and off at sunrise. It has an IF statement to set the dimmers to 100% based on motion sensor and then is supposed to dim them back to 25% after 10 minutes but they dim after just a few seconds (basically after motion stops with no delay).

2) What is the expected behavior?
Lights should remain at 100% until motion has stopped for 10 minutes.

3) What is happening/not happening?
Lights are dimming after motion stops without the 10 minute delay.

4) Post a Green Snapshot of the pistonimage

5) Attach any logs (From ST IDE and by turning logging level to Full)
10/13/2017, 9:50:52 AM +605ms +5ms ╔Received event [Home].test = 1507913452587 with a delay of 10ms +155ms ║RunTime Analysis CS > 37ms > PS > 37ms > PE > 86ms > CE +173ms ║Runtime (38678 bytes) successfully initialized in 37ms (v0.2.0fa.20171011) (162ms) +177ms ║╔Execution stage started +264ms ║║Comparison (time) 35452816 is_between (time) 1507944720000 .. (time) 1507904280000 = false (15ms) +272ms ║║Condition #23 evaluated false (63ms) +286ms ║║Cancelling statement #23's schedules... +299ms ║║Requesting time schedule wake up at Fri, Oct 13 2017 @ 6:32:00 PM PDT +314ms ║║Condition group #18 evaluated false (state did not change) (108ms) +322ms ║║Cancelling statement #29's schedules... +349ms ║║Skipped execution of physical command [Light - Driveway].off([]) because it would make no change to the device. (6ms) +350ms ║║Executed [Light - Driveway].off (10ms) +355ms ║║Skipped execution of physical command [Light - Front Door].off([]) because it would make no change to the device. (3ms) +356ms ║║Executed [Light - Front Door].off (4ms) +403ms ║╚Execution stage complete. (228ms) +421ms ║Setting up scheduled job for Fri, Oct 13 2017 @ 6:32:00 PM PDT (in 31266.977s) +440ms ╚Event processed successfully (442ms)

REMOVE BELOW AFTER READING


#2

Separating your two if’s Into two separate if statements.


#3

pistons evaluate from top to bottom, so basically your piston setup at the moment is, whenever there is movement, that is triggering a re-evaluation of the piston from the top causing it to turn on the light and then set the level to 25% if it is between sunset and sunrise…


#4

You lost me. First if is sunset to sunrise. When true, turn on lights and set to 25%. Nested IF is when there’s motion set to 100% else wait 10 minutes and turn back down to 25%. The motion does trigger the 100%, but a few seconds after motion stops it reverts to 25% (ignoring the else of that if).

Can you tell me how to do your suggestion?


#5

Here is what I do … I have Arlo’s outside and if any detect motion between just before sunset and a while after sunrise, I turn on my front porch lights… see if this helps


#6

I want to explain why your piston does what it does so as to help you understand when making more pistons where is was that you went wrong…

if you look at your piston you will notice there are 2 events that are subscribed to, they are “the time is between sunset and sunrise”, and “motion sensor 21 being active”. you can tell that these are the only 2 events being subscribed to by looking for the lightning bolts in the left most section next to the line numbers.

this doesn’t mean that they will only do the things associated with them when they happen, this actually means if any event is sent to the SmartThings hub from either of these two “triggers” they will cause the piston to evaluate (from the top to the bottom).

so basically any time there is either a signal for “movement detected” or the signal for “movement detection finished” is sent or the “time becomes sunset” or “time becomes sunrise” is sent to the SmartThings hub, this will make it look at your piston and check it…

Now, if you look at your piston, when movement is detected it won’t do exactly what you are expecting it to do,
Firstly it will say is the time between sunset and sunrise? if it is then it will turn the lights on (if they are not already on) because that is the first “THEN” that it has been told to do, and then it will set the level to 25% (if they are not already 25%)
then it will say “is movement being detected”? (in this situation “YES” it was because it was “movement being detected” that caused it to re-evaluate this time) if it is being detected then it will set the lights to 100% (if they are not already 100%) then it will skip the else section of your NESTED if because at the time it was checking the conditions there “WAS” movement being detected… if at the time it was checking the conditions there was “NO MOVEMENT” being detected (which would only be when the “time” became either “sunset” or “sunrise” because that is the only other thing that can trigger a re-evaluation of this piston) then it would have skipped the first if which was to set the lights to 100% and it would go straight to the ELSE which was to wait 10 minutes and then set level to 25%

also your nested if’s else section only has one group of actions associated with it so there was no need for the async selection on there either.

the lesson here is basically don’t use NESTED IF’s unless you only want it to check either/or but without subscribing to either event in the nested if…

I hope this explanation has made sense and helps you along the way with your future pistons. :slight_smile:

so here is your piston Re-Structured so that it will do what you are expecting it to do…
Please import it using the import code…


#7

@Baz2473 your rock! Thanks - and I do appreciate the detailed explanation.

I do have two questions about the updated piston. First, why the async with on line 30?

Second, what would happen if there were motion 5 minutes before sunrise? Line 48 (sunrise) would happen and turn the lights off, but would line line 34 happen 5 minutes later and turn the lights back on to 25%?


#8

There are “ONLY WHEN” restrictions in the motion activated “if” section to only allow the “if” or the “else” to perform actions “if the time is between sunset and sunrise” so theoretically nothing would happen if there was motion before sunset or after sunrise…

And the async wasn’t supposed to be there, i imported your piston and edited it but forgot to remove that async, MY BAD!

I’ve Edited the piston now… async is gone :slight_smile:


#9

@DarellCraighead sorry, i misunderstood what you said, give me a second and ill check and change if necessary
OK,
So i see what you meant and have adjusted accordingly…

There beauty is there are so many ways of doing things with WebCoRE and ending with the same result but this should solve that situation, i think you’ll find that it would have cancelled the timer anyway because sunrise would have caused a fresh re-evaluation of the piston causing the timer to either restart if still under the restrictions or cancel if no longer valid… but this should just make extra sure that doesn’t happen with the light and sunrise thingy!


#10

Getting closer. Lights come on at sunset. Motion raises level for 10 minutes then dim. But, they don’t turn off at sunrise???

Here are the logs from this morning at sunrise:

10/17/2017, 7:30:58 AM +150ms
+0ms ╔Received event [Home].time = 1508250659378 with a delay of -1229ms
+114ms ║RunTime Analysis CS > 22ms > PS > 48ms > PE > 44ms > CE
+128ms ║Runtime (40282 bytes) successfully initialized in 48ms (v0.2.0fa.20171011) (126ms)
+129ms ║╔Execution stage started
+172ms ║║Comparison (time) 27058303 is_between (time) 1508289960000 … (time) 1508250180000 = false (11ms)
+175ms ║║Cancelling condition #49’s schedules…
+176ms ║║Condition #49 evaluated false (22ms)
+177ms ║║Cancelling condition #47’s schedules…
+178ms ║║Condition group #47 evaluated false (state changed) (26ms)
+188ms ║║Comparison (time) 27058333 happens_daily_at (time) 1508289960000 = false (1ms)
+190ms ║║Condition #41 evaluated false (7ms)
+193ms ║║Cancelling statement #41’s schedules…
+199ms ║║Requesting time schedule wake up at Tue, Oct 17 2017 @ 6:26:00 PM PDT
+202ms ║║Condition group #40 evaluated false (state did not change) (20ms)
+211ms ║║Comparison (time) 27058357 happens_daily_at (time) 1508250180000 = false (1ms)
+213ms ║║Condition #45 evaluated false (7ms)
+214ms ║║Cancelling statement #45’s schedules…
+220ms ║║Requesting time schedule wake up at Wed, Oct 18 2017 @ 7:23:00 AM PDT
+224ms ║║Condition group #42 evaluated false (state did not change) (18ms)
+228ms ║╚Execution stage complete. (99ms)
+231ms ║Setting up scheduled job for Tue, Oct 17 2017 @ 6:26:00 PM PDT (in 39301.62s), with 1 more job pending
+248ms ╚Event processed successfully (248ms)
10/17/2017, 7:20:59 AM +148ms
+1ms ╔Received event [Home].time = 1508250060000 with a delay of -852ms
+171ms ║RunTime Analysis CS > 21ms > PS > 128ms > PE > 22ms > CE
+182ms ║Runtime (40283 bytes) successfully initialized in 128ms (v0.2.0fa.20171011) (180ms)
+183ms ║╔Execution stage started
+199ms ║║Comparison (enum) inactive is (string) active = false (2ms)
+201ms ║║Condition #33 evaluated false (10ms)
+202ms ║║Condition group #32 evaluated false (state did not change) (12ms)
+218ms ║║Comparison (time) 26459353 is_between (time) 1508289960000 … (time) 1508250180000 = true (9ms)
+219ms ║║Time restriction check passed
+221ms ║║Condition #39 evaluated true (17ms)
+222ms ║║Condition group #36 evaluated true (state did not change) (17ms)
+223ms ║║Cancelling statement #36’s schedules…
+228ms ║║Executed virtual command [Light - Front Door, Light - Driveway].wait (0ms)
+230ms ║║Requesting a wake up for Tue, Oct 17 2017 @ 7:30:59 AM PDT (in 600.0s)
+235ms ║╚Execution stage complete. (52ms)
+237ms ║Setting up scheduled job for Tue, Oct 17 2017 @ 7:30:59 AM PDT (in 599.993s), with 1 more job pending
+253ms ╚Event processed successfully (253ms)


#11

Try setting tcp to never for the two bottom statements.
(Task cancellation policy)


#12

Still won’t turn off at sunrise :frowning:

`10/18/2017, 7:32:58 AM +169ms

+0ms ╔Received event [Home].time = 1508337179391 with a delay of -1222ms
+100ms ║RunTime Analysis CS > 13ms > PS > 49ms > PE > 38ms > CE
+125ms ║Runtime (40266 bytes) successfully initialized in 49ms (v0.2.0fa.20171011) (124ms)
+126ms ║╔Execution stage started
+159ms ║║Comparison (time) 27178315 is_between (time) 1508376300000 … (time) 1508336640000 = false (8ms)
+161ms ║║Cancelling condition #49’s schedules…
+162ms ║║Condition #49 evaluated false (15ms)
+163ms ║║Cancelling condition #47’s schedules…
+163ms ║║Condition group #47 evaluated false (state changed) (18ms)
+171ms ║║Comparison (time) 27178336 happens_daily_at (time) 1508376300000 = false (1ms)
+173ms ║║Condition #41 evaluated false (6ms)
+177ms ║║Cancelling statement #41’s schedules…
+182ms ║║Requesting time schedule wake up at Wed, Oct 18 2017 @ 6:25:00 PM PDT
+185ms ║║Condition group #40 evaluated false (state did not change) (18ms)
+190ms ║║Comparison (time) 27178356 happens_daily_at (time) 1508336640000 = false (1ms)
+191ms ║║Condition #45 evaluated false (4ms)
+192ms ║║Cancelling statement #45’s schedules…
+197ms ║║Requesting time schedule wake up at Thu, Oct 19 2017 @ 7:24:00 AM PDT
+199ms ║║Condition group #42 evaluated false (state did not change) (12ms)
+202ms ║╚Execution stage complete. (76ms)
+204ms ║Setting up scheduled job for Wed, Oct 18 2017 @ 6:25:00 PM PDT (in 39121.628s), with 1 more job pending
+226ms ╚Event processed successfully (225ms)
10/18/2017, 7:22:59 AM +134ms
+0ms ╔Received event [Home].time = 1508336580000 with a delay of -867ms
+196ms ║RunTime Analysis CS > 13ms > PS > 138ms > PE > 45ms > CE
+209ms ║Runtime (40267 bytes) successfully initialized in 138ms (v0.2.0fa.20171011) (208ms)
+210ms ║╔Execution stage started
+224ms ║║Comparison (enum) inactive is (string) active = false (2ms)
+225ms ║║Condition #33 evaluated false (8ms)
+226ms ║║Condition group #32 evaluated false (state did not change) (10ms)
+243ms ║║Comparison (time) 26579363 is_between (time) 1508376300000 … (time) 1508336640000 = true (9ms)
+247ms ║║Time restriction check passed
+248ms ║║Condition #39 evaluated true (19ms)
+249ms ║║Condition group #36 evaluated true (state did not change) (21ms)
+250ms ║║Cancelling statement #36’s schedules…
+255ms ║║Executed virtual command [Light - Front Door, Light - Driveway].wait (0ms)
+256ms ║║Requesting a wake up for Wed, Oct 18 2017 @ 7:32:59 AM PDT (in 600.0s)
+261ms ║╚Execution stage complete. (51ms)
+263ms ║Setting up scheduled job for Wed, Oct 18 2017 @ 7:32:59 AM PDT (in 599.994s), with 1 more job pending
+298ms ╚Event processed successfully (298ms)
10/17/2017, 8:54:59 PM +109ms
+1ms ╔Received event [Home].time = 1508298900137 with a delay of -1028ms
+100ms ║RunTime Analysis CS > 13ms > PS > 44ms > PE > 42ms > CE
+114ms ║Runtime (40266 bytes) successfully initialized in 44ms (v0.2.0fa.20171011) (112ms)
+116ms ║╔Execution stage started
+150ms ║║Comparison (time) 75299245 is_between (time) 1508289960000 … (time) 1508250180000 = true (9ms)
+151ms ║║Time restriction check passed
+153ms ║║Condition #49 evaluated true (17ms)
+154ms ║║Condition group #47 evaluated true (state did not change) (19ms)
+155ms ║║Cancelling statement #47’s schedules…
+193ms ║║Executed physical command [Light - Driveway].setLevel([25]) (32ms)
+194ms ║║Executed [Light - Driveway].setLevel (34ms)
+229ms ║║Executed physical command [Light - Front Door].setLevel([25]) (33ms)
+230ms ║║Executed [Light - Front Door].setLevel (35ms)
+237ms ║║Comparison (time) 75299343 happens_daily_at (time) 1508289960000 = false (1ms)
+238ms ║║Condition #41 evaluated false (4ms)
+244ms ║║Cancelling statement #41’s schedules…
+248ms ║║Requesting time schedule wake up at Wed, Oct 18 2017 @ 6:26:00 PM PDT
+251ms ║║Condition group #40 evaluated false (state did not change) (18ms)
+257ms ║║Comparison (time) 75299363 happens_daily_at (time) 1508250180000 = false (0ms)
+259ms ║║Condition #45 evaluated false (4ms)
+260ms ║║Cancelling statement #45’s schedules…
+265ms ║║Requesting time schedule wake up at Wed, Oct 18 2017 @ 7:23:00 AM PDT
+267ms ║║Condition group #42 evaluated false (state did not change) (13ms)
+271ms ║╚Execution stage complete. (155ms)
+273ms ║Setting up scheduled job for Wed, Oct 18 2017 @ 7:23:00 AM PDT (in 37680.619s), with 1 more job pending
+292ms ╚Event processed successfully (292ms)
10/17/2017, 8:44:59 PM +971ms
+1ms ╔Received event [Motion Sensor - Front Door].motion = inactive with a delay of 990ms
+109ms ║RunTime Analysis CS > 20ms > PS > 50ms > PE > 39ms > CE
+124ms ║Runtime (40279 bytes) successfully initialized in 50ms (v0.2.0fa.20171011) (122ms)
+125ms ║╔Execution stage started
+137ms ║║Comparison (enum) inactive is (string) active = false (2ms)
+138ms ║║Cancelling condition #33’s schedules…
+139ms ║║Condition #33 evaluated false (7ms)
+140ms ║║Cancelling condition #32’s schedules…
+141ms ║║Condition group #32 evaluated false (state changed) (10ms)
+154ms ║║Comparison (time) 74700114 is_between (time) 1508289960000 … (time) 1508250180000 = true (7ms)
+156ms ║║Time restriction check passed
+157ms ║║Condition #39 evaluated true (14ms)
+158ms ║║Condition group #36 evaluated true (state did not change) (15ms)
+159ms ║║Cancelling statement #36’s schedules…
+164ms ║║Executed virtual command [Light - Front Door, Light - Driveway].wait (0ms)
+165ms ║║Requesting a wake up for Tue, Oct 17 2017 @ 8:55:00 PM PDT (in 600.0s)
+172ms ║╚Execution stage complete. (47ms)
+174ms ║Setting up scheduled job for Tue, Oct 17 2017 @ 8:55:00 PM PDT (in 599.993s), with 2 more jobs pending
+196ms ╚Event processed successfully (195ms)
10/17/2017, 8:44:43 PM +160ms
+1ms ╔Received event [Motion Sensor - Front Door].motion = active with a delay of 1005ms
+106ms ║RunTime Analysis CS > 20ms > PS > 54ms > PE > 33ms > CE
+119ms ║Runtime (40284 bytes) successfully initialized in 54ms (v0.2.0fa.20171011) (116ms)
+120ms ║╔Execution stage started
+131ms ║║Comparison (enum) active is (string) active = true (2ms)
+132ms ║║Cancelling condition #33’s schedules…
+133ms ║║Condition #33 evaluated true (7ms)
+134ms ║║Cancelling condition #32’s schedules…
+135ms ║║Condition group #32 evaluated true (state changed) (10ms)
+149ms ║║Comparison (time) 74683297 is_between (time) 1508289960000 … (time) 1508250180000 = true (7ms)
+150ms ║║Time restriction check passed
+151ms ║║Cancelling condition #46’s schedules…
+152ms ║║Condition #46 evaluated true (15ms)
+153ms ║║Cancelling condition #34’s schedules…
+154ms ║║Condition group #34 evaluated true (state changed) (17ms)
+155ms ║║Cancelling statement #34’s schedules…
+202ms ║║Executed physical command [Light - Front Door].setLevel([100]) (42ms)
+203ms ║║Executed [Light - Front Door].setLevel (43ms)
+245ms ║║Executed physical command [Light - Driveway].setLevel([100]) (39ms)
+245ms ║║Executed [Light - Driveway].setLevel (41ms)
+252ms ║║Comparison (time) 74683409 happens_daily_at (time) 1508289960000 = false (1ms)
+253ms ║║Condition #41 evaluated false (4ms)
+254ms ║║Cancelling statement #41’s schedules…
+258ms ║║Requesting time schedule wake up at Wed, Oct 18 2017 @ 6:26:00 PM PDT
+260ms ║║Condition group #40 evaluated false (state did not change) (12ms)
+266ms ║║Comparison (time) 74683423 happens_daily_at (time) 1508250180000 = false (1ms)
+267ms ║║Condition #45 evaluated false (4ms)
+268ms ║║Cancelling statement #45’s schedules…
+272ms ║║Requesting time schedule wake up at Wed, Oct 18 2017 @ 7:23:00 AM PDT
+275ms ║║Condition group #42 evaluated false (state did not change) (11ms)
+278ms ║╚Execution stage complete. (159ms)
+280ms ║Setting up scheduled job for Wed, Oct 18 2017 @ 7:23:00 AM PDT (in 38296.561s), with 1 more job pending
+295ms ╚Event processed successfully (295ms)
10/17/2017, 6:35:58 PM +116ms
+1ms ╔Received event [Home].time = 1508290559538 with a delay of -1422ms
+105ms ║RunTime Analysis CS > 16ms > PS > 59ms > PE > 30ms > CE
+118ms ║Runtime (40270 bytes) successfully initialized in 59ms (v0.2.0fa.20171011) (116ms)
+119ms ║╔Execution stage started
+149ms ║║Comparison (time) 66958252 is_between (time) 1508289960000 … (time) 1508250180000 = true (7ms)
+150ms ║║Time restriction check passed
+152ms ║║Cancelling condition #49’s schedules…
+153ms ║║Condition #49 evaluated true (16ms)
+154ms ║║Cancelling condition #47’s schedules…
+154ms ║║Condition group #47 evaluated true (state changed) (18ms)
+156ms ║║Cancelling statement #47’s schedules…
+203ms ║║Executed physical command [Light - Driveway].setLevel([25]) (40ms)
+204ms ║║Executed [Light - Driveway].setLevel (42ms)
+244ms ║║Executed physical command [Light - Front Door].setLevel([25]) (38ms)
+245ms ║║Executed [Light - Front Door].setLevel (39ms)
+251ms ║║Comparison (time) 66958365 happens_daily_at (time) 1508289960000 = false (0ms)
+253ms ║║Condition #41 evaluated false (5ms)
+255ms ║║Cancelling statement #41’s schedules…
+259ms ║║Requesting time schedule wake up at Wed, Oct 18 2017 @ 6:26:00 PM PDT
+262ms ║║Condition group #40 evaluated false (state did not change) (13ms)
+267ms ║║Comparison (time) 66958381 happens_daily_at (time) 1508250180000 = false (0ms)
+269ms ║║Condition #45 evaluated false (5ms)
+271ms ║║Cancelling statement #45’s schedules…
+275ms ║║Requesting time schedule wake up at Wed, Oct 18 2017 @ 7:23:00 AM PDT
+277ms ║║Condition group #42 evaluated false (state did not change) (13ms)
+282ms ║╚Execution stage complete. (163ms)
+285ms ║Setting up scheduled job for Wed, Oct 18 2017 @ 7:23:00 AM PDT (in 46021.6s), with 1 more job pending
+301ms ╚Event processed successfully (301ms)
10/17/2017, 6:25:59 PM +104ms
+1ms ╔Received event [Home].time = 1508289960000 with a delay of -896ms
+325ms ║RunTime Analysis CS > 33ms > PS > 261ms > PE > 31ms > CE
+389ms ║Runtime (40273 bytes) successfully initialized in 261ms (v0.2.0fa.20171011) (387ms)
+390ms ║╔Execution stage started
+405ms ║║Comparison (enum) inactive is (string) active = false (2ms)
+406ms ║║Condition #33 evaluated false (9ms)
+407ms ║║Condition group #32 evaluated false (state did not change) (11ms)
+421ms ║║Comparison (time) 66359514 is_between (time) 1508289960000 … (time) 1508250180000 = true (7ms)
+422ms ║║Time restriction check passed
+424ms ║║Cancelling condition #39’s schedules…
+424ms ║║Condition #39 evaluated true (14ms)
+426ms ║║Cancelling condition #36’s schedules…
+426ms ║║Condition group #36 evaluated true (state changed) (17ms)
+427ms ║║Cancelling statement #36’s schedules…
+433ms ║║Executed virtual command [Light - Front Door, Light - Driveway].wait (0ms)
+434ms ║║Requesting a wake up for Tue, Oct 17 2017 @ 6:35:59 PM PDT (in 600.0s)
+439ms ║╚Execution stage complete. (50ms)
+441ms ║Setting up scheduled job for Tue, Oct 17 2017 @ 6:35:59 PM PDT (in 599.994s), with 1 more job pending
+457ms ╚Event processed successfully (457ms)`


#13

I think the problem lies with the fact that you have an action at sunrise and sunset and you also have restrictions that stop/start at sunrise and sunset also. So I would suggest changing it so the lights turn off a minute after sunrise. And on a minute before sunset. That should solve the problem.

I mentioned in an earlier post that pistons evaluate from top to bottom, and then I went and made you a piston putting the two time actions that only happen once each per day at the bottom. I would also suggest moving them to the top 2 instead of the bottom 2 if’s


#14

Seems to have worked! Yea!