Motion Controlled Lights Will Not Turn Off After 3 Minutes


#1

1) Give a description of the problem
I would like my floor lamp controlled by a smart plug to turn on with motion and off if no motion is detected for three minutes.

2) What is the expected behaviour?
Turn on with motion and off with three minutes without motion

3) What is happening/not happening?
Light turns on but not off.

4) Post a Green Snapshot of the pistonimage

5) Attach logs after turning logging level to Full
8/21/2020, 5:22:49 PM +45ms
+1ms ╔Received event [Home].test = 1598055769045 with a delay of 0ms
+42ms ║RunTime Analysis CS > 23ms > PS > 6ms > PE > 13ms > CE
+44ms ║Runtime (37195 bytes) successfully initialized in 6ms (v0.3.110.20191009) (42ms)
+45ms ║╔Execution stage started
+60ms ║║Condition #2 evaluated false (10ms)
+61ms ║║Condition group #1 evaluated false (state did not change) (11ms)
+64ms ║╚Execution stage complete. (18ms)
+65ms ╚Event processed successfully (65ms)

REMOVE BELOW AFTER READING
If a solution is found for your question then please mark the post as the solution.


#2

Your logic looks solid, but the second IF should be moved down below…
(Totally outside the other IF)


IF X
    Then Turn on
END IF

IF Y
    Then Turn off
END IF

Also note, that pressing Test will not do anything in this piston.
(you actually have to walk past the motion sensor to test properly)


#3

Thank you very much for this suggestion. It looks like it worked. I’m new to this and I truly appreciate your time and information.


#4

Sure thing… Glad to be able to help.

Perhaps you can solution my post above to help others?


#5

One last question (I hope). It looks like the light turns off at 3 minutes despite being in the room in front of the Smartthings motion sensor prompting me to wave at the motion sensor to reactivate the light. Is there a solution to having the light remain on while present in the room or a better way to program the piston to avoid this from happening?
Thanks for your assistance


#6

Hmmm… Usually “IF motion stays inactive for X minutes” works well.

As long as the sensor sees motion at least once every 179 seconds, the light should remain on.

Can you please turn on Trace, turn Logging to Full, and share your latest piston & log so I can take a closer look?


Note, There are sensors (or locations) where I may increase the STAY to 5 min, instead of 3 min…


#7

8/21/2020, 8:13:32 PM +503ms
+1ms ╔Received event [Motion Guest Bed].motion = active with a delay of 45ms
+28ms ║RunTime Analysis CS > 15ms > PS > 4ms > PE > 9ms > CE
+30ms ║Runtime (37271 bytes) successfully initialized in 4ms (v0.3.110.20191009) (28ms)
+31ms ║╔Execution stage started
+38ms ║║Comparison (enum) active changes_to (string) active = true (1ms)
+40ms ║║Cancelling condition #2’s schedules…
+40ms ║║Condition #2 evaluated true (5ms)
+41ms ║║Cancelling condition #1’s schedules…
+42ms ║║Condition group #1 evaluated true (state changed) (7ms)
+44ms ║║Cancelling statement #3’s schedules…
+67ms ║║Executed physical command [Lamp Guest Bed].on() (20ms)
+68ms ║║Executed [Lamp Guest Bed].on (22ms)
+75ms ║║Comparison (enum) active stays (string) inactive = false (2ms)
+77ms ║║Cancelling any timed trigger schedules for condition 6
+78ms ║║Cancelling statement #6’s schedules…
+78ms ║║Cancelling condition #6’s schedules…
+79ms ║║Condition #6 evaluated false (8ms)
+80ms ║║Cancelling condition #5’s schedules…
+81ms ║║Condition group #5 evaluated false (state changed) (11ms)
+83ms ║╚Execution stage complete. (52ms)
+84ms ╚Event processed successfully (84ms)
8/21/2020, 8:13:25 PM +165ms
+1ms ╔Received event [Home].time = 1598066006706 with a delay of -1541ms
+42ms ║RunTime Analysis CS > 23ms > PS > 6ms > PE > 13ms > CE
+44ms ║Runtime (37273 bytes) successfully initialized in 6ms (v0.3.110.20191009) (42ms)
+46ms ║╔Execution stage started
+55ms ║║Cancelling condition #6’s schedules…
+56ms ║║Condition #6 evaluated true (1ms)
+57ms ║║Cancelling condition #5’s schedules…
+58ms ║║Condition group #5 evaluated true (state changed) (4ms)
+60ms ║║Cancelling statement #7’s schedules…
+82ms ║║Executed physical command [Lamp Guest Bed].off() (17ms)
+83ms ║║Executed [Lamp Guest Bed].off (19ms)
+85ms ║╚Execution stage complete. (40ms)
+86ms ╚Event processed successfully (86ms)


#8

Thanks for the quick reply.

Would you please clear that log, and then walk past the sensor again.

I need to see the first (turn on) command… the wait… as well as the premature “turn off” command to properly diagnose.


Note: I just sat down to eat, so I may be a little bit before replying again.


#9

Thanks again for your efforts:

