Hi - I’ve made an automation to turn on light when motion is detected, and off again when no motion is detected.
Now i would like to delay turn off for a short time.
I thought it was as simple as to add a time to the condition like this
Thank for taking time to help me with this.
I do see it works to move the timer up to the trigger, and it isn’t needed conditions. But i don’t understand why.
I’ve added another motion sensor to the automation, and it is working.
When i create the automation, the YAML looks a bit different.
But this is working
alias: Autolys Akvarie Lab og Baggang
description: ""
triggers:
- trigger: state
entity_id:
- binary_sensor.philips_sml001_occupancy
from: null
to: "on"
- trigger: state
entity_id:
- binary_sensor.ikea_motion_sensor_2_motion
from: null
to: "on"
- trigger: state
entity_id:
- binary_sensor.ikea_motion_sensor_2_motion
from: null
to: "off"
for:
hours: 0
minutes: 3
seconds: 0
- trigger: state
entity_id:
- binary_sensor.philips_sml001_occupancy
from: null
to: "off"
for:
hours: 0
minutes: 3
seconds: 0
enabled: true
conditions: []
actions:
- choose:
- conditions:
- condition: state
entity_id: binary_sensor.philips_sml001_occupancy
state: "on"
sequence:
- action: light.turn_on
metadata: {}
data: {}
target:
entity_id: light.akvarie_lab_og_baggang
- conditions:
- condition: state
entity_id: binary_sensor.ikea_motion_sensor_2_motion
state: "on"
sequence:
- action: light.turn_on
metadata: {}
data: {}
target:
area_id: akvarie_lab
- conditions:
- condition: and
conditions:
- condition: state
entity_id: binary_sensor.ikea_motion_sensor_2_motion
state: "off"
- condition: state
entity_id: binary_sensor.philips_sml001_occupancy
state: "off"
sequence:
- action: light.turn_off
metadata: {}
data:
transition: 10
target:
area_id: akvarie_lab
mode: single