Struggling with binary_sensor template

Hi,
I’m trying to define a binary_sensor that is on according to attributes of two entities but HA returns error, what I’m doing wrong?
code:

binary_sensor:
  - platform: template
    sensors:
      inhibit_vortice_1:
        value_template: "{{ state_attr("weather.home", "humidity") >= state_attr("climate.vortice_1", "temperature")}}"
      inhibit_vortice_2:
        value_template: "{{ state_attr("weather.home", "humidity") >= state_attr("climate.vortice_2", "temperature")}}"

Error message:

Error loading /home/homeassistant/.homeassistant/configuration.yaml: while parsing a block mapping
in “/home/homeassistant/.homeassistant/packages/gestione_vortici_bagni.yaml”, line 25, column 9
expected , but found ‘’
in “/home/homeassistant/.homeassistant/packages/gestione_vortici_bagni.yaml”, line 25, column 41

Line 25 corresponds to line 5 in code above (e.g. “value_template:…”)

Thanks for any hints

PS: when I test on Developer Tools ==> Template it works…

Start with using single quotes inside the double quotes

value_template: "{{ state_attr('weather.home', 'humidity') >= state_attr('climate.vortice_1', 'temperature')}}"

You may also need to convert the attributes to numbers to be able to compare them.

value_template: "{{ state_attr('weather.home', 'humidity')|float >= state_attr('climate.vortice_1', 'temperature')|float }}"

@tom_l @micque thanks both of you: with suggested changes, it works perfectly

1 Like

Hello, may I ask if you have vortice’s modbus heat recovery device, how do you accept the homeassistant control?