8/21/2020, 8:28:40 PM +666ms
+1ms ╔Received event [Motion Guest Bed].motion = inactive with a delay of 41ms
+38ms ║RunTime Analysis CS > 18ms > PS > 5ms > PE > 16ms > CE
+41ms ║Runtime (37275 bytes) successfully initialized in 5ms (v0.3.110.20191009) (38ms)
+42ms ║╔Execution stage started
+49ms ║║Comparison (enum) inactive changes_to (string) active = false (1ms)
+50ms ║║Cancelling condition #2’s schedules…
+51ms ║║Condition #2 evaluated false (5ms)
+52ms ║║Cancelling condition #1’s schedules…
+53ms ║║Condition group #1 evaluated false (state changed) (7ms)
+60ms ║║Comparison (enum) inactive stays (string) inactive = true (1ms)
+62ms ║║Adding a timed trigger schedule for condition 6
+65ms ║║Condition #6 evaluated false (8ms)
+66ms ║║Condition group #5 evaluated false (state did not change) (9ms)
+68ms ║╚Execution stage complete. (27ms)
+69ms ║Setting up scheduled job for Fri, Aug 21 2020 @ 8:31:40 PM PDT (in 179.994s)
+77ms ╚Event processed successfully (77ms)
8/21/2020, 8:28:17 PM +900ms
+0ms ╔Received event [Motion Guest Bed].motion = active with a delay of 38ms
+30ms ║RunTime Analysis CS > 15ms > PS > 4ms > PE > 11ms > CE
+32ms ║Runtime (37272 bytes) successfully initialized in 4ms (v0.3.110.20191009) (31ms)
+33ms ║╔Execution stage started
+40ms ║║Comparison (enum) active changes_to (string) active = true (1ms)
+41ms ║║Cancelling condition #2’s schedules…
+42ms ║║Condition #2 evaluated true (5ms)
+43ms ║║Cancelling condition #1’s schedules…
+44ms ║║Condition group #1 evaluated true (state changed) (7ms)
+46ms ║║Cancelling statement #3’s schedules…
+59ms ║║Executed physical command [Lamp Guest Bed].on() (9ms)
+59ms ║║Executed [Lamp Guest Bed].on (11ms)
+66ms ║║Comparison (enum) active stays (string) inactive = false (1ms)
+68ms ║║Cancelling any timed trigger schedules for condition 6
+69ms ║║Cancelling statement #6’s schedules…
+70ms ║║Cancelling condition #6’s schedules…
+71ms ║║Condition #6 evaluated false (8ms)
+72ms ║║Cancelling condition #5’s schedules…
+72ms ║║Condition group #5 evaluated false (state changed) (10ms)
+74ms ║╚Execution stage complete. (42ms)
+75ms ╚Event processed successfully (76ms)
8/21/2020, 8:23:31 PM +120ms
+0ms ╔Received event [Home].time = 1598066612651 with a delay of -1532ms
+51ms ║RunTime Analysis CS > 25ms > PS > 7ms > PE > 20ms > CE
+55ms ║Runtime (37273 bytes) successfully initialized in 7ms (v0.3.110.20191009) (53ms)
+57ms ║╔Execution stage started
+76ms ║║Cancelling condition #6’s schedules…
+78ms ║║Condition #6 evaluated true (2ms)
+79ms ║║Cancelling condition #5’s schedules…
+81ms ║║Condition group #5 evaluated true (state changed) (5ms)
+84ms ║║Cancelling statement #7’s schedules…
+102ms ║║Executed physical command [Lamp Guest Bed].off() (13ms)
+104ms ║║Executed [Lamp Guest Bed].off (16ms)
+107ms ║╚Execution stage complete. (50ms)
+108ms ╚Event processed successfully (108ms)
8/21/2020, 8:20:32 PM +584ms
+1ms ╔Received event [Motion Guest Bed].motion = inactive with a delay of 40ms
+44ms ║RunTime Analysis CS > 29ms > PS > 4ms > PE > 11ms > CE
+46ms ║Runtime (37275 bytes) successfully initialized in 4ms (v0.3.110.20191009) (44ms)
+47ms ║╔Execution stage started
+54ms ║║Comparison (enum) inactive changes_to (string) active = false (0ms)
+56ms ║║Cancelling condition #2’s schedules…
+57ms ║║Condition #2 evaluated false (5ms)
+58ms ║║Cancelling condition #1’s schedules…
+58ms ║║Condition group #1 evaluated false (state changed) (7ms)
+65ms ║║Comparison (enum) inactive stays (string) inactive = true (2ms)
+67ms ║║Adding a timed trigger schedule for condition 6
+69ms ║║Condition #6 evaluated false (8ms)
+70ms ║║Condition group #5 evaluated false (state did not change) (9ms)
+72ms ║╚Execution stage complete. (25ms)
+73ms ║Setting up scheduled job for Fri, Aug 21 2020 @ 8:23:32 PM PDT (in 179.994s)
+81ms ╚Event processed successfully (81ms)
8/21/2020, 8:20:03 PM +787ms
+1ms ╔Received event [Motion Guest Bed].motion = active with a delay of 35ms
+30ms ║RunTime Analysis CS > 17ms > PS > 4ms > PE > 9ms > CE
+33ms ║Runtime (37271 bytes) successfully initialized in 4ms (v0.3.110.20191009) (31ms)
+34ms ║╔Execution stage started
+41ms ║║Comparison (enum) active changes_to (string) active = true (1ms)
+43ms ║║Cancelling condition #2’s schedules…
+44ms ║║Condition #2 evaluated true (5ms)
+45ms ║║Cancelling condition #1’s schedules…
+45ms ║║Condition group #1 evaluated true (state changed) (7ms)
+48ms ║║Cancelling statement #3’s schedules…
+95ms ║║Executed physical command [Lamp Guest Bed].on() (44ms)
+96ms ║║Executed [Lamp Guest Bed].on (46ms)
+103ms ║║Comparison (enum) active stays (string) inactive = false (2ms)
+105ms ║║Cancelling any timed trigger schedules for condition 6
+106ms ║║Cancelling statement #6’s schedules…
+106ms ║║Cancelling condition #6’s schedules…
+107ms ║║Condition #6 evaluated false (8ms)
+108ms ║║Cancelling condition #5’s schedules…
+109ms ║║Condition group #5 evaluated false (state changed) (10ms)
+111ms ║╚Execution stage complete. (77ms)
+112ms ╚Event processed successfully (112ms)


