Choose condition in automation always gets to default sequence

I have an automation with a choose condition and it always skip the conditions. This is the choose condition:

choose:
  - conditions:
      - condition: template
        value_template: '{{ states("sensor.combi_koelkast_power") | int(0) < 2 }}  '
    sequence:
      - service: input_select.select_option
        data:
          option: Niet actief
        target:
          entity_id: input_select.combi_koelkast_status
  - conditions:
      - condition: template
        value_template: '{{ states("sensor.combi_koelkast_power") | int(0) > 35 }}'
    sequence:
      - service: input_select.select_option
        data:
          option: Koelen
        target:
          entity_id: input_select.combi_koelkast_status
default: []

With sensor

combi_koelkast_power:
state_class: measurement
unit_of_measurement: W
friendly_name: Combi koelkast
icon: mdi:fridge
device_class: power

Has anyone an idea why?
Thx
Bernd

Well reading the automation, the only obvious answer is that the wattage of the fridge is always above 2W, and always below 35W ? And thus neither condition matches.
If you look at the Automation trace, it will tell you what the actual values are.
What is the trigger for the automation?

1 Like

Ths is the trigger for the automation:

platform: template
value_template: '{{ states("sensor.combi_koelkast_power") | round(0) }}'

This value can be 0 to 50

That’s not really a trigger though? It doesn’t do anything, there is no logic in it.
You’d be better off just using a numeric_state trigger for the sensor, without an above or below.

Use a State Trigger.

alias: example
trigger:
  - platform: state
    entity_id: sensor.combi_koelkast_power
condition:
  - condition: template
    value_template: >
      {% set p = trigger.to_state.state | int(0) %}
      {{ p < 2 or p > 35 }}
action:
  - service: input_select.select_option
    target:
      entity_id: input_select.combi_koelkast_status
    data:
      option: "{{ 'Niet actief' if trigger.to_state.state | int(0) < 2 else 'Koelen' }}"

Thank you!

1 Like