Combine two binary_sensors into one?

I currently have two input_numbers that I want to use to determine when my battery charger should switch on. They look like this:

- platform: template
  sensors:
    niu_start_charge:
      friendly_name: Niu Start Charge
      value_template: "{{ states('input_number.niu_battery_min') | float > states('sensor.niu_battery') | float }}"
- 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 }}"

niu_start_charge is on when the battery level is below the value input_number.niu_battery_min and niu_start_charge is on when the battery exceeds the value of input_number.niu_battery_max. sensor.niu_battery is the current charged level of the battery.

I can use these binary_sensors to establish when to start and stop the charging process but it requires two seperate automations. I’d like to be able to combine the two binary_sensors given above into just one, which only returns true when the battery level is below the minimum value and below the maximum level. But, it should not be on when it is above the minimum level even if that is below the maximum charge level.

So… Is there a way to combine those two binary_sensors into one? If so I’d appreciate a nudge in the right direction.

Thanks

  1. Create a new sensor with a value_template that combines both the less than and greater than checks.
  2. Modify the automation to trigger on either of those binary sensors
  3. Create a group of both sensors, the group will be on if one is on
  4. Use the threshold sensor. https://www.home-assistant.io/integrations/threshold/

I appreciate the response but I was hoping for some help with combining the two value templates as asked in my post. Apologies if that wasn’t clear.

Thanks.

Something like that maybe?

- platform: template
  sensors:
    niu_reached_threshold:
      friendly_name: Niu Reached Charging Threshold
      value_template: "{{ (states('input_number.niu_battery_max') | float <= states('sensor.niu_battery') | float) or (states('input_number.niu_battery_min') | float >= states('sensor.niu_battery') | float) }}"

That looks like it should work.

Thanks.