Binary Sensor last tripped time issue

I have no problem with multiple entities in the state trigger although my spacing is different.

image

I use it in different automations but I know this one works

automation basement_hall_movement:
  - alias: basement_hall_movement
    trigger:
      - platform: state
        entity_id:
         - binary_sensor.basement_hall_motion
         - binary_sensor.exercise_rooom_motion
        to: 'on'
      - platform: state
        entity_id:
         - binary_sensor.basement_hall_motion
         - binary_sensor.exercise_rooom_motion
        to: 'off'
        for:
          minutes: 2
    action:
      service_template: '{% if trigger.to_state.state == "on" %}homeassistant.turn_on{% elif trigger.to_state.state == "off" %}homeassistant.turn_off{% endif %}'
      entity_id: light.basement_hall_light

Revisiting this again, as life got in the way.

I tried what @RobDYI showed with the multiple entity_id records, but no dice.

Here is what I have. It will only fire off if BOTH binary sensors go from closed to open. If I try to list entity_id twice under the platform: state field, it tells me that entity_id is duplicated. Any more ideas?

#Door left open longer than 5 minutes
  - alias: Window or Door left open longer than 5 minute
    trigger:
      - platform: state
        entity_id: 
         - binary_sensor.carport_door
         - binary_sensor.office_windows
        to: 'on'
        for:
          minutes: 5

I would just split the triggers like chairstacker suggested.

- entity_id: binary_sensor.office_windows
  to: 'on'
  for:
    minutes: 5
- entity_id: binary_sensor.guest_windows
  to: 'on'
  for:
    minutes: 5

Yep, that will work. Kinda ugly code for multiple triggers, but it will work. One slight modification here, you must reference the platform each time. Simply referencing the multiple entity_id will result in an error.

trigger:
  - platform: state
    entity_id: binary_sensor.office_windows
    to: 'on'
    for:
      minutes: 5
  - platform: state 
    entity_id: binary_sensor.guest_windows
    to: 'on'
    for:
      minutes: 5
1 Like