2 PIR off automation

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'
indent preformatted text by 4 spaces

ganglicht uit.yaml (607 Bytes)

Format (not spacing) looks wrong to me:

  id
  alias
  trigger
  condition
  action

I don’t use ID myself but everything else is the format I use as far as order is concerned.

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?

The internal automation editor always formats the code like that :frowning:

Most pir’s don’t report an ‘off’ state, are you sure yours do?

1 Like

soooo lovelly :smiley:

@Roy like @lolouk44 mention try like this:

- 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'

I must be going blind what’s different?

His first condition is missing a dash.

And I see now Trigger also doesnt have a dash only Action.
maybe that’s the problem? :thinking:

Well spotted :slight_smile: could be!

I never used the automation editor and if it adds dashes to action, trigger or conditions, maybe just remove them :stuck_out_tongue:

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
1 Like

We still don’t know that the pir’s send the off code :P, if they are 433 pir’s then they probably don’t, if zwave or zigbee they probably do.

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 :slight_smile:

thank you, it works now.

yes, i bild it out of Sonnofs. so it have a off state