Example Configuration:
template:
- binary_sensor:
- name: a_test
unique_id: bs_a_test
state: >-
{{
(
is_state('binary_sensor.a_test', 'on') #REGARDING THIS!
or is_state('input_boolean.test_1', 'on')
)
and
(
is_state('input_boolean.test_2', 'on')
)
}}
The documentation suggests the above configuration for a template entity that needs to reference itself. However, it is problematic because the entity_id of the binary_sensor can be changed in the UI. It’s also possible that the obvious entity_id (‘binary_sensor.a_test’) is already used and therefore this binary_sensor gets a different entity_id.
I would like to see something similar to the this keyword available in automation triggers to refer to the state of the template entity itself. With this in place, something like the following would work…
template:
- binary_sensor:
- name: a_test
unique_id: bs_a_test
state: >-
{{
(
is_state(this, 'on') #MUCH BETTER!
or is_state('input_boolean.test_1', 'on')
)
and
(
is_state('input_boolean.test_2', 'on')
)
}}