Hi together,
is it possible to create a simple switch in HA with changing icons based on the state?
Finally I would like to display the switch in a simple button card which changes the icon when pressing the button. I thought about using a template switch like this:
- platform: template
kitchen_music_on:
# value_template: "{{ states('switch.mute_kitchen') }}"
turn_on:
service: switch.turn_on
target:
entity_id: switch.kitchen_music_on
turn_off:
service: switch.turn_off
target:
entity_id: switch.kitchen_music_on
icon_template: >-
{% if is_state('switch.kitchen_music_on', 'on') %}
mdi:volume-high
{% else %}
mdi:volume-off
{% endif %}
This doesn’t work … or only works once I pressed the button in lovelace. Using template switch looks a bit like shooting sparrows with cannons and it does not feel right as written above. Anyone has a simple solution?
PS: I wanted to avoid custom cards.
red