Templating service call in blueprint for mobile_app notification with multiple:true

Is it possible in a blueprint to to template one or more service calls depending on the input?
What I am trying to achieve is that the user selects multiple mobile_app devices to get them notified.
The service call here for is notify.mobile_app_DEVICE_NAME which is nothing easy to achieve with multiple: true in a blueprint.
I tried passing the service call(s) as a list to serivce:, which did not work. I could use templates to essential render the entire action: of the blueprint, as long as I can pass it as a jinja list with sqaure brackets. I’ve tried diferent versions:

blueprint:
  name: Notify to ventilate
  description: An automation blueprint that informs the user that in a given room the temperature is higher than the outside temperature in order to ventilate the room. Especially useful for hot summer days. The temperature sensor must be assigned an area.
  domain: automation
  input:
    outside_temp:
      name: Outside temperature sensor
      description: Sensor for the outside temperature
      selector:
        entity:
          domain: sensor
          device_class: temperature
    forecast_temp:
      name: Forecast temperature
      description: Sensor for the peak temperature of the current day.
      selector:
        entity:
          domain: sensor
          device_class: temperature
    min_temp:
      name: Minimum temperature
      description: Min. temperature for the day (forecast) to enable notifications.
      selector:
        number:
          min: 18
          max: 40
          unit_of_measurement: "C"
          mode: box
    temp_sensor:
      name: Temperature sensor
      description: A sensor reading temperature.
      selector:
        entity:
          domain: sensor
          device_class: temperature
          multiple: true
    notify_device:
      name: Devices to notify
      description: Devices to be notified via the mobile app
      selector:
        device:
          integration: mobile_app
          #multiple: true
    message_title:
      name: Message title
      description: Title of the notification.
      selector:
        text:
    message_string:
      name: Message
      description: Text to append after the area name.
      selector:
       text:
  source_url: 
variables:
  temp_sensors: !input 'temp_sensor'
  min_temp: !input 'min_temp'
  forecast_temp: !input 'forecast_temp'
  outside_temp: !input 'outside_temp'
  notify_devices: !input 'notify_device'
  title: !input 'message_title'
  message: !input 'message_string'
  notify_service: >-
    {% for device in notify_devices %}
      {%- set data.services = data.services + ["notify.mobile_app_"+device] -%}
    {% endfor %}
    {{data.services}}
trigger:
- platform: numeric_state
  entity_id: !input 'temp_sensor'
  below: !input 'outside_temp'    
condition:
- condition: template
  value_template: >-
    {{forecast_temp >= min_temp }}
action:
- device_id: !input notify_device
  domain: mobile_app
  type: notify
  title: "{{ title | default('') }}"
  message: >-
      {% for state in states.sensor%}
        {% if state.entity_id in temp_sensors %}
          {% if state.state >= outside_temp %}
            {{area_name(state.entity_id)}} {{message}}
          {% endif %}
        {% endif %}
      {% endfor %}
  data:
    target: window
    sticky: true
    persistent: true
- wait_template: >
    {{forecast_temp < min_temp}}
  continue_on_timeout: false
- device_id: !input notify_device
  domain: mobile_app
  type: notify
  title: "{{ title | default('') }}"
  message: "clear_notification"
  data:
    target: window

Version 2:

blueprint:
  name: Notify to ventilate
  description: An automation blueprint that informs the user that in a given room the temperature is higher than the outside temperature in order to ventilate the room. Especially useful for hot summer days. The temperature sensor must be assigned an area.
  domain: automation
  input:
    outside_temp:
      name: Outside temperature sensor
      description: Sensor for the outside temperature
      selector:
        entity:
          domain: sensor
          device_class: temperature
    forecast_temp:
      name: Forecast temperature
      description: Sensor for the peak temperature of the current day.
      selector:
        entity:
          domain: sensor
          device_class: temperature
    min_temp:
      name: Minimum temperature
      description: Min. temperature for the day (forecast) to enable notifications.
      selector:
        number:
          min: 18
          max: 40
          unit_of_measurement: "C"
          mode: box
    temp_sensor:
      name: Temperature sensor
      description: A sensor reading temperature.
      selector:
        entity:
          domain: sensor
          device_class: temperature
          multiple: true
    notify_device:
      name: Devices to notify
      description: Devices to be notified via the mobile app
      selector:
        device:
          integration: mobile_app
          multiple: true
    message_title:
      name: Message title
      description: Title of the notification.
      selector:
        text:
    message_string:
      name: Message
      description: Text to append after the area name.
      selector:
       text:
  source_url:
variables:
  temp_sensors: !input 'temp_sensor'
  min_temp: !input 'min_temp'
  forecast_temp: !input 'forecast_temp'
  outside_temp: !input 'outside_temp'
  notify_devices: !input 'notify_device'
  title: !input 'message_title'
  message: !input 'message_string'
  notify_service: >
    {% for device in notify_devices %}
    - notify.mobile_app_{{device_attr(device, "name") | replace(" ", "_")}}
    {% endfor %}
trigger:
- platform: numeric_state
  entity_id: !input 'temp_sensor'
  below: !input 'outside_temp'    
condition:
- condition: template
  value_template: >-
    {{forecast_temp >= min_temp }}
