Help with 'Repeat Until'

Hi,
Trying to get my Co2 automation working. When triggered I want my lights to turn on any my Alexa to repeat a message until the Co2 sensor returns to an off state.

Below is my automation but it is only tuning my lights on. If I change the repeat action to a call service then Alexa makes the announcement successfully.

Any pointers to what is going wrong with the repeat until action?

- id: '1631363815831'
  alias: Co2 Alert
  description: ''
  trigger:
  - platform: state
    entity_id: binary_sensor.co_detector_co
    from: 'off'
    to: 'on'
  condition: []
  action:
  - service: homeassistant.turn_on
    target:
      entity_id: group.safety_lights
  - repeat:
      until:
      - condition: state
        entity_id: binary_sensor.co_detector_co
        state: 'off'
      sequence:
      - service: notify.alexa_media_living_room
        data:
          message: Emergency! Carbon dioxide detected.
          data:
            type: announce
            method: speak
  mode: single

Add a short delay immediately after notify.alexa_media_living_room service call. The delay’s duration should be more than the amount of time it takes to say the message (perhaps 5-10 seconds). Without a delay, the repeat iterates as fast as your computer allows it, thereby bombarding Alexa with requests to speak (and there’s probably a rate-limiter somewhere that cancels all of them).

      sequence:
      - service: notify.alexa_media_living_room
        data:
          message: Emergency! Carbon dioxide detected.
          data:
            type: announce
            method: speak
      - delay: '00:00:10'
2 Likes

Exactly right - Thanks again!

Do you mean CO - carbon monoxide v CO2 carbon dioxide? It could be either. It does not affect what you are doing but from a warning it could mean very different things. I ask because the sensor is co_binary_co.

You’re correct - I meant carbon monoxide. Speech message changed.