Trigger and condition both with FOR clause

Hi there,

I have 1 motion sensor and 1 light in the hall way below and 1 of each in the hall way above.

Both motion sensors trigger all lamps and once there is no motion sensed for 4 minutes in either all lights should switch off.

But here I’m having a little trouble configuring this. This is what I have;

- alias: 'Turn off hall way lights after last movement'
  trigger:
    - platform: state
      entity_id: binary_sensor.presence_9
      to: 'off'
      for:
        minutes: 4
  condition:
    - condition: template
      value_template: '{{ not is_state("input_select.house_mode","Jazz home alone") }}' 
    - condition: state
      entity_id: binary_sensor.presence_11
      to: 'off'
      for:
        minutes: 4
  action:
      - service: light.turn_off
        entity_id: light.hall_way   

This is what I would like to have; check if downstairs motion sensor didn’t have movement for 4 minutes AND upstairs doesn’t have motion for 4 minutes and THEN switch off lights

But here I’m getting a Invalid config for [automation]: extra keys not allowed @ data[‘condition’][1][‘for’] so apparently a FOR is not allowed which I find a bit weird because the documentation mentions them https://www.home-assistant.io/docs/scripts/conditions/

An alternative would be that I could specifiy two triggers with an AND but I know this it not supported.

What am I doing wrong or do you guys know an alternative way of getting this done?

Thanks

Line 13 should be state: 'off' , which probably doesn’t help.

Having FOR in conditions is a fairly recent addition, are you running the latest version?

Completely overlooked that even when triple checking the syntax. Will change it once I’m home. Think that will fix it. I’m running the latest version.

Thanks!

If you want both lights to go off when there has been no motion for at least 4 minutes in both hallways, you can do this with one automation. Just trigger with both motion sensors and use both motion sensors in the condition. So it will try to trigger whenever either motion detector has not seen motion for 4 minutes, but it will only run the action (i.e., turn off both lights) if both motion detectors have not seen motion for at least 4 minutes.

EDIT: I believe this should work:

- alias: 'Turn off hall way lights after last movement'
  trigger:
    - platform: state
      entity_id: binary_sensor.presence_9, binary_sensor.presence_11
      to: 'off'
      for:
        minutes: 4
  condition:
    - condition: template
      value_template: '{{ not is_state("input_select.house_mode","Jazz home alone") }}' 
    - condition: state
      entity_id: binary_sensor.presence_9
      state: 'off'
      for:
        minutes: 4
    - condition: state
      entity_id: binary_sensor.presence_11
      state: 'off'
      for:
        minutes: 4
  action:
    - service: light.turn_off
      # Does this control both lights? If not, just add entity_id of other light
      entity_id: light.hall_way

Thanks pnbruckner, works like a charm. This is much more elegant and prevents double configuration code.