I’ve got two Xiaomi door/window sensors. I’ve added them to my front end by using a sensor template. The value template is working, but not the icon template. There’s no icon showing at all. Can anyone help me out here? Thank you!
- platform: template
sensors:
front_door:
friendly_name: "Front Door"
value_template: >-
{% if is_state('binary_sensor.door_window_sensor_158d0001ab56bd', 'on') %}
Open
{% else %}
Closed
{% endif %}
icon_template: >-
{% if is_state('binary_sensor.door_window_sensor_158d0001ab56bd', 'on') %}
mdi:door-open
{% else %}
mdi:door-closed
{% endif %}
VDRainer
(🍻)
November 15, 2017, 8:18am
2
Looks ok to me.
Do you have any customizing for this sensor?
What if you try it without the hyphen?
icon_template: >
1 Like
if you define it as a binary sensor template, you can use device_classs and the icon will change accordingly. see below
platform: template
scan_interval: 2
sensors:
entrance_open:
value_template: ‘{{ is_state(‘binary_sensor.door_window_sensor_158d0001ab56bd’, ‘on’) }}’
entity_id: sensor.entrance_node_access_control
device_class: opening
sorry, correction:
platform: template
scan_interval: 2
sensors:
entrance_open:
value_template: ‘{{ is_state(‘binary_sensor.door_window_sensor_158d0001ab56bd’, ‘on’) }}’
entity_id: binary_sensor.door_window_sensor_158d0001ab56bd
device_class: opening
Ended up doing a fresh install. At some point after that, the issue fixed itself after a reset. No clue what ended up being the actual fix. Thanks for your help!
VirtualL
(Virtual L)
March 10, 2018, 7:52am
6
i found a really easy way to do it
just in customize.ymal file do something like this:
binary_sensor.door_window_sensor_158d0xx0d8xxxxxxxxxx4ac:
friendly_name: blablabla
device_class: door
and now you have a custom icon for open or close
5 Likes
Thank you very much, it works!
1 Like