Automation Notify data_template not working

Hi @all,

any idea why my action is not working:

  action:
    - service: notify.ios_xxx_iphone
      data:
        message: "test"
        data:
          push:
            sound: >-
                   {% if is_state('cover.garage', 'open') %}
                   "US-EN-Morgan-Freeman-Garage-Door-Opened.wav"
                   {% elif is_state('cover.garage', 'closed') %}
                   "US-EN-Morgan-Freeman-Garage-Door-Closed.wav"
                   {% endif %}

Thanks for your support

I’m not familiar with the ios platform in HASS, however, for starters, I believe the “data” key under “message” should be “data_template” in order to use templating in data further down as you are in the “sound” key.

Like this:

  action:
    - service: notify.ios_xxx_iphone
      data_template:
        message: "test"
        data:
          push:
            sound: >-
                   {% if is_state('cover.garage', 'open') %}
                   "US-EN-Morgan-Freeman-Garage-Door-Opened.wav"
                   {% elif is_state('cover.garage', 'closed') %}
                   "US-EN-Morgan-Freeman-Garage-Door-Closed.wav"
                   {% endif %}

Alternately, you could set up two separate Automations, one for the garage door closing, and one for it opening, thus eliminating your need for templating inside the data passed to notify.ios_xxx_iphone.

data_template was correct. I also has to remove the quotation marks

action:
    - service: notify.ios_xxx_iphone
      data_template:
        message: "test"
        data:
          push:
            sound: >-
                   {% if is_state('cover.garage', 'open') %}
                   US-EN-Morgan-Freeman-Garage-Door-Opened.wav
                   {% elif is_state('cover.garage', 'closed') %}
                   US-EN-Morgan-Freeman-Garage-Door-Closed.wav
                   {% endif %}
1 Like