I have an Aeotec dry contact on my backyard gate. I was easily able to change icon from a door to a gate but the icon stays the same, and only the color changes. I created a binary_sensor template to make the icon change based on the sensor state following these instructions:
… but I wonder whether there are other ways to do this.
The way I set it up I ended up with two entities:
binary_sensor.backyard_gate (the actual sensor)
binary_sensor.backyard_gate_sensor (the template sensor)
The template code is (please note this is in a template.yaml file so the template:
declaration is in configuration.yaml file (mentioning this as noobs like myself won’t be wondering why the code is not working if they copy it… it got me quite a few times in my first weeks).
- binary_sensor:
- name: "Backyard Gate Sensor"
state: >
{{ is_state("binary_sensor.backyard_gate", "on") }}
icon: >
{% if is_state('binary_sensor.backyard_gate_sensor', 'on') %}
hass:gate-alert
{% else %}
hass:gate
{% endif %}
Is there any way to tell HA that the binary_sensor.backyard_gate
(the actual sensor) should use gate icons and should default to open / closed states without having to create a new binary_sensor?
EDIT: I “customized” the binary_sensor.backyard_gate_sensor
(the template sensor) assigning it to device_class: door
in my customize.yaml file.