I want a automation to turn off the light when ther is no motinion detectent in twoo pir sensonsors for one minute.
this is mij configuration.
HA doesn’t give a error, but the automation doesn’t work.
what do i have to chance in my code to get it to work?
- action:
- data:
entity_id: light.gang_boven
service: light.turn_off
alias: Gang boven uit
condition:
condition: and
conditions:
- condition: state
entity_id: binary_sensor.pir_trap_beneden
state: 'off'
for:
minutes: 1
- condition: state
entity_id: binary_sensor.pir_trap_boven
state: 'off'
for:
minutes: 1
id: '1519164310758'
trigger:
- entity_id: binary_sensor.pir_trap_beneden
platform: state
to: 'off'
- entity_id: binary_sensor.pir_trap_boven
platform: state
to: 'off'
might be easier to code if you grouped both PIRs together?
Then you’d just have 1 trigger and one condition?
Just a thought…
Also you have a dash (-) in front of action but non in front of condition or trigger. Yaml is rather strict on indentation so you may want to review your formatting?
just a thought:
Your automation gets triggered on state changing to ‘off’
Your conditions state both PIRs must be off for 1 min. I’m guessing that will never be true as one of the PIR will just have changed for the triggers to be true, therefore the condition will never be met.
Can you try this instead (assuming no formatting issues with the dashes)?
- action:
- data:
entity_id: light.gang_boven
service: light.turn_off
alias: Gang boven uit
condition:
condition: and
conditions:
- condition: state
entity_id: binary_sensor.pir_trap_beneden
state: 'off'
- condition: state
entity_id: binary_sensor.pir_trap_boven
state: 'off'
id: '1519164310758'
trigger:
- entity_id: binary_sensor.pir_trap_beneden
platform: state
to: 'off'
for:
minutes: 1
- entity_id: binary_sensor.pir_trap_boven
platform: state
to: 'off'
for:
minutes: 1
As per @keithh666,
If the PIRs don’t send the ‘off’ code, I guess you could change the triggers from to: 'off' to from: 'on'
Hopefully with the info we all provided you get this working