Working time on entity

I have a number of sonoff s26 smart plugs with attached mozzie zapppers. I have successfully (utlising great help from here) set up these to only turn on at sunset and turn off at sunrise. This automation is triggered when I turn on a helper boolean.
Because the zappers are in differrent rooms they each turn on for different lengths of time depending on if we have guests etc.
I know the amount of time that the mozzie zapper inserts should run for.
I want to be able to monitor how long they have run on their automation cycle and then have an alert sent to me when they are near 100% of expected run life.
Is it possible to accumulate run time of an entity and send an alert based on a calculated amount?

You can use History Stats to calculate the total ‘on’ time for a period, up to your “purge days” as defined for the recorder. However, I assume the devices run for a period of months, so this won’t be useful.

You could just accumulate the total and reset it to zero when you buy a new one (assuming that’s the use case). For example, use History Stats to get the total ‘on’ time for the day, and then at the end of the day, add the number of minutes to an input number. If you also set state_class to “total_increasing” it will keep long-term statistics so you can graph the usage over time (beyond “purge days”).

thanks for that. Now to do some reading on how to get that done.