#Multiple wait conditions with duration before actions start

1 messages · Page 1 of 1 (latest)

lunar oak
#

Hi,

I'm having issue configuring automation that waits for multiple entities states for specific duration before actions get executed. I have tried wait_trigger but it needs the state to change to specific one before automation starts, so it didn't seem to work. The wait_template doesn't seem to have an option to configure the duration needed for the state to be in, before evaluating true. When I add the conditions for and if, it seems to just outright fail it if the duration isn't met.

Do you guys have any other suggestions, so it waits until all conditions are met before it runs actions?

alias: Close Garage Door after Car Detected in Garage
description: ""
trigger:
  - platform: state
    entity_id:
      - binary_sensor.garage_inside_car_occupancy
    to: "on"
condition: []
action:
  - if:
      - type: is_not_connected
        condition: device
        device_id: 0e711c4afe1a3bb57eb4bd4da5274ea8
        entity_id: 4254f2af9b434c3737fd04d4ce0f9f17
        domain: binary_sensor
      - condition: zone
        entity_id: person.maxver
        zone: zone.home
      - condition: state
        entity_id: cover.ratgdov25i_0b06d3_door
        state: open
        for:
          minutes: 2
      - condition: state
        entity_id: binary_sensor.ratgdov25i_0b06d3_obstruction
        state: "off"
        for:
          minutes: 1
    then:
      - service: notify.mobile_app
        data:
          message: Closing Car Garage Door
lunar oak
#

Multiple wait conditions with duration before actions starts

#

Multiple wait conditions with duration before actions start

lunar oak
#

I have came up with this; using repeat until with the delay of 10 seconds. So, once the all conditions are true, the loop will finish and will proceed with other actions. However this doesn't seem optimal. Any suggestions on how to improve below?

alias: Close Garage Door after Car Detected in Garage
description: ""
triggers:
  - trigger: state
    entity_id:
      - binary_sensor.garage_inside_car_occupancy
    to: "on"
conditions: []
actions:
  - repeat:
      sequence:
        - delay:
            hours: 0
            minutes: 0
            seconds: 10
            milliseconds: 0
      until:
        - type: is_not_connected
          condition: device
          device_id: 0e711c4afe1a3bb57eb4bd4da5274ea8
          entity_id: 4254f2af9b434c3737fd04d4ce0f9f17
          domain: binary_sensor
          for:
            hours: 0
            minutes: 0
            seconds: 20
        - condition: zone
          entity_id: person.maxver
          zone: zone.home
        - condition: state
          entity_id: binary_sensor.ratgdov25i_0b06d3_obstruction
          state: "off"
          for:
            hours: 0
            minutes: 1
            seconds: 0
        - type: is_off
          condition: device
          device_id: 0e711c4afe1a3bb57eb4bd4da5274ea8
          entity_id: a3133065d44f83a5dcc51520c49f270c
          domain: binary_sensor
          for:
            hours: 0
            minutes: 1
            seconds: 0
  - device_id: 0e711c4afe1a3bb57eb4bd4da5274ea8
    domain: mobile_app
    type: notify
    message: Closing Car Garage Door
  - type: notify
    device_id: 0e711c4afe1a3bb57eb4bd4da5274ea8
    domain: mobile_app
    message: TTS
    data:
      ttl: 0
      priority: high
      media_stream: media_stream
      tts_text: Closing Car Garage Door
mode: single
junior ridge
#

I generally recommend creating automations that complete quickly, which means avoiding delays and repeat-until loops whenever possible.
In this automation, does it matter which order everything happens? Does the entity binary_sensor.garage_inside_car_occupancy need to happen before everything else? If order isn't critical, I'd suggest an automation where each of those items are triggers, and then they are also all conditions in the conditions ("and if") section also. That way, when any one of them occurs, the automation will check if all the others are already true, and will run the actions if so.