Keep lights on for 10 minutes with no motion

I’ve talked abouit GrizzlyAK example

I don’t really understand why you would want the “turn lights off” action to be dependent on the “motion sensor is on” trigger (with a delay).
Why not have the “motion sensor is on” turn the lights on, and a “motion sensor has been off for X minutes” turn the lights off?

1 Like

Ah … Apologies

It sometimes hard to get the drift of a comment that does not seem a specific response but a general one (in this case)

No idea, why it did not show that I used the “reply” button to his comment.
But in fact it does not work for me. I tried it several times. Result was - not working.

But correct me if my assumption is wrong. My testing result shown me, that the status is not changing. But the code says change status “to” ON. Since if the status is ongoing at ON, there won’t happen a change of the status. Like change from bla to ON, change from OFF to ON, because the status will remain until the motion stops. After the status changed to what ever, the trigger can be used again.

I’ve tried now Turn ON light for 10 minutes when motion detected
This works perfectly for me. But I really would like to have it run with just one automation. Because this way I’ve splitted the automation in two pieces. The ON, and the OFF automation. But am still struggling to understand how I could make it with only one automation entry and maybe with a script in the backend.

Why?

What is the benefit of having one automation with complex syntax and conditions which is difficult to read, undersand and debug, instead of having two simple, easy to understand automations that does exactly what you would expect?

If you reply immediately beneath a post it’s impossible (for me at least) to tell if you made a general reply or a reply to the post immediately above
:man_shrugging:
So I consider the wording to make it clear

People read all sorts of things into even innocent replies, anything to reduce a potential flame war :wink:

Less automation entries? Make it more flexible? Make it usable for other sensors, too?
There are several reasons why you want to do such things.
In bash i also do not write 10 scripts, when I can do it in one shot and being able to use it for other topics. Or like to extend the the functionality of a script.

Well. When I write scripts, I tend to write them to do one thing and do that well. And if I want to do several things, I add a wrapper that can trigger the individual scripts in the order I need.
But ymmv.

And I dont really understand why you feel it is more “flexible” and “usable” to introduce delays and conditions, than to simply do something like:

  - id: garage_lights_on_when_motion
    trigger:
     -  platform: state
        entity_id: group.motion_garage
        to: 'on'
    action:
    - service: switch.turn_on
      data:
        entity_id: switch.zooz_zen21_switch_garage

  - id: garage_lights_off_when_no_motion
    trigger:
     -  platform: state
        entity_id: group.motion_garage
        to: 'off'
        for: '00:10:00'
    action:
    - service: switch.turn_off
      data:
        entity_id: switch.zooz_zen21_switch_garage

Easy to read, easy to understand, easy to add more sensors, more switches or lights etc.

The delay before the lights are turned off can easily be set by an input_datetime if you want to have a more dynamic delay. You can also add different conditions to the “on” and “off” automation.

The OP talked about not turning the lights on during the day. Add a condition to the “turn on” automation only, and you still turn the lights off automatically if there is no motion detected, even if the ligths were turned on by something else than the automations. So at daytime, you can turn on the lights manually if needed, and if you forget to turn them off, they are turned off after 10 minutes of no motion.

All of this gets more and more complicated because you need to handle both the “turn on” and “turn off” cases in the same automation.

If you insist on having them as a single automation, follow @123 s example. At least add triggers on both “pir on” and “pir off”, instead of waiting for a given time after “pir on”.

Hi,

I am trying to do something similar (except it’s 1min instead of 10 ^^
The first part works. I get the lights to turn on when there is a movement detected. However, they don’t turn off.
Here is what I have in my automation :

Nevermind, it works if I put 00:01:00 in the delay input :slight_smile:

Now, I don’t see your triggger here. But guessing it is something like “Motion detected in hallway”.
So this automation will turn on the lights when motion is detected, and turn it off again after one minute, even if there is still motion in the hallway.
I might be wrong, but I don’t believe this is what you really want…

My problem is that my XIaomi sensor only send update “off” after 2:30 minutes aproximately.
However, when I cross the hallway, I usually stay way less than that I did not want to leave the light on for so long. So I decided to automaticaly turn it off after 1min.

But you are right. The issue is that the sensor won’t send an movement detection signal if someone is still in the hallway or if someone else enter less thatn 2:30 min after the first person entered.

Not sure if I can do what I want then :confused:

For me its working perfectly with the motion sensor of fibaro.
As long as movement is recognized in the kitchen the light stays on. Without movement the light goes off after 30 seconds. Can be even extended or reduced.
Not sure about the xiaomi sensors. I have a very cheap eWeLink MS01 (Sonoff SNZB-3) which is not able to handle my goal for example. This is due to the blindtime which cannot be changed. Here it would be 1m - and thats useless for my kitchen or bedroom lights.