How would I calculate cumulative total time ON vs cumulative total time OFF in a 24h period?

Hey gang

I have a binary sensor that is “on” or “off”

How would i go about calculating 2 numeric template sensors (based on time) - one that calculates a number of minutes in a 24hr period the sensor is “on” and another that calculates a number of minutes it is “off” in the same 24h period???

I truly dont know how to approach this…

One history stats sensor for on and one for off.

Or one history stats sensor for on and a template sensor of 24hrs minus the on-time to get off time.