#Template actionable notification sequence

1 messages · Page 1 of 1 (latest)

hard maple
#

As the title states, is this currently possible? I am trying to create a reusable actionable notification for general dismiss/confirm stuff. It currently look like this:

confirm_dismiss_notification:
  mode: restart
  sequence:
    - variables:
        action_confirm: "{{ 'CONFIRM_' ~ context.id }}"
        action_dismiss: "{{ 'DISMISS_' ~ context.id }}"
        clear_notification:
          - action: notify.home
            data:
              message: "clear_notification"
              data:
                tag: "{{ tag }}"
    - action: notify.home
      data:
        title: "{{ title }}"
        message: "{{ message }}"
        data:
          tag: "{{ tag }}"
          actions:
            - action: "{{ action_confirm }}"
              title: Yes
            - action: "{{ action_dismiss }}"
              title: No
    - wait_for_trigger:
        - platform: event
          event_type: mobile_app_notification_action
          event_data:
            action: "{{ action_confirm }}"
        - platform: event
          event_type: mobile_app_notification_action
          event_data:
            action: "{{ action_dismiss }}"
    - choose:
        - conditions: "{{ wait.trigger.event.data.action == action_confirm }}"
          sequence: "{{ confirm_sequence + clear_notification }}"
        - conditions: "{{ wait.trigger.event.data.action == action_dismiss }}"
          sequence: "{{ dismiss_sequence }}"

Seems reasonable to me except I get this error:

ERROR:homeassistant.components.script:Script with object id 'confirm_dismiss_notification' could not be validated and has been disabled: expected dictionary @ data['sequence'][3]['choose'][0]['sequence'][0]. Got '{'

Which makes me wonder if this is currently possible or that I am messing up somewhere. Has anyone tried this before?

#

Calling side looks something like this:

    - service: script.confirm_dismiss_notification
      data:
        title: Waste collection
        message: Did you put away the {{ states('sensor.next_bin_collection') }} bin?
        tag: garbage_bin_away
        confirm_sequence:
          - action: input_boolean.turn_off
            target:
                entity_id: input_boolean.garbage_bin_home
        dismiss_sequence: []
novel scarab
#

You can’t use a template to replace YAML.

#

sequence: must be followed by a list of actions or conditions. Not a template.

robust whale
#

I created a FR to allow templates for a sequence.
You can make something like this working for a blueprint, using an action selector. However, if you use an action selector in a script, you'll end up with a variable which contains the actions.
You can work around this with a repeat sequence, but that only works with actions like action: light.turn_on but not with other building blocks like delay or if.