Hi All,
I am having troubles getting some custom text on my UI.
I have a binary sensor which monitors my computers lock state, so HA knows if I am using my machine or not. This works fine.
I wanted to create a UI element instead of saying On/Off,Detected/Clear etc, it says something like “In Use” or “Locked”
I looked at this thread (and others) which seemed to be exactly what I wanted.
The Template Dev tool shows this is working, but I can’t seem to get it to work after adding it to my configuration. The computer_in_use_template sensor always shows Off.
The following is from my binary_sensors.yaml. First part is the MQTT sensor for the computer lock state, second is the template.
- platform: mqtt
name: "Computer Lock State"
state_topic: "computer/lock-state"
payload_on: "unlocked"
payload_off: "locked"
device_class: power
unique_id: computer_lock_state
- platform: template
sensors:
computer_in_use_template:
friendly_name: Computer State
entity_id: binary_sensor.computer_lock_state
value_template: >-
{% if is_state('binary_sensor.computer_lock_state', 'on') %}
Using
{% else %}
Locked
{% endif %}
Any help is appreciated!
Cheers