Hi,
I’ve got a template sensor containing a list of radio stations:
- name: "Radio list"
unique_id: "radio_list"
attributes:
items: !include radiostations.yaml
with radiastations.yaml
"{{ [ ('NDR2', 'http://icecast.ndr.de/ndr/ndr2/niedersachsen/mp3/128/stream.mp3'), ('NDR1', 'http://icecast.ndr.de/ndr/ndr1niedersachsen/hannover/aac/low'), ('1LIVE', 'http://wdr-1live-live.icecast.wdr.de/wdr/1live/live/mp3/128/stream.mp3'), ] }}"
Now I want to create an automation to store a new radio station. The idea is to retrieve it from radio browser, type in a friendly name and add friendly name and media_content_id from the player to the file with File integration.
The problem is in templating and escaping.
With
action: notify.send_message
target:
entity_id: notify.file
data:
message: " {{ state_attr('sensor.radio_list', 'items') + [('new Name', 'new id')] }} "
I got in radiostations.yaml
[('NDR2', 'http://icecast.ndr.de/ndr/ndr2/niedersachsen/mp3/128/stream.mp3'), ('NDR1', 'http://icecast.ndr.de/ndr/ndr1niedersachsen/hannover/aac/low'), ('1LIVE', 'http://wdr-1live-live.icecast.wdr.de/wdr/1live/live/mp3/128/stream.mp3'), ('new Name', 'new id')]
So I’m missing the brackets and quotes.
PS: To make the automation work I have a shell commad deleting the content of the text file before and the command to reload yaml afterwards.
Thanks for any hint!
flosen1304