home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
71.11k stars 29.79k forks source link

Automation waits 5 minutes after executing service call #107763

Closed jay-kub closed 8 months ago

jay-kub commented 8 months ago

The problem

After the automation executes a cover.open service call, it waits 300 seconds before moving to the next action.

What version of Home Assistant Core has the issue?

2024.1.2

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant OS

Integration causing the issue

Automation

Link to integration documentation on our website

No response

Diagnostics information

No response

Example YAML snippet

alias: Get Home - Jacob
description: Open Garage or Unlock Door, Disarm Alarm
trigger:
  - platform: state
    entity_id:
      - person.jacob
    from: not_home
    to: home
    id: person_is_home
  - platform: state
    entity_id:
      - device_tracker.ble_jake_s_p7_espresense_helper
    from: not_home
    to: home
    id: espresense_is_home
    enabled: true
condition:
  - condition: state
    entity_id: binary_sensor.jake_away_more_than_5_minutes
    state: "on"
  - condition: template
    value_template: |-
      {{ now() - state_attr('automation.get_home_ang',
            'last_triggered') > timedelta(minutes=5) }}
action:
  - if:
      - condition: state
        entity_id: cover.garage_door
        state: closed
        for:
          hours: 0
          minutes: 5
          seconds: 0
    then:
      - if:
          - condition: or
            conditions:
              - condition: state
                entity_id: binary_sensor.jake_s_pixel_7_android_auto
                state: "on"
              - condition: state
                entity_id: binary_sensor.jake_s_phone_connected_to_mazda_cx5
                state: "on"
              - condition: state
                entity_id: binary_sensor.jake_s_phone_connected_to_toyota_corolla
                state: "on"
        then:
          - service: cover.open_cover
            data: {}
            target:
              entity_id: cover.garage_door
          - service: script.get_home_fail_safe
            data: {}
        else:
          - service: lock.unlock
            data: {}
            target:
              entity_id: lock.front_door
    enabled: true
  - if:
      - condition: not
        conditions:
          - condition: state
            entity_id: alarm_control_panel.alarmo
            state: disarmed
    then:
      - service: alarmo.disarm
        data:
          code: (redacted)
          entity_id: alarm_control_panel.alarmo
      - wait_for_trigger:
          - platform: state
            entity_id:
              - binary_sensor.door_entry_contact
            to: "on"
          - platform: state
            entity_id:
              - binary_sensor.door_garage_contact
            to: "on"
        timeout:
          hours: 0
          minutes: 5
          seconds: 0
          milliseconds: 0
        continue_on_timeout: false
      - delay:
          hours: 0
          minutes: 0
          seconds: 3
          milliseconds: 0
      - service: tts.google_translate_say
        data_template:
          cache: false
          entity_id: media_player.kitchen_entry
          message: (redacted)
          language: en-ie
mode: queued
max: 2

Anything in the logs that might be useful for us?

No response

Additional information

I don't see any relevant errors in the logs, but I can see that the service call was successful. The state of the cover changed to opening within a few milliseconds and then to open within ~10 seconds. It's not clear what the automation is waiting for. image

jay-kub commented 8 months ago

Solved: since I'm calling the script directly, it waits for the script to be complete. Updating that action to script.turn_on should resolve the issue.

https://www.home-assistant.io/integrations/script/#waiting-for-script-to-complete