Self-calling automations not running as expected

I’m posting here to get some attention to my issue…

I’ve some automations failing. These automations worked for years, and stop working after update to 2023.8.
I’ve seen several other similar reports, but in the end are related to an integration. On my case, I’m not sure how to identify the culprit therefore I’m opening a new issue.

This automation, based on some conditions, turns on or off an input_boolean.

After restarting HA, the automation runs as expected. Once it triggers itself a one or two times. I get the following on the trace:

alias: Ricardo away checker Nothing Phone
description: >-
  If Ricardo is away for 10min turns on the input_boolean...Once Ricardo arrives
  home, turns it off
trigger:
  - platform: state
    entity_id:
      - person.ricardo
    to: not_home
    for:
      hours: 0
      minutes: 5
      seconds: 0
    from: home
  - platform: state
    entity_id:
      - person.ricardo
    to: home
    for:
      hours: 0
      minutes: 30
      seconds: 0
    id: return
  - platform: state
    entity_id:
      - sensor.nothing_phone1_ble
      - device_tracker.nothinphone1_fritz
    to: not_home
    for:
      hours: 0
      minutes: 0
      seconds: 0
    from: home
  - platform: state
    entity_id:
      - person.ricardo
    to: Work
condition: []
action:
  - if:
      - condition: not
        conditions:
          - condition: trigger
            id: return
      - condition: state
        entity_id: sensor.nothing_phone1_ble
        state: home
      - condition: state
        entity_id: device_tracker.nothinphone1_fritz
        state: home
    then:
      - stop: BLE, BT and WIFI report Ricardo at home.
  - if:
      - condition: not
        conditions:
          - condition: trigger
            id: return
      - condition: state
        entity_id: sensor.nothing_phone1_ble
        state: not_home
      - condition: not
        conditions:
          - condition: state
            entity_id: sensor.nphone1_wifi_connection
            state: 0rion
        enabled: true
      - condition: state
        entity_id: input_boolean.ricardo_away_10_min
        state: "off"
        for:
          hours: 0
          minutes: 3
          seconds: 0
      - condition: state
        entity_id: device_tracker.nothinphone1_fritz
        state: not_home
      - condition: or
        conditions:
          - condition: state
            entity_id: binary_sensor.withings_bed_occupancy_ricardo
            state: "off"
          - condition: state
            entity_id: binary_sensor.withings_bed_occupancy_ricardo
            state: unavailable
    then:
      - service: input_boolean.turn_on
        data: {}
        target:
          entity_id: input_boolean.ricardo_away_10_min
      - service: notify.ricardo
        data:
          message: You've been successfully set away!
          title: ✅ Set away!
    else:
      - delay:
          hours: 0
          minutes: 1
          seconds: 0
          milliseconds: 0
      - if:
          - condition: state
            entity_id: input_boolean.ricardo_away_10_min
            state: "off"
        then:
          - service: automation.trigger
            data:
              skip_condition: false
            target:
              entity_id: automation.ricardo_away_checker_nothing_phone
        enabled: true
    enabled: true
  - if:
      - condition: trigger
        id: return
    then:
      - service: input_boolean.turn_off
        data: {}
        target:
          entity_id: input_boolean.ricardo_away_10_min
mode: restart

If someone could help me identifying the root cause I would be very thankful.

Can someone try to help on this? Or let me know how I can provide more meaningful information

When an automation employs automation.trigger on itself, it’s effectively using itself like a script (because neither the automation’s trigger or condition are executed, only its action). Generally speaking, this is not a recommended design pattern; I have seen many reports of operational problems when this ill-advised pattern is employed. In all cases, I recommend redesigning the automation to avoid calling itself in this manner.

Change it to mode queued and it would probably work. Outside that, I agree with 123 on this. There’s no reason for recursion in an automation or even a script. Especially if you’re using restart mode.

That’s not the point… These automation worked for years… and there’s no way to create a loop in scripts / automations…

Something has changed in August that broke this…

I’ve seen that in similar issues they troubleshoot it to the integrations on the automation itself, but I’m not sure how to do the same.

Yes there is, repeat

- repeat:
    while:
    - condition: state
      entity_id: foo.bar
      state: "on"
    sequence:
    - service: ....
      data:
        ....

There’s a few different repeat types, see link

The change that was made was the timeouts on service calls were removed. So automations now stall when devices & services don’t respond or exit correctly. Find out what device/service is stalling the execution of the automation and report it as an issue on github.

How can I find out?

Look at the automations trace, it’ll show the last run and where it stopped.