Hello all, fighting for 2 days (together with ChatGPT) to make this work.
I have a sensor that keeps a list of messages/notifications (workaround for Persistent Notifications not generating entities anymore). I want to display each notification/message as a separate card in a vertical stack. I feel that I am pretty close, but not there yet, hope I’m not hitting any limitations.
First approach gets me almost there, but I think the issue is that my output is a simple string and not a list
card:
type: vertical-stack
cards_template: |
{% set messages = state_attr('sensor.messages', 'messages') %}
{% for message in messages %}
- type: markdown
content: "{{ message.title }}"
{% endfor %}
entities:
- sensor.messages
The result is this, pretty close, except the “|-” characters which probably doesn’t allow this method to work.
Studied more, found out they have a method where they return a list, like this:
type: custom:card-templater
card:
type: vertical-stack
cards_template: >-
{{ state_attr('sensor.messages', 'messages')| map(attribute="message") |
list |
tojson }}
entities:
- sensor.messages
This actually generates individual cards, but the question is how I generate the markdown/whatever card I want in that map function for each message?