Patrick4
(Patrick)
November 22, 2023, 7:07pm
1
I want my automation to fire even if one of the entities (the list is longer) is not available. Is that indeed the way to do it?
condition:
- condition: and
conditions:
- condition: or
conditions:
- condition: numeric_state
entity_id: number.office_radiator_valve_position
below: 15
- condition: state
entity_id: number.office_radiator_valve_position
state: 'unavailable'
- condition: or
conditions:
- condition: numeric_state
entity_id: number.parents_heater_valve_position
below: 15
- condition: state
entity_id: number.parents_heater_valve_position
state: 'unavailable'
...
I am not confident to try a template just yet.
CO_4X4
(Colorado Four Wheeler)
November 22, 2023, 7:34pm
2
Looks right to me, two AND statements evaluating OR statements.
1 Like
123
(Taras)
November 22, 2023, 7:40pm
3
It’s simpler with Template Conditions.
condition:
- condition: template
value_template: "{{ states('number.office_radiator_valve_position') | float(0) < 15 }}"
- condition: template
value_template: "{{ states('number.parents_heater_valve_position') | float(0) < 15 }}"
...
Even simpler if you use shorthand notation.
condition:
- "{{ states('number.office_radiator_valve_position') | float(0) < 15 }}"
- "{{ states('number.parents_heater_valve_position') | float(0) < 15 }}"
...
If the entity’s state
value is unavailable
, the float(0)
filter will report 0
. Given that 0 is less than 15, the template will report true
. In other words, the condition passes if the state
value is unavailable
or a numeric value less than 15.
2 Likes
Patrick4
(Patrick)
November 22, 2023, 10:09pm
4
Yes, I didn’t dare to go into templating land. Thanks for the hint! It will be much more readable that way.
1 Like
Patrick4
(Patrick)
December 1, 2023, 5:35pm
5
Thank you for the tip, my automation looks much better now.
For a trigger, I understand that I can transform the first one below into the second one, correct? There is no shorthand notation here, right?
trigger:
- platform: numeric_state
entity_id:
- number.office_radiator_valve_position
above: 15
- platform: template
value_template: "{{ states('number.office_radiator_valve_position') | float(0) > 15 }}"
123
(Taras)
December 2, 2023, 3:25am
6