Long-time entity status duration tracking

I would love there to be an easy first-class way to track the amount of time an entity has been in a particular state since some cutoff datetime.

My use-case: I just replaced some lightbulbs that are behind a home-assistant controlled smart switch. The bulbs I put in are rated for 8000 hours of use, but it felt like the last ones died sooner than I would have expected. I want some way to track approximately how far through those 8000 hours I am so far so I can see when these current ones die relative to when they are rated for.

Currently I have an ugly and confusing mix of a daily History Stats sensor tracking the light per-day and a Utility Meter pointed at that History Stats sensor to (hopefully) track the uptime over the long term. However I’m not actually confident that my setup actually works, since I have to wait until at least tomorrow until seeing if the Utility Meter is configured properly.

It would be really nice instead if there was some helper that just tracked a long-term duration value for some entity+state combo that could be reset back to 0 (i.e. when I next change the bulbs).

Before anyone says “just use History Stats”, running 8000 hours of a light could take years, depending on how much time it spends on per day. Even keeping it on 24/7 it would take 333⅓ days. I don’t want to keep that much detailed history in my database, and History Stats (as far as I can tell from the docs) can’t pull from long-term stats.

If I’m missing something that can cleanly solve this problem already then I apologize, but I searched for a while and I couldn’t find anything that seemed to do what I wanted.

Just a thought.
Wouldn’t the history stats set to today and an automation at 23:59 that does input_number = input_number + history_stats work?

I’m not dismissing your request, I see there are a few people wanting to track stuff, but in the mean time I believe the above could work.