Consider this sensor:
- name: testing_2_flags
state: >-
{{ states('input_boolean.testing_boolean') }}
I expect this sensor to repeat the “input_boolean” state - and it works.
Next, I want to add a logic: the sensor repeats “testing_boolean” - unless it is forced to ON by “testing_boolean_2”:
- name: testing_2_flags_1
state: >-
{{ states('input_boolean.testing_boolean') or
is_state('input_boolean.testing_boolean_2','on') }}
and an alternative version:
- name: testing_2_flags_2
state: >-
{{ is_state('input_boolean.testing_boolean','on') or
is_state('input_boolean.testing_boolean_2','on') }}
And these sensors behave differently:
i.e.:
on or True -> on
off or True -> off
on or False -> on
off or False -> off
True or True -> on
False or True -> on
True or False -> on
False or False -> on
I see that I should use the 2nd variant.
But the 1st variant LOOKS like a working too - until you start testing it.
Why do we have a different logic here?
Probably because I am comparing values of different types - “on/off” & “True/False”.
But my dark C/C++ past is telling me that “off or True
” is supposed to be resolved as “True” and then presented as “on”.