Automation sensor value above input slider

I recently added a temperature sensor in my fridge, since my fridge needs to stay around 20 degrees. I have an automation working which turns the fridge on and off around 20 degrees, but sometimes I would like to change the target temperature. That is why I want to use an input slider. I have tried a lot of examples from this forum and the home assistant website, but always get an error.

- alias: Turn On Fridge
  trigger:
      platform: template
      value_template: {{ states('sensor.fridge_temperature') > states('input_number.slider1') }}
  condition:
    - condition: state
      entity_id: switch.beer_fridge
      state: 'off'
  action:
    service: homeassistant.turn_on
    entity_id: switch.beer_fridge

And this is the error I get:

Error loading /config/configuration.yaml: invalid key: “OrderedDict([(“states(‘sensor.fridge_temperature’) > states(‘input_number.slider1’)”, None)])”
in “/config/automations.yaml”, line 32, column 0

Does someone know what is wrong with the value template?

You are comparing strings. Also single line templates need to be enclosed in quotes. Try this:

value_template: "{{ states('sensor.fridge_temperature') | float > states('input_number.slider1') | float }}"
2 Likes