Help with binary sensor issue

I am trying to create a binary sensor to turn on heating when the temperature is below 17.5. My template below doesn’t seem to work. Any assistance would be welcome.

binary_sensor:
  - platform: template
    sensors:
      heating_required:
        friendly_name: "heating required"
        value_template: "{{ state_attr('sensor.upstairs_temp_d2', 'temperature')| float < 17.5}}"

what do you get when you put {{ state_attr('sensor.upstairs_temp_d2', 'temperature')| float }} into Developer Tools > Template?

Thank you for your help. I get 0.0, so this must mean I have something wrong.

Thank you Glenn,
I have changed my statement to below and I think it works.
value_template: “{{ states(‘sensor.upstairs_temp_d2’)| float < 17.5}}”

1 Like