I have the following in my customize.yaml which is linked in under my config.yaml but i cannot get it working, the icons dont set nor does the colours. Does this still work?
If still of an interest, there’s a solution without custom-ui -
It’s a WIP for a door lock who has binary sensor for “is (not) lock” and a binary switch for “un/lock” the door.
Create a template binary sensor that can control the icon (and be used on the UI - to un/lock) and an input boolean that will be used by the binary sensor to report (or by the UI - which is actually not needed, but I added it for clarification) to toggle the state of the binary sensor.
This is the configuration.yaml part:
binary_sensor:
- platform: template
sensors:
door_main:
friendly_name: Main door
value_template: >-
{%- if is_state("input_boolean.door_main", "on") -%}
true
{%- else -%}
false
{%- endif -%}
icon_template: >
{% if is_state("input_boolean.door_main", "on") %}
mdi:door-open
{% else %}
mdi:door-closed
{% endif %}
input_boolean:
door_main:
name: Main door
icon: mdi:door-closed
And on the Lovelace UI (I added the entities types to the entity names for better understanding):
entity-button (will be used to un/lock the door) and to show the current state of the door (is or isn’t locked) -
type: entity-button
tap_action:
action: call-service
service: input_boolean.toggle
service_data:
entity_id: input_boolean.door_main
hold_action:
action: none
entity: binary_sensor.door_main
name: Main door (binary_sensor.door_main)
Entities -
entities:
- entity: input_boolean.door_main
name: Main door (input_boolean.door_main)
- entity: binary_sensor.door_main
name: Main door (binary_sensor.door_main)
show_header_toggle: false
title: Doors
type: entities