Compare sensor to input.number

I’m trying to establish a condition where a certain sensor is above a value I can adjust and that will impact how others automations behave.
I’m only now starting to understand how to code, and moving deeper into the automations.

condition: template
alias: "Battery above minimum -1"
value_template: "{{
  states('sensor.solax_local_battery_soc’)|int >
  states('input.number.minimum_battery_flux_peak')|int -1}}"

When I test the condition this is the error I get:

Invalid condition configuration
invalid template (TemplateSyntaxError: expected token ‘,’, got ‘input’) for dictionary value @ data[‘value_template’]

Do you have any idea of what might be causing this? The minimum battery value is defined as 85, and the battery is at 95 so it should at least validate as true when we test the condition in the visual editor, no?

That is the wrong type of quotation.

1 Like

Thank you tom_l :+1:

I made the edit and now I get the error:

Error occurred while testing condition

In ‘template’ condition: ValueError: Template error: int got invalid input ‘unknown’ when rendering template ‘{{ states(‘sensor.solax_local_battery_soc’)|int > states(‘input.number.minimum_battery_flux_peak’)|int -1}}’ but no default was specified

Should be
states('input_number

1 Like

:man_facepalming: rookie mistakes… Thank you so much

Final code:

condition: template
alias: Battery above minimum -1
value_template: >-
  {{ states('sensor.solax_local_battery_soc')|int >
  states('input_number.minimum_battery_flux_peak')|int -1}}
1 Like