HTML5 Notification and problem with set target

I want to send notifications to my phone and to my notebook when it is online. If I manually set target to ["oneplus","notebook"] notification works, but if I use target template I have error in log:

17-04-20 09:59:07 ERROR (Thread-5) [homeassistant.components.notify.html5] ["oneplus","notebook"] is not a valid HTML5 push notification target!

My automation:

- alias: 'Notification Update Available'
  trigger:
    platform: state
    entity_id: updater.updater
  action:
    service: notify.html5
    data_template:
      title: 'Nowa wersja Home Assistante'
      message: "Dostępna jest aktualizacja do wersji {{ states.updater.updater..state }} dla Home Assistant."
      target: >-
         {% if states.device_tracker.notebook.state == 'home' %}
            ["oneplus","notebook"]
         {% else %}
            oneplus
         {% endif %}
    data:
      data:
        tag: 'notification-hass-update'
        url: "https://home-assistant.io/blog/"

What I’m doing wrong?

Try removing the [ and the ". Something like this:

 {% if states.device_tracker.notebook.state == 'home' %}
   oneplus,notebook
 {% else %}
   oneplus
 {% endif %}

I tried this, it doesn’t work.

ERROR (Thread-5) [homeassistant.components.notify.html5] oneplus,notebook is not a valid HTML5 push notification target!

Uhmmm … What about creating a notification group as in here https://home-assistant.io/components/notify.group/ and use it instead.

Did you try it?

1 Like

I didn’t know this, I will try.

@Bieniu how did you solve your problem?