I can’t seem to wrap my head around getting the binary sensor template to work properly.
I have two binary sensors that I’d like to customize their state to Open and Closed.
binary_sensor.door_window_sensor_158d0001584d8d
binary_sensor.door_window_sensor_158d0001549402
Currently, my output looks like this…
...
customize:
# iconing
binary_sensor.frame_front_door:
icon: mdi:glassdoor
binary_sensor.frame_back_door:
icon: mdi:glassdoor
...
binary_sensor:
- platform: template
sensors:
frame_front_door:
friendly_name: Front Door
entity_id:
- binary_sensor.door_window_sensor_158d0001549402
value_template: >-
{%- if is_state("binary_sensor.door_window_sensor_158d0001549402", "on") -%}
Open
{%- else -%}
Closed
{%- endif -%}
frame_back_door:
friendly_name: Back Door
entity_id:
- binary_sensor.door_window_sensor_158d0001584d8d
value_template: >-
{%- if is_state("binary_sensor.door_window_sensor_158d0001584d8d", "on") -%}
Open
{%- else -%}
Closed
{%- endif -%}
When using the dev tools, I can get the value_template to evaluate correctly, but not to update at all. Additionally, my output panel doesn’t have the correct state names and it won’t ever update those values.
Is there any way to customize the icon, friendly name AND the state, but keep the functionality of having my icon go yellow when the state is on?
It seems like it’s working … but I get an error on startup and my group won’t appear.
17-03-11 22:23:37 WARNING (MainThread) [homeassistant.components.sensor.template] Could not render icon template Back Door, the state is unknown.
17-03-11 22:23:37 WARNING (MainThread) [homeassistant.components.sensor.template] Could not render icon template Front Door, the state is unknown.
If you find out something neat, do show and tell! I’m not even sure the changing-of-icon-colors is a public function in hass. I assume it’s just done via CSS based on a state change, but we currently don’t have the ability to modify that. At least not to my knowledge!
Right, and that totally works … but it doesn’t seem to work on-startup for me. It tells me the state is unknown, and will not create the group.
edit … I’m a dirty liar. I had the wrong sensor names. It still doesn’t solve my want though. If I use the ugly sensor name, the icon will light up yellow/gold when the sensor is “on” and it will be the regular mdi icon when it is “off”. This functionality is not reproduced when you make a template sensor.