But when I slide the on/off button, the icons do not change.
I expect , for water , to use the mdi:water icon and change the icon for on/off states using
mdi:water-on and mdi:water-off ??
What have I done wrong please - obviously probably not understanding icon and entity relationships??
If Homeassistant knows what device_class your sensor belongs to it will figure out what icons to use for the on/off state i.e. motion sensors. Just giving an icon doesn’t help homeassistant here, you have to be more specific and create a new template sensor that specifies an icon_template for the on and off state. (No guarantee the syntax is correct)
sensor:
- platform: template
sensors:
water:
entity_id: switch.danfoss_rxz3_rf_relay_switching_unit_switch
friendly_name: Hot Water
icon_template: >
{% if is_state('switch.danfoss_rxz3_rf_relay_switching_unit_switch', 'on') %}
mdi:water-on
{% else %}
mdi:water-off
{% endif %}
Ah, I see. I understand your code - thanks - but alas it may not be that simple…can I just check with you please…
I have a Z-Wave Danfoss RX2 controller which HA has discovered as a device, and has auto-created entities for it, including switch.danfoss_rxz3_rf_relay_switching_unit_switch as a binary_sensor class.
So do I need to “overwrite” some of the So do I need to “overwrite” attributes of this switch, perhaps like this?..:
Just wanted to check before I go off and try myself.
EDIT:
Scratch the above. I understand now. Didn’t realise the template was creating a new entity called water.
Also
I had to tweak the code - granted you provided unverified code:
ui-lovelace.yaml
- type: vertical-stack
title: HW & CH
cards:
- type: entities
entities:
# templating for switch.danfoss_rxz3_rf_relay_switching_unit_switch
- entity: switch.water
name: Hot water
state_color: true
- entity: switch.danfoss_rxz3_rf_relay_switching_unit_switch_2
name: Central heating
state_color: true
Had to move from sensor to switch to get the desired UI.
But , why does the color of the water drop turn yellow when on? Can this be changed, to say red/orange? Other than this, working perfectly - so big thank you.