tuffno
(Bob)
1
Hello.
I’m trying to figure out how to define which Icon that will be used in a Sensor Template.
This is my sensor template.
{{ iif(is_state(‘binary_sensor.peters_telefon_device_locked’, ‘on’), ‘Locked’, ‘Unlocked’) }}
the sensor is made to change the status of On and Off to Locked and Unlocked.
But I would also like it to change the Icon based on the state.
Thanks for any tips.
Hello Bob,
You should make a template sensor for that entity.
Search this and you will see examples:
site:home-assistant.io change icon template sensor
tuffno
(Bob)
3
Thank you.
This is how It ended up working.
- sensor:
- name: petertelefonlocked
unique_id: peter_telefon_locked
state: >
{% if is_state("binary_sensor.peters_telefon_device_locked", "on") %}
Locked
{% else %}
Unlocked
{% endif %}
icon: >
{% if is_state("binary_sensor.peters_telefon_device_locked", "on") %}
mdi:lock-outline
{% else %}
mdi:lock-open-variant-outline
{% endif %}