Platform nut sensor into a on/off switch that activates when in battery mode

Hey all trying to create a switch in home assistant for when my ups goes to state “online battery discharging” has anyone done this with a template switch ? my sensor name is “sensor.ups_status” and the state to activate switch to on is “Online Battery Charging”
this is using the NUT platform

I think you are looking for a template binary sensor, not a switch, if you just want an indicator of whether the UPS is current charging or not.