Compare input_number value with sensor value

I’m trying to create a binary sensor that switches on when a battery has a charge lower than that defined via an input_number. The battery value is reported via a sensor as a percentage.

Here’s what I’ve got so far, but this doesn’t work. I’m assuming it’s because the sensor.niu_battery is reported as a percentage.

- platform: template
  sensors:
    niu_end_charge:
      friendly_name: Niu End Charge
      value_template: "{{ states(input_number.niu_battery_max) | float < (sensor.niu_battery) | float }}"

Any ideas as to what I’m doing wrong? Suggestions for things to try?

Thanks.

You were very close but missed a few important quotes and a function name:

- platform: template
  sensors:
    niu_end_charge:
      friendly_name: Niu End Charge
      value_template: "{{ states('input_number.niu_battery_max') | float < states('sensor.niu_battery') | float }}"

Of course.

Thanks, I’ll try that asap.