Condition template returns false in automation

Hi all,

Trying to understand why my condition template returns false in my automation.
But while checking it in the developer window within HA returns true

This is the automation:

- alias: Actual speed send mechanical ventilation
  id: '1322'
  mode: single
  triggers:
    - trigger: state
      entity_id:
        - input_number.bathroom_fan_speed
      id: BadkamerFan
    - trigger: state
      entity_id:
        - input_number.toilet_fan_speed
      id: ToiletFan
  conditions: []
  actions:
    - choose:
        - conditions:
            - condition: trigger
              id:
                - ToiletFan
            - condition: template
              value_template: >-
                "{{ ( states('input_number.toilet_fan_speed') | float ) > ( states('input_number.mechanical_fan_idle_speed') | float ) }}"
          sequence:
            - action: light.turn_on
              metadata: {}
              target:
                entity_id: light.mechanischeventilator
              data:
                brightness: "{{ states('input_number.toilet_fan_speed') | int }}"
        - conditions:
            - condition: trigger
              id:
                - BadkamerFan
            - condition: template
              value_template: >-
                "{{ ( states('input_number.bathroom_fan_speed') | float ) > ( states('input_number.mechanical_fan_idle_speed') | float ) 
                and ( states('input_number.bathroom_fan_speed') | float ) > ( states('input_number.toilet_fan_speed') | float )}}"
          sequence:
            - action: light.turn_on
              metadata: {}
              target:
                entity_id: light.mechanischeventilator
              data:
                brightness: "{{ states('input_number.bathroom_fan_speed') | int }}"
      default:
        - action: light.turn_on
          metadata: {}
          target:
            entity_id: light.mechanischeventilator
          data:
            brightness: "{{ states('input_number.mechanical_fan_idle_speed') | int }}"

and mainly these 2 template conditions return false while checking the same syntax in developer window returns a true

              value_template: >-
                "{{ ( states('input_number.toilet_fan_speed') | float ) > ( states('input_number.mechanical_fan_idle_speed') | float ) }}"
            - condition: template
              value_template: >-
                "{{ ( states('input_number.bathroom_fan_speed') | float ) > ( states('input_number.mechanical_fan_idle_speed') | float ) 
                and ( states('input_number.bathroom_fan_speed') | float ) > ( states('input_number.toilet_fan_speed') | float )}}"

Should there be another way of writing those equations?

Remove the quotes around the template if you’re using multiline format:

value_template: >-
  {{ ( states('input_number.bathroom_fan_speed') | float ) > ( states('input_number.mechanical_fan_idle_speed') | float ) 
  and ( states('input_number.bathroom_fan_speed') | float ) > ( states('input_number.toilet_fan_speed') | float )}}

Or use single-line format with quotes:

value_template: "{{ (states('input_number.toilet_fan_speed') | float) > (states('input_number.mechanical_fan_idle_speed') | float) }}"

Thank you very much !

so to narrow it down and checking it for me.

value_template: >- requires the quotes to me removed
value_template: requires the quotes to be used.

Yes.

Rule 1 here:

1 Like
1 Like