YAML help in Automation

Hello All,

Hoping someone here can point me in the right direction. I’m trying to create an automation that announces over Alexa that the freezer has been left open. Here is what I got so far…

alias: Freezer Alexa notification
initial_state: "on"
description: ""
trigger:
  - platform: state
    entity_id:
      - binary_sensor.aqara_freezer_opening
    from: "off"
    to: "on"
    for:
      hours: 0
      minutes: 4
      seconds: 0
action:
  - service: notify.alexa_media
    data:
      target:
      - media_player.everywhere
      data:
        type: announce
      message: The freezer is open
mode: single

When I try to run this it tells me Error: ‘NoneType’ object is not iterable when I look at the traces. Not exactly sure what this means. I’m reasonably sure it is the trigger causing this. It works with a time only trigger. These next thing I would like to do is have the message repeat every x minutes until someone closes it. Any thoughts on how to make that happen? As you can tell I’m new to this. Thanks.

Use a Repeat action:

alias: Freezer Alexa notification
initial_state: "on"
description: ""
trigger:
  - platform: state
    entity_id:
      - binary_sensor.aqara_freezer_opening
    from: "off"
    to: "on"
    for: "00:04:00"
action:
  - repeat:
      while:
        - condition: state
          entity_id: binary_sensor.aqara_freezer_opening
          state: "on"
      sequence:
        - service: notify.alexa_media_everywhere
          data:
            message: The fridge is open
            data:
              type: announce
        - delay: "00:02:00"

or switch to an Alert.

Thank you for this! Took me a little time to get back to it. Works great!!