Yes ‘and’ and ‘or’ can be mixed but beware of the logic results and order of operations.
‘()’ has precedence over ‘not’ has precedence over ‘and’ has precedence over ‘or’.
It’s hard to tell which things you want to ‘or’ together from the template but based on the order of operations it looks like you will get this:
(
states('sensor.temp_current_office_temperature') | float < 20.0
and
states('sensor.temp_current_kitchen_temperature')| float < 20.0
and
is_state('input_boolean.dummy_switch','on')
)
or
is_state_attr('climate.your_thermostat', 'temperature', 23)
If that’s what you want then your template is fine.
if it’s not then you may need to force order of operations by including ‘()’
so let’s say you want to ‘and’ the first two and then ‘and’ that result with an ‘or’ of the last two.
logically it would look like this:
(
states('sensor.temp_current_office_temperature') | float < 20.0
and
states('sensor.temp_current_kitchen_temperature')| float < 20.0
)
and
(
is_state('input_boolean.dummy_switch','on')
or
is_state_attr('climate.your_thermostat', 'temperature', 23)
)
the new template would look like this:
value_template: "{{ states('sensor.temp_current_office_temperature') | float < 20.0 and states('sensor.temp_current_kitchen_temperature')| float < 20.0 and ( is_state('input_boolean.dummy_switch','on') or is_state_attr('climate.your_thermostat', 'temperature', 23) ) }}"
So the template again depends on the logic you want in the end.
I like to force order of operations using parenthesis so there is no ambiguity in my templates so I would probably even put ‘()’ around the first two operands:
value_template: "{{ ( states('sensor.temp_current_office_temperature') | float < 20.0 and states('sensor.temp_current_kitchen_temperature')| float < 20.0 and is_state('input_boolean.dummy_switch','on') ) or is_state_attr('climate.your_thermostat', 'temperature', 23) }}"
or if using the second template:
value_template: "{{ ( states('sensor.temp_current_office_temperature') | float < 20.0 and states('sensor.temp_current_kitchen_temperature')| float < 20.0 ) and ( is_state('input_boolean.dummy_switch','on') or is_state_attr('climate.your_thermostat', 'temperature', 23) ) }}"
but that might just be me.