I’m hoping someone can help - as I can’t seem to resolve this.
A simple (I thought !) template to change an icon colour.
The template looks like this:
icon_color: >
{% if is_state('switch.smart_plug_1', 'on') %}
green
{% else %}
red
{% endif %}
The icon remains resolutely black. When I replace the template and the ‘>’ with red or green - it works great and the icon changes colour.
What am I doing wrong ?
The formatting above is a bit out - ‘{’ are aligned under the ‘o’ of ‘icon’ and ‘g’ and ‘r’ of colours are aligned under ‘space’ of ‘{% …’.
PS - I put the template in the template engine in HA - and came back with red or green as expected…
Help ??!!
1 Like
What kind of card are you using here? Does its icon_color
property support templates?
It’s a custom-mushroom-chips card. And - as mentioned - when I take the templating out and just use the raw colour (like ‘red’) - it seems to work.
- type: custom:mushroom-entity-card
entity: switch.smart_plug_1
name: Washing machine
icon: mdi:power-plug
layout: vertical
primary_info: none
secondary_info: name
icon_color: |
{% if is_state('switch.smart_plug_1', 'on') %}
green
{% elseif %}
red
{% endif %}
1 Like
jetolu
(Jetolu)
January 26, 2023, 11:54am
5
Try using a Mushroom Template Card instead. I don’t think templating is supported on Mushroom Entity Cards. If you don’t get it to work with the Template Card, I suggest asking the same question on this topic instead:
https://community.home-assistant.io/t/mushroom-cards-build-a-beautiful-dashboard-easily/
1 Like
Brilliant - that was it - thank you. I thought because I could change the icon colour manually - meant it also supported templating. Clearly not. Got the same effect with a mushroom-template-card.
Thank you !
1 Like