It seems like a lot of people are creating additional template binary sensors just to be able to change the default icons. For example when I add a new window contact, the entity that gets created has the
mdi:window-closed. I personally find it quite hard to differentiate between these two icons so I would like to use
mdi:window-closed-variant instead. This is just an example case, there are lots of others in the forums.
The current offered solution is to create template sensors and define different icons inside an
icon_template based on different states. Whilst this achieves the desired result, it consequently means that I now have 2 binary sensors for the same device. When you’ve got umpteen contacts all over your house, maintaining this code can get tedious, not to mention the performance impact its probably having on HA with twice as many sensors.
It seems the logical place to do this would be in the
customize section of
configuration.yaml. This is where you would override the entity name, device class etc., for example.
homeassistant: customize: binary_sensor.bathroom_window_contact: friendly_name: "Bathroom Window" device_class: window icon: mdi:window-open-variant
However whilst you can specify an icon here, it does not respond to state changes, e.g. on or off.
My suggestion therefore is to extend the functionality of the icon in here so that it responds to state changes. Something that would allow me to say use this icon when on and this icon when off.
This will save everyone from creating additional template sensors when all they are wanting to do is change an icon.