#10

Thanks… Let’s take a closer look at the key elements:

8:20:03 = [Motion Guest Bed].motion = active   = Turn on
8:20:32 = [Motion Guest Bed].motion = inactive = Set timer
8:23:31 = Executed [Lamp Guest Bed].off        = 3 min after inactive

According to the log, there was no activity for 3 minutes, so the light was turned off.

Common solutions to a premature shutoff, is to either extend the 3 min to a higher number, or perhaps aim the sensor towards a more “action-packed” direction.


#11

OK. The sensor is pointed directly at me. I’ll try increasing the time. Thanks again for all your help.


#12

If it helps, almost all of my motion sensor pistons have been fine-tuned with a different shut-off timer.
(IE: the delay for my kitchen is nowhere near the delay for my bathroom, since there is a very different… how shall I say… “level of activity”… in those rooms)

  • Set the number too high, and you waste energy
  • Set the number too low, and you are forced to wave your hands to keep it ‘awake’

The goal is to find the magic number somewhere in between.
(with things like lights, I typically round up a bit to lower false alarms)

Note:

  • It may take a few days, with multiple tweaks until you find your “sweet spot”.
  • It may take a week, if the room is shared by others with a different pace.
    (make sure they know to tell you if the light went off on them, so you can adjust)

This is kind of like you programming the AI to learn what is your preference.


Pro Tip:

I would recommend keeping Log level at Full until you are happy with the piston.
(you can use it as a reference to see precise times, and tweak a bit further)


Pro Tip #2:

For “communal” pistons, that might be (unknowingly) triggered by a guest (who might not understand my SmartHome), I always add a few extra minutes before turning off the lights.

This is much easier than trying to explain to a temporary guest how my house operates.


#13

Thanks again for all your great advice. I have a lot to learn.


#14

We are here to help.


#15

My motion sensors (Bosch) have a wait time of 5 minutes. Meaning, they only check for movement every 5 minutes. So, I cannot set the ‘wait’ time for anything lower than 5 minutes, or it doesn’t work.

I’ve found 10 minutes to be a “magic” number for my home. That way, it catches movement if you leave the room and decide to come back in.

I have many of my motion pistons set to 10 minutes.


#16

I find the second sentence a bit baffling…
In my mind, even a tiny delay would work with a STAY trigger. IE:

IF Sensor's motion STAYS inactive for 6 seconds

From what I have seen, webCoRE’s timer begins the moment the device reports “inactive” to the hub. If you set it to 6 sec, it would fire 6 sec after the status came in. (although, this doesn’t mean the room was only vacant for 6 sec)

The part I am unsure of is whether Bosch starts a new 5 min timer when it switches to “active”, or does it (for example) consistently check every hour at :00, :05, :10, :15, :20 etc… without fluctuation.

(not that any of this really matters, since you are happy with your piston :grin:)


#17

What I mean is: if I set my piston to “stays inactive for 3 minutes”, the lights will turn off on me if there is still motion in the room. Thats because the motion sensor only checks every 5 minutes. So there will not be another “active” until 5 minutes after the one that turned on the lights. So, the “3 minutes” will always be true.


#18

I see… The “active” is limited to once per 5 min, but the “inactive” can come in before that time period…

Peculiar… I wonder why they chose that logic…

(normally sensors that limit updates will also delay on the inactives)


#19

I don’t know. It took me a while to get use to. It becomes “active” on motion for about 5 seconds, and then changes to “inactive” and sets off a “check every 5 minutes for motion”. If there is motion, repeat above, if not, reset, wait for motion, repeat above.


#20

Ahh OK… So even if the whole family was breakdancing in front of it, it only shows “active” for 5 sec out of every 5 min…

I now see why you coded the way you did.