Count cumulative tv-on time

Hi there!

I want to record the tv-on time of our LG G1 television. I’ve found many tuts to accomplish some tv-on time recording, but most of them is just one day, or as long as the recorder records…

However, i just want to see the tv-on time since the beginning. We’ve watched around 2000 hours now since we have him (i know, because last week the auto pixel refresher runs, and thats after 2000 hours).

So, i want a tv-on timer to check how many hours our tv was on.

I also found this topic: Handling long term cumulative historical data (finalizing days) - #9 by CM000n

but… that’s quite a lot of work for something simple i think. And it’s also 2 years old. There must be an easier way isn’t it?

TLDR;
how can i record tv-on time for a long long long period?

Since 2021.8 there are long-term statistics in Home Assistant, but so far they support only a very few sensor types. You can try to enforce the long term statistics like it is described here: Benefit from long term statistics for any sensor

Anyway I think my approach would probably still be the most flexible solution. Especialy If you want to use your sensor values in other systems. For example grafana. You can also use Influxdb to store long-term information if you are more familiar and comfortable with it. But I prefer Timescaldb because I can do standard SQL queries and operations with it.

As a second aproach you can just increase your recorder purge interval and work with history stats sensors: History Stats - Home Assistant
Of course, you need to have enough storage capacity for this because it will now store all of your sensors for the longer purging interval. The recorder component is no good choice for storing long term data in my opinion.

The third option would be to possibly build something with multiple template and history stats sensors.
You could calculate the TV consumption per day and add this to a sensor with the total consumption, which in turn is summed with itself.
For example something like that: Calculate cumulative total sensor from daily total sensor - #6 by matys