Please help with repeated automation (repeat until, android companion, event)

Hi everybody,

I built this by using the example provided in the mobile companion docs. For some reason I cannot figure out myself, the action that is supposed to happen via notify.mobil (input_boolean.turn_on) does not happen.

Can you please help me with this?

automation:
### This will turn OFF an input_boolean in order to
### trigger the ALERT that I initially used for this
  - alias: "Notify Helper Vacuum Off"
    trigger:
      - platform: time
        at: input_datetime.helper_medusa_check
    action:
      - service: input_boolean.turn_off
        entity_id: input_boolean.helper_medusa_oben
### This gets triggered by said input_boolean
  - alias: "Mobile: Medusa Oben"
    trigger:
      - platform: state
        entity_id: input_boolean.helper_medusa_oben
        to: "off"
    mode: single
    action:
      - alias: "Bis sie oben ist wiederholen"
        repeat:
          sequence:
            # inside a automation actions or script sequence
            - alias: "Variabeln festlegen"
              variables:
                # Including an id in the action allows us to identify this script run
                # and not accidentally trigger for other notification actions
                action_erledigt: "{{ 'ERLEDIGT_' ~ context.id }}"
                action_close: "{{ 'CLOSE_' ~ context.id }}"
### FIRST, clear any notifications with this TAG that
### might already exist (as they'd be identical; this tag is only used once)         
            - service: notify.mobil
              data:
                message: "clear_notification"
                data:
                  tag: medusahoch
            - delay:
                seconds: 2
### THEN, send the next notification
            - service: notify.mobil
              data:
                message: "Bitte Medusa nach oben holen."
                data:
                  actions:
                    - action: "{{ action_erledigt }}"
                      title: Erledigt
                  tag: medusahoch
            - delay:
                minutes: 15
### I assumed THIS and the delay above would assure that
### the automation would repeat UNTIL that input_boolean 
### would be turned ON again (which is supposed to 
### be handled by this part from above
### =>  action_erledigt: "{{ 'ERLEDIGT_' ~ context.id }}"
### in the automation below
          until:
            - condition: state
              entity_id: input_boolean.helper_medusa_oben
              state: "on"
### THIS automation
      - alias: "Auf die Antwort warten"
        wait_for_trigger:
          - platform: event
            event_type: mobile_app_notification_action
            event_data:
              # waiting for the specific action avoids accidentally continuing
              # for another script/automation's notification action
              action: "{{ action_erledigt }}"
          - platform: event
            event_type: mobile_app_notification_action
            event_data:
              action: "{{ action_close }}"
      - alias: "Perform the action"
        choose:
          - conditions: "{{ wait.trigger.event.data.action == action_erledigt }}"
            sequence:
### specifically, THIS part here:
              - service: input_boolean.turn_on
                target:
                  entity_id: input_boolean.helper_medusa_oben
### I just kept this from the example;
### it doesn't do anything at all, and it cannot even be triggered
### BY clicking anything, as I removed that part from above
          - conditions: "{{ wait.trigger.event.data.action == action_close }}"
            sequence:
              - service: cover.close_cover
                target:
                  entity_id: cover.some_cover

In order to test this, I manually turned off input_boolean.helper_medusa_oben. When I did, the service: notify.mobil positively did get triggered. The notification showed up on my device (and supposedly on other devices as well, which I wasn’t able to check at the time).

When I clicked on Erledigt underneath the notification on my Android device, I could see that an Event did show up in Home Assistant (the data part contained something like ERLEDIGT_21342345634345435, or similar).

However, the input_boolean.helper_medusa_oben did not turn_on, and the notification would re-occur every 15 minutes. I now manually turned it on through lovelace, but still got the notification again a few minutes ago (after turning it on, of course).

Can you please tell me what I did wrong? It should not repeat once the input_boolean is on again, but it did at least once. It should also act accordingly to the event fired when I clicked Erledigt underneath the Android notification, this turning that input_boolean on.

Thank you in advance for your help :slight_smile: