Template as a condition - help w/ YAML

I’m struggling w/ the syntax of this Yaml. Everything works except when I try toadd the template condition. I’ve tried all kind of ',", combinations etc. Sometimes I really hate yaml. I know my condition evaluates correctly in the dev tools template tester.

text_sensor:
#get these object values from home assistant 
  - platform: homeassistant
    id: hvac_action
    entity_id: climate.dev_wood_pellet_stove
    attribute: hvac_action
    on_value:   # When value simply changes
      then:
        - while:
            condition: 
              and:
                - binary_sensor.is_on: p5z 
                - text_sensor.state:
                  id: hvac_action
                  state: 'idle'
                - condition: template  
                  value_template: '{{float(states("sensor.esph_dev_stove_pipe_temp") , 0) >=  250}}'               
            then:
              - switch.turn_on: p5_indicator

ERROR:

Try this:

value_template: "{{ float(states('sensor.esph_dev_stove_pipe_temp') , 0) >=  250 }}"

Same error

How about this?

value_template: "{{ states('sensor.esph_dev_stove_pipe_temp')  |  float(0)  >=  250 }}"

Exact same error.

The editor is highlighting the word “template”, Not sure why

I’m glad I’m not the only one struggling with this…

It appears you’re trying to nest another condition beneath your then/while/condition lines?

Some guys on Discord nailed it. It was a pretty intense discussion! :

text_sensor:
#get these object values from home assistant 
  - platform: homeassistant
    id: hvac_action
    entity_id: climate.dev_wood_pellet_stove
    attribute: hvac_action
    on_value:   # When value simply changes
      then:
        - if:
            condition: 
              and:
                - binary_sensor.is_on: p5z 
                - text_sensor.state:
                    id: hvac_action
                    state: 'idle'
#               - lambda: return id(stove_pipe_temp).state >=  250 ;
#both work.  sensor.in_range is just more betterer!
                - sensor.in_range:
                     id: stove_pipe_temp
                     above: 250.0
            then:
              - switch.turn_on: p5_indicator
              - logger.log: "P5 active.Auger ON, in WHILE LOOP " 
              - switch.turn_on: auger_output_to_optoisolator    
              - logger.log: 
                  format: "logger: hvac_action= %s"
                  args: ['id(hvac_action).state.c_str()']
              - delay: !lambda "return id(auger_on_timez).state * 1000;"
              #
              - switch.turn_off: auger_output_to_optoisolator  
              - delay: !lambda "return id(auger_off_timez).state * 1000;"
              - logger.log: "P5 active Auger OFF after auger_off_timez, exiting WHILE LOOP"   
        - if:
            condition:
              - binary_sensor.is_off: p5z #p5 is not active
            then:
              - switch.turn_off: auger_output_to_optoisolator  
              - switch.turn_off: p5_indicator
    ```
1 Like

The users and developers in the Discord channel have been of great assistance to me on many occasions. They are a GREAT bunch of people. :partying_face:

1 Like