Webpush (html5) woes, URL from sensor is not sent correctly?

I’ve built a few automations to help me with notifying about all the great youtubers out there.

One of them looks like this:

- id: '1566214902542'
  alias: Youtube - videorelease - DrZzs
  trigger:
  - entity_id: sensor.drzzs
    platform: state
  condition:
  - condition: template
    value_template: '{{ as_timestamp(now()) - as_timestamp(states.automation.youtube_videorelease_drzzs.attributes.last_triggered)
      | int > 600 }}'
  action:
  - data:
      data:
        tag: drzzs-video
        url: '{{ state_attr(''sensor.drzzs'',''url'') }}'
      message: '{{ states(''sensor.drzzs'') }}'
      target:
      - Mobil
      title: Ny DrZzz video frigivet
    service: notify.webpush

It works for most part, but for some reason the URL part doesn’t work? The template works when I test it (it shows https://www.youtube.com/xxxxx), but when I click it on the phone (where it’s pushed to), the phone goes to the nabu casa URL, and then shows a 404 error?

The drzzs sensor is the youtube sensor, and that has this content:

url: 'https://www.youtube.com/watch?v=8a6JCIeZ6rU'
published: '2019-12-24T20:33:54+00:00'
live: false
friendly_name: DrZzs
icon: 'mdi:youtube'
entity_picture: 'https://i1.ytimg.com/vi/8a6JCIeZ6rU/hqdefault.jpg'

Seems odd that templates are being resolved but you’re missing data_template.

1 Like

Hi @petro
Thankyou for coming to the rescue.
Changing it to data_template made it work, so now I have some great automations for the great youtubers of my selection :smiley:

So the resulting automation:

- id: '1566214902542'
  alias: Youtube - videorelease - DrZzs
  trigger:
  - entity_id: sensor.drzzs
    platform: state
  condition:
  - condition: template
    value_template: '{{ as_timestamp(now()) - as_timestamp(states.automation.youtube_videorelease_drzzs.attributes.last_triggered)
      | int > 600 }}'
  action:
  - data_template:
      data:
        tag: drzzs-video
        url: '{{ state_attr(''sensor.drzzs'',''url'') }}'
      message: '{{ states(''sensor.drzzs'') }}'
      target:
      - Mobil
      title: Ny DrZzz video frigivet
    service: notify.webpush
1 Like