Hello guys
I would like to have a button-card in my dashboard which is changing its backround to red if the title of an calendar entry is “Low Demand Season - Peak” or “High Demand Season - Peak”. Otherwise, the backround should be green.
type: custom:button-card
entity: calendar.eskom_ruraflex
name: Eskom Tariff
icon: mdi:power-plug
show_state: false
label: |
{% if state_attr('calendar.eskom_ruraflex', 'message') %}
{{ state_attr('calendar.eskom_ruraflex', 'message') }}
{% else %}
Low Eskom Tariff
{% endif %}
styles:
card:
- background-color: >
{% if 'Low Demand Season - Peak' in
state_attr('calendar.eskom_ruraflex', 'message') or 'High Demand Season
- Peak' in state_attr('calendar.eskom_ruraflex', 'message') %}
red
{% else %}
green
{% endif %}
icon:
- color: white
Well, nothing is happening, just the standard dark backround. It looks like the code is not reading the attribute “message” correctly. Looking it up under developer tools shows the right message of the event though.
I don’t have a clue, but it is also my first calendar based automation. Any idea what I am doing wrong here?