Hi there,
after trying out a lot of things that worked sometimes or not at all, I would be grateful for some advice. We have stairwell light groups and different motion sensors (Tradfri/Sonoff RF motion sensors/Sonoff Switches with ESPhome+HCSR501). In general the hardware works but I cant get the off-automation properly triggered. Basically it should be: If all sensors are clear for X seconds, turn the lights off. In other words: While motion is detected, leave the lights on; when not, turn them off after X seconds. Or: When motion is detected, delay the off-command by X seconds… I think you get it
Here is our/one yaml (only with 2 sensors for testing purposes). Thanks guys!
And binary_sensor.pir_sensor_7 has been off for 10 seconds
And binary_sensor.pir_sensor_10 has been off for 10 seconds
Turn off group.stairwell_floor_three
Oh, and that and condition isn’t doing what you think it is. You’ll likely want to re-read the docs on that.
That’s not what you said you wanted. Remember, triggers are the thing that start an automation - conditions are then checked. This is likely what you really wanted:
- id: '1632393316283'
alias: Light Off Floor Three
description: ''
trigger:
- platform: state
entity_id: binary_sensor.pir_sensor_7
to: 'off'
for: '00:00:10'
- platform: state
entity_id: binary_sensor.pir_sensor_10
to: 'off'
for: '00:00:10'
condition:
- condition: state
entity_id: group.stairwell_floor_three
state: 'on'
- condition: state
entity_id: binary_sensor.pir_sensor_7
state: 'off'
for: '00:00:10'
- condition: state
entity_id: binary_sensor.pir_sensor_10
state: 'off'
for: '00:00:10'
action:
- service: homeassistant.turn_off
target:
entity_id: group.stairwell_floor_three
mode: single
If you’re writing it in YAML you can collapse it though:
- id: '1632393316283'
alias: Light Off Floor Three
description: ''
trigger:
- platform: state
entity_id:
- binary_sensor.pir_sensor_7
- binary_sensor.pir_sensor_10
to: 'off'
for: '00:00:10'
condition:
- condition: state
entity_id: group.stairwell_floor_three
state: 'on'
- condition: state
entity_id:
- binary_sensor.pir_sensor_7
- binary_sensor.pir_sensor_10
state: 'off'
for: '00:00:10'
action:
- service: homeassistant.turn_off
target:
entity_id: group.stairwell_floor_three
mode: single