I currently have the following two automations to turn on and off the light with a motion sensor (more specifically two motion sensors grouped in binary_sensor.group_flur_sensor_occupancy). They are below.
I would like to consolidate these two automations into a single automation to simplify things. (I use the same configuration in other rooms.)
How would I do this?
This automation turns ON the light, when motion is detected:
alias: automation__flur__automatisches_licht_an
description: ""
mode: single
triggers:
- entity_id:
- binary_sensor.group_flur_sensor_occupancy
from: "off"
to: "on"
trigger: state
actions:
- target:
entity_id: light.group_flur_licht_decke
data: {}
action: light.turn_on
This automation turns OFF the light, when no motion is detected for 5 minutes:
This takes into consideration time of day, not to switch on the light during day light hours. Also not switching on the light when walking into the room after midnight, I need to manually switch it on if I need lights.
Thank you for the replies. That is very helpful.
I have a follow-up question: Is it possible to set the time-out based on the time of day, e.g. using templating. I.e. is it possible to do something like this(?):
- platform: state
entity_id: binary_sensor.your_motion_sensor_here # change this
to: 'off'
for:
minutes: 2 # use templating to set the value here
Would be possible, but not so sure about using the template example.
Using the choose actions from my earlier example, you would be able to start a timer as an action. The times can be of different durations to control how long the light would need to stay on for based on the time of day.