While/until repeat not working?

I have this seemingly fairly simple automation that i can’t get to run it’s actions. I tried while and until, both with on and off states for the group but it is not working. It’s triggering, but not announcing anything.

The flood group is definitely going to on or off, depending on the flood sensors being triggered. I do use a 433 sensor, but that shouldn’t matter. Might be few seconds to detect, but on is on, off is off one would think.

What have i missed here?

- id: '1642836191931'
  alias: Water leak Announce In Progress
  description: Announce water leak is in progress while the flood sensor group is
    turned on
  trigger:
  - platform: state
    entity_id: group.flood_sensors_group
    to: 'on'
  condition: []
  action:
  - repeat:
      while:
      - condition: state
        entity_id: group.flood_sensors_group
        state: 'on'
      sequence:
      - service: notify.alexa_media_everywhere
        data:
          message: Water Leak In Progress
          data:
            type: announce
            method: all
  mode: single

have you checked the trace of the automation within GUI?
Are you sure the loop is never executed?

I am asking this, because as far as I know, you cannot sent an announcement to the everywhere group via alexa_media …so it might be not the loop which is not execute but the service call :wink:

My workaround here to perform announcements via alexa was a “spoken command”:

          - service: media_player.play_media
            data_template:
              entity_id: media_player.this_device
              media_content_id: "kündige an, dass {{ text }}"
              media_content_type: custom
1 Like

My guess is that it’s looping too often which means it makes the media player just load and not play.

Try and add a delay of 15 seconds in the loop.

3 Likes

Interesting. Pretty sure i did it before, but i’ll check that.

Yes, also good point. Let me try that as well.

Were you able to resolve this?
Would be great if you could share your outcome with the community or mark the correct answer.

Thanks :slight_smile:

Yes. So the service call was fine, what i did was add a 10-15 delay after the service call. I was thinking in this direction as well, as a debug would take a long time to load as it must have been stuck in a very tight loop.

e.g.

repeat:
  until:
    - condition: state
      entity_id: group.flood_sensors_group
      state: 'off'
      for:
        hours: 0
        minutes: 2
        seconds: 0
  sequence:
    - service: notify.alexa_media_everywhere
      data:
        message: Water Leak In Progress
        data:
          type: announce
          method: all
    - delay:
        hours: 0
        minutes: 0
        seconds: 10
        milliseconds: 0
1 Like