Hi everybody,
I am trying to automate sending notifications when certain sensors state their data. What is wrong with my template? Nothing happens at the moment:
automation:
- id: 'not_yt_all'
alias: "[Notify] YouTube Abos"
trigger:
- platform: state
entity_id: sensor.youtuber1
- platform: state
entity_id: sensor.youtuber2
action:
- service: notify.wir_alle
data_template:
title: "{{ state_attr('trigger.entity_id', 'friendly_name') }}"
message: >
📺 Neues Video! {{ state_attr('trigger.entity_id', 'friendly_name') }} ➡ {{ states('trigger.entity_id') }} ({{ state_attr('trigger.entity_id', 'published')[11:16] }} Uhr am {{ state_attr('trigger.entity_id', 'published')[:10] }})
Let’s say youtuber1 (friendly_name YouT) releases “my new video”. The sensor picks this up and I should get the following message: 📺 Neues Video! YouT ➡ my new video (12:15 Uhr am 2019-10-01)
.
I had a hard-coded version of this written for each youtuber, which worked fine; but now that I am trying to just add any additional subscription to the trigger entity_ids, it won’t work any longer.
This is my previous code
automation:
- id: 'not_yt_rtg'
alias: "[Notify] YouTube YouT"
trigger:
- platform: state
entity_id: sensor.youtuber
action:
- service: notify.wir_alle
data_template:
title: YouT
message: >
📺 Neues Video! {{ state_attr('sensor.youtuber1', 'friendly_name') }} ➡ {{ states('sensor.youtuber1') }} ({{ state_attr('sensor.youtuber1', 'published')[11:16] }} Uhr am {{ state_attr('sensor.youtuber1', 'published')[:10] }})
# trying there to also add a photo to the mssage, but this does not work
# data:
# photo:
# - url: {{ state_attr.('sensor.youtuber1', 'entity_picture') }}
# caption: "Something"
What am I doing wrong? I suggest there is something wrong with trigger.entity_id
, but I cannot seem to figure out what it is.
Thank you for your ideas