Tracking "time consumption" of a switch

Hello, i’m building a esp-home device driving the anti-mosquitoes electric appliance. It has a cartridge that should last (let’s say) 80h
So i’m looking for a way to track how long the relay has been active, so i know when to change the cartridge and reset the counter.
I thought i could use an integral, but no way a binary_sensor can feed a integral. So before starting to try strange solution (a fake input_number to feed an integral? a timed sensor to add time once a minute?) i was wondering for an hint, it doesn’t seem a use case that strange, so probably a clean solution is out there and i’m just missing it…
And it’s not about “showing” with history chart, i’m not interested in the elapsed time used to reach the limit, it’s the limit by itself
thanks

Use History Stats to capture how many hours the binary sensor is ‘on’, then feed that into a integral or Utility Meter.