I’m trying to figure out how to trigger my lights to turn on when motion is detected, but ONLY if there hasn’t been any motion in the last half hour. That way if we’re watching TV with the lights off it won’t keep turning them back on.
My previous HA setup used SmartThings - they had some good ideas, among them a concept of a “Mode” for the house. I have adopted this in HA using an Input_select as the mode. The idea is you use specific events to set the mode, e.g. set it to evening when the light goes below a certain intensity. Set it to morning when motion is first detected after a certain time. The upside of this is that you can then use the mode as conditions in other automations. So for instance, I have lights come on low at night if anyone goes downstairs, but only if the mode is set to “night”, that way they are not triggering during the evening when I am watching TV.
You could maybe adapt something similar for your setup? I end up having the following modes:
Morning (triggered by motion after 5am) - downstairs lights come on
Day (triggered by outside light > 200lux) - all lights off
Evening (triggered by outside light < 200 lux within 2hrs of sunset) - Lights on
Night (manually triggered by telling Alexa its bedtime) - all lights off, motion detection triggered for downstairs lighting
I now am at the point where I rarely have to worry about the lights downstairs they just take care of themselves
If you need something a little more complicated, you could for instance set an additional “do not disturb” flag when you are running your “watch tv” scene that would disable the motion lights.
Interesting, would you mind sharing your config (or that part)? I think I could use that with a script o set a “living room is empty” flag if no motion is detected for 30 minutes, and then have a trigger that only fires if motion is detected and the flag is set.
I tried just setting it for transitions from off to on, but if we sat too still and then moved it would trigger.
Sure - I might put the whole thing up as an example, but for now, here are some bits to get you started (apologies, all my files are split up so you’ll have to figure out the indentation and missing keywords, let me know if you have trouble with that part)
First I create the input boolean.
house_mode:
name: House Mode
icon: mdi-home
options:
- Morning
- Day
- Evening
- Night
initial: Day
Here is an example of me setting it for evening mode - an automation:
And finally here is an example of my motion lights automation taking into account the mode:
- alias: 'Night Lights 1'
trigger:
platform: state
entity_id: binary_sensor.downstairs_sensor_26
to: 'on'
condition:
- condition: time
before: '23:59:59'
- condition: time
after: '20:00:00'
- condition: state
entity_id: input_select.house_mode
state: Night
action:
service: script.turn_on
entity_id: script.timed_dim_on
- alias: 'Night Lights 2'
trigger:
platform: state
entity_id: binary_sensor.downstairs_sensor_26
to: 'on'
condition:
- condition: time
before: '05:30:00'
- condition: time
after: '00:00:00'
- condition: state
entity_id: input_select.house_mode
state: Night
action:
service: script.turn_on
entity_id: script.timed_dim_on
I have this as 2 separate automations to avoid spanning midnight as that did not work at the time, I believe it now should be possible to do this with a single automation as of 0.21 but I haven’t tried it out yet.
Hi kelbot, die you already found a way to do something with the “time motion sensor away”? I want to do the same with the sensors in my living room and turning out the lights.
Alternative could be that the state of the sensor stays “on” as long there is movement in every 10 minutes. Important will be that it will not be set to off by a script after 10 minutes after a certain movement while there was movement all the time.