Repeat Notifications with Delay Option

I’m trying to set up a system to notify me to get my laundry out of the washer. I’d like this to send me another notification every 5 minutes until I use the actionable notification to mark it complete, I’ve gotten this part to work in a separate automation. But I’d ALSO like to have an option to delay the next notification for a set amount of time, 30 minutes in this example.

I think I have the general set up correct, I have a helper number set to the amount of time to delay the notifications, so when I set to delay 30 minutes the helper gets changed to 30. I think I’m running into issues with me choose / wait for trigger section. Anyone have any thoughts?

alias: Notification_Laundry TEST
description: ""
trigger:
  - platform: state
    entity_id:
      - timer.washing_machine
    from: active
    to: idle
condition: []
action:
  - service: input_boolean.turn_on
    data: {}
    target:
      entity_id: input_boolean.washing_machine
  - service: input_number.set_value
    metadata: {}
    data:
      value: 5
    target:
      entity_id: input_number.washing_machine_notification
  - parallel:
      - repeat:
          sequence:
            - service: notify.mobile_app_nicks_iphone
              metadata: {}
              data:
                message: Laundry is done!
                data:
                  actions:
                    - action: WASHER_EMPTIED
                      title: Done
                    - action: DELAY_30
                      title: Delay 30 Minutes
            - delay:
                hours: 0
                minutes: >-
                  {{ states('input_number.washing_machine_notification') | int
                  }} 
                seconds: 0
                milliseconds: 0
          until:
            - condition: state
              entity_id: input_boolean.washing_machine
              state: "off"
      - if:
          - condition: state
            entity_id: input_boolean.washing_machine
            state: "on"
        then:
          - wait_for_trigger:
              - platform: event
                event_type: mobile_app_notification_action
                event_data:
                  action: WASHER_EMPTIED
              - platform: event
                event_type: mobile_app_notification_action
                event_data:
                  action: DELAY_30
            timeout:
              hours: 6
              minutes: 0
              seconds: 0
              milliseconds: 0
          - choose:
              - conditions:
                  - condition: template
                    value_template: "{{ wait.trigger.event.data.action == WASHER_EMPTIED }}"
                sequence:
                  - service: input_boolean.turn_off
                    metadata: {}
                    data: {}
                    target:
                      entity_id: input_boolean.washing_machine
              - conditions:
                  - condition: template
                    value_template: "{{ wait.trigger.event.data.action == DELAY_30 }}"
                sequence:
                  - service: input_number.set_value
                    metadata: {}
                    data:
                      value: 30
                    target:
                      entity_id: input_number.washing_machine_notification
mode: single

you have the the last ‘if’ block running in parallel with your repeat block. and the ‘if’ block, being outside of the repeat, happens once… it waits and sets a value then exits. is that what you want?

the code is kinda hard to read and follow. what’s the purpose of doing these things in parallel? and having one of them repeat and one run once?

take a look at this… note that i’m not really able to test it, so it’s free hand written… my intent is to offer a simplified way that might do what you want… typically something simpler is going to have fewer issues… and especially having things that run in parallel and depend upon each other and modify the state for each other is often fragile… so i’ve eliminated that.

i’m using your input_number as the keeper of how long to wait… i change that to 30 or 5 to say how long it should wait until the next notificatoin. and i change it to 0 to say ‘done’.

alias: Notification_Laundry TEST
description: ""
trigger:
  - platform: state
    entity_id:
      - timer.washing_machine
    from: active
    to: idle
condition: []
action:
  - repeat:
      sequence:
        - service: notify.mobile_app_nicks_iphone
          data:
            message: Laundry is done!
            data:
              actions:
                - action: WASHER_EMPTIED
                  title: Done
                - action: DELAY_30
                  title: Delay 30 Minutes
        - wait_for_trigger:
            - platform: event
              event_type: mobile_app_notification_action
              event_data:
                action: WASHER_EMPTIED
            - platform: event
              event_type: mobile_app_notification_action
              event_data:
                action: DELAY_30
          timeout:
            minutes: >-
              {{ states('input_number.washing_machine_notification') | int
              }} 
        - service: input_number.set_value
          data:
            value: 5
          target:
            entity_id: input_number.washing_machine_notification
        - choose:
            - conditions:
                - condition: template
                  value_template: "{{ wait.trigger.event.data.action == WASHER_EMPTIED }}"
              sequence:
                - service: input_number.set_value
                  data:
                    value: 0
                  target:
                    entity_id: input_number.washing_machine_notification
            - conditions:
                - condition: template
                  value_template: "{{ wait.trigger.event.data.action == DELAY_30 }}"
              sequence:
                - service: input_number.set_value
                  data:
                    value: 30
                  target:
                    entity_id: input_number.washing_machine_notification
      until:
        - condition: template
          value_template: "{{states('input_number.washing_machine_notification') | int == 0}}"
mode: single

Or just use this:

2 Likes

what’s the fun in that!!!??? :stuck_out_tongue_winking_eye:

1 Like

Yikes didn’t realize you could use companion app notifications with the alert system. Thanks!

1 Like