Hi
I’m using some input_booleans and wondering if they can set to readonly? Because some of them are only meant for status and not to control it
Thanks
Hi
I’m using some input_booleans and wondering if they can set to readonly? Because some of them are only meant for status and not to control it
Thanks
No, you would have to create template binary sensors to track your input boolean. e.g.
configuration.yaml
template:
- binary_sensor:
- name: Read only
state: "{{ states('input_boolean.foobar')|bool }}"
exactly what I was looking for. can I also display open and close instead of off or on in the same template?
Add:
device_class: door
It’s possible to eliminate the Input Boolean by using a Trigger-based Template Binary Sensor whose state is set by a custom event.
In other words, instead of your automation controlling the state of an Input Boolean (and then using a separate Template Binary Sensor to create a ‘read-only’ representation of the Input Boolean), your automation would directly control the state of a Trigger-based Template Binary Sensor.
Here’s a Trigger-based Template Binary Sensor whose state is set by a custom event called jboesh_door1
(rename it to whatever you want).
template:
- trigger:
- platform: event
event_type: jboesh_door1
binary_sensor:
- name: My First Door
device_class: door
state: "{{ trigger.event.data.state }}"
Here’s what you would use in your automation to set the state of binary_sensor.my_first_door
to on
(which will display as Open
in the UI because its device_class is door).
action:
- event: jboesh_door1
event_data:
state: 'on'
In other words, instead of your automation using input_boolean.turn_on
to turn on the Input Boolean, it would post the jboesh_door1
custom event, as shown above, to turn on the Trigger-based Template Binary Sensor.