action:
- service: >
    {%- set data = namespace(services=[]) -%}
    {% for device in notify_devices %}
      {%- set data.services = data.services + ["notify.mobile_app_"+device_attr(device, "name") | replace(" ", "_")] -%}
    {% endfor %}
    {{data.services}}
  data:
    message: >-
      {% for state in states.sensor%}
        {% if state.entity_id in temp_sensors %}
          {% if state.state >= outside_temp %}
            {{area_name(state.entity_id)}} {{message}}
          {% endif %}
        {% endif %}
      {% endfor %}
    title: "{{ title | default('') }}"
    data: 
      target: window
      sticky: true
      persistent: true
- wait_template: >
    {{forecast_temp < min_temp}}
  continue_on_timeout: false
- service: >
    {%- set data = namespace(services=[]) -%}
    {% for device in notify_devices %}
      {%- set data.services = data.services + ["notify.mobile_app_"+device_attr(device, "name") | replace(" ", "_")] -%}
    {% endfor %}
    {{data.services}}
  data:
    message: "clear_notification"
    title: "{{ title | default('') }}"
    data: 
      target: window
mode: restart
max_exceeded: silent

This is my third version, but it won’t create an actual automation:

blueprint:
  name: Notify to ventilate2
  description: An automation blueprint that informs the user that in a given room the temperature is higher than the outside temperature in order to ventilate the room. Especially useful for hot summer days. The temperature sensor must be assigned an area.
  domain: automation
  input:
    outside_temp:
      name: Outside temperature sensor
      description: Sensor for the outside temperature
      selector:
        entity:
          domain: sensor
          device_class: temperature
    forecast_temp:
      name: Forecast temperature
      description: Sensor for the peak temperature of the current day.
      selector:
        entity:
          domain: sensor
          device_class: temperature
    min_temp:
      name: Minimum temperature
      description: Min. temperature for the day (forecast) to enable notifications.
      selector:
        number:
          min: 18
          max: 40
          unit_of_measurement: "C"
          mode: box
    temp_sensor:
      name: Temperature sensor
      description: A sensor reading temperature.
      selector:
        entity:
          domain: sensor
          device_class: temperature
          multiple: true
    notify_device:
      name: Devices to notify
      description: Devices to be notified via the mobile app
      selector:
        device:
          integration: mobile_app
          multiple: true
    message_title:
      name: Message title
      description: Title of the notification.
      selector:
        text:
    message_string:
      name: Message
      description: Text to append after the area name.
      selector:
       text:
  source_url: https://community.home-assistant.io/t/homematic-ip-local-reduce-room-temperature-when-a-window-or-door-is-opened/373305
variables:
  temp_sensors: !input 'temp_sensor'
  min_temp: !input 'min_temp'
  forecast_temp: !input 'forecast_temp'
  outside_temp: !input 'outside_temp'
  notify_devices: !input 'notify_device'
  title: !input 'message_title'
  message: !input 'message_string'
  notify_service: >
    {% for device in notify_devices %}
    - notify.mobile_app_{{device_attr(device, "name") | replace(" ", "_")}}
    {% endfor %}
trigger:
- platform: numeric_state
  entity_id: !input 'temp_sensor'
  below: !input 'outside_temp'    
condition:
- condition: template
  value_template: >-
    {{forecast_temp | int >= min_temp | int}}
action: >
  {% for device in notify_devices %}
  - service: notify.mobile_app_{{device_attr(device, "name") | replace(" ", "_")}}
    data:
    message: {% for state in states.sensor%}{% if state.entity_id in temp_sensors %} {% if state.state >= outside_temp %}{{area_name(state.entity_id)}} {{message}}{% endif %}{% endif %}{% endfor %}
    title: "{{ title | default('') }}"
    data: 
      target: window
      sticky: true
      persistent: true
  {% endfor %}
  - wait_template: {{forecast_temp | int < min_temp | int}}
    continue_on_timeout: false
  {% for device in notify_devices %}
  - service: notify.mobile_app_{{device_attr(device, "name") | replace(" ", "_")}}
    data:
    message: {% for state in states.sensor%}{% if state.entity_id in temp_sensors %} {% if state.state >= outside_temp %}{{area_name(state.entity_id)}} {{message}}{% endif %}{% endif %}{% endfor %}
    title: "clear_notifiction"
    data: 
      target: window
  {% endfor %}
  mode: restart
  max_exceeded: silent

Error in in the logs:

Blueprint Notify to ventilate generated invalid automation with inputs OrderedDict[('outside_temp', 'sensor.openweathermap_temperature'), ('forecast_temp', 'sensor.openweathermap_forecast_temperature'), ('min_temp', 24), ('temp_sensor', ['sensor.arbeitszimmer_actual_temperature', 'sensor.bad_actual_temperature']), ('notify_device', ['89e43fbdb33b67c52df8e0e11faebf33', '06b2b0e5fc4911ea9581d7f976ee0369']), ('message_title', 'Lüften'), ('message_string', 'kann gelüftet werden')]) 
2 Likes

Does anyone have a solution to this? I am attempting to use seamus65’s blueprint
for notifying devices when a ring doorbell is pressed but am unable to send to multiple devices without creating two automations. A CSV list does not work as someone had recommended elsewhere. the blueprint is here seamus65/doorbell_notify_alexa_or_google_and_camera_snapshot.yaml