Why is my repeat only running once?

Hello! I want to implement a loop in an action, so I got a repeat like:

action:

  - choose:

    - conditions:
      - condition: template
        value_template: "{{ ... }}"
   
      sequence:
        - service: climate.turn_off
          target:
            entity_id: !input trv

        - repeat:
            count: 4
            sequence:
              
              - delay: '00:00:10'

              - service: notify.signal_test
                data: 
                  message: "A loop!"

The problem: The Signal-message is only sent once after 10 seconds, but not after 20 or 30 or 40 seconds. So the sequence in the repeat is only execute once.

I tried the same with a condition:

        - repeat:
            sequence:
              
              - delay: '00:00:10'

              - service: notify.signal_test
                data: 
                  message: "A loop!"

            until:
              - condition: state
                entity_id: binary_sensor.windowsensor_opening
                state: "on" # Tried "off" as well just to be sure...

but it’s only running once as well.

What am I missing? No errors occur in the log, the trace shows that the loop is only running once and then is just ending quietly without any hint, why.

It’s hard to diagnose with only part of the picture, see item 11:

And post the entirety of your YAML. It could be that your value template is the problem. I can tell you that I did a quick test to see if there is a bug somewhere and this ran perfectly fine:

alias: "Automation Test"
description: ""
trigger:
  - platform: state
    entity_id:
      - light.greatroom_hallway
    to: "on"
condition: []
action:
  - repeat:
      count: 3
      sequence:
        - service: persistent_notification.create
          data:
            message: TEST
            title: TEST
        - delay:
            hours: 0
            minutes: 0
            seconds: 5
            milliseconds: 0
mode: single

2 Likes

Thanks for your reply. I thought I did an obvious mistake somehow, but it seems to be more difficult…

I made the following automation for testing in automations.yaml:

- id: '1700459058808'
  alias: "Test-Loop"
  description: ''
  trigger: []
  condition: []
  action:
    - repeat:
        count: 3
        sequence:
          - service: notify.signal_test # persistent_notification.create
            data:
              message: TEST
              title: TEST
          - delay:
              hours: 0
              minutes: 0
              seconds: 5
              milliseconds: 0
  mode: single

and started in manually. I’m still getting only one message.

When starting the automation again manually, I’m getting the error:
WARNING (MainThread) [homeassistant.components.automation.test_loop] Test-Loop: Already running

And: When using persistent_notification.create instead of notify.signal_test, it works.

Seems to me like the Signal-service somehow crashes preventing the loop to continue… Hm.

Okay, just updating the signal docker-container (I’m using GitHub - bbernhard/signal-cli-rest-api: Dockerized Signal Messenger REST API) did the trick. Sorry for blaming HA :blush: :wink: