Notification to Repeat

Hi,

I’m trying to create a notification that announces my plants need to be watered when my moisture sensor falls below a setpoint. I’d like it to repeat every 20 mins. until they are watered. I am able to get it to work without the repeat commands included, but as soon as I try to intetgrate the while loop I get a “Message malformed: required key not provided @ data[‘action’]” error. Here is the script:

alias: Plant Water Notification
description: ""
trigger:
  - type: humidity
    platform: device
    device_id: 36ee92b83327314f44dd9eb7fdb0f9f0
    entity_id: f4761bf9b21a11207d5a7773ea0bf2ed
    domain: sensor
    below: 28
    for:
      hours: 0
      minutes: 2
      seconds: 0
  - type: humidity
    platform: device
    device_id: 36ee92b83327314f44dd9eb7fdb0f9f0
    entity_id: 88d39f0da77b0159ade3decc767da8a7
    domain: sensor
    below: 28
  - type: humidity
    platform: device
    device_id: 36ee92b83327314f44dd9eb7fdb0f9f0
    entity_id: ae4aa1225d18bef545e20f177c786803
    domain: sensor
    below: 28
condition:
  - condition: state
    entity_id: binary_sensor.zone_6_family_room_motion
    state: "on"
action:
  - repeat:
      while:
        - condition: numeric_state
          entity_id: sensor.gw1100b_soil_moisture_1
            below: 15
        sequence:
          - service: notify.alexa_media_joshua_s_sonos_move
            metadata: {}
            data:
              message: Time to water the plants, Bitch!!
          - service: notify.alexa_media_bose_speaker_bose
            metadata: {}
              data:
                message: Time to water the plants, Bitch!!
          -delay:
              minutes: 20
mode: single

You’re missing a space between the hyphen and “delay” which would cause an error.

In addition to the delay issue mentioned above, you need to fix the indentation. The key below is indented too much and the keys while and sequence should be aligned with each other.

alias: Plant Water Notification
description: ""
trigger:
  - type: humidity
    platform: device
    device_id: 36ee92b83327314f44dd9eb7fdb0f9f0
    entity_id: f4761bf9b21a11207d5a7773ea0bf2ed
    domain: sensor
    below: 28
    for:
      hours: 0
      minutes: 2
      seconds: 0
  - type: humidity
    platform: device
    device_id: 36ee92b83327314f44dd9eb7fdb0f9f0
    entity_id: 88d39f0da77b0159ade3decc767da8a7
    domain: sensor
    below: 28
  - type: humidity
    platform: device
    device_id: 36ee92b83327314f44dd9eb7fdb0f9f0
    entity_id: ae4aa1225d18bef545e20f177c786803
    domain: sensor
    below: 28
condition:
  - condition: state
    entity_id: binary_sensor.zone_6_family_room_motion
    state: "on"
action:
  - repeat:
      while:
        - condition: numeric_state
          entity_id: sensor.gw1100b_soil_moisture_1
          below: 15
      sequence:
        - service: notify.alexa_media_joshua_s_sonos_move
          metadata: {}
          data:
            message: Time to water the plants, Bitch!!
        - service: notify.alexa_media_bose_speaker_bose
          metadata: {}
          data:
            message: Time to water the plants, Bitch!!
        - delay:
            minutes: 20
mode: single

Thank you both for the replies. That solved the problem. I didn’t realize how important indenting was to the success of the automation.

Thank you again!