I am using custom button-card GitHub - custom-cards/button-card: ❇️ Lovelace button-card for home assistant. I have a template sensor with a icon template, which should be used in the button-card.
sensor:
- platform: template
sensors:
weather_dresscode:
friendly_name: Dress Code
value_template: >
{% if states('sensor.gw2000a_feels_like_temperature')|float < 5 %}
Ice Bear Dress
{% else %}
Normal Dress
{% endif %}
# Set icon based on general weather range outside; snow for cold, clouds for average, and sun for hot
icon_template: >
{% if states('sensor.gw2000a_feels_like_temperature')|float < 5 %}
mdi:mdiSnowflakeThermometer
{% else %}
mdi:mdiTshirtCrew
{% endif %}
On a dashboard I want to used the icon from the template:
type: custom:button-card
action: none
entity: sensor.weather_dresscode
show_state: true
show_last_changed: false
name: |
[[[
return states['sensor.weather_dresscode'].attributes.friendly_name
]]]
icon: |
[[[
return states['sensor.weather_dresscode'].attributes.icon
]]]
The “name” is working. Unfortunately the icon is not show. Can someone help me please?