I thought I would simply create this automation but it seems to be much more difficult then I expected.
When my media player starts playing the entity changes from ‘idle’ to ‘playing’. When this happens I want a counter to start so I can actually see how long the media player is playing. When the media player stops playing (changes to idle) the counter can stop.
Solutions I found are mostly with two (or more) helpers, with multiple automations, with history stats, timers that count down (not up), counters that increment every second (and need to be formatted into minutes) etc.
Is there a more simple solution where I can start counting in seconds/minutes/hours and stop (and reset)?
My idea is to reset the counter after the state is idle for x minutes. My media player goes to idle immediately after an episode ends, but when a new episode starts a few seconds later it changes to playing again.
I think it’s best to record a ‘session’ and reset after it’s for example 5 or 10 minutes idle.
It does not need to stop when it goes to idle, it can keep on counting. Maybe this would be something for a next step but for now I’d like to create something that works and is simple.
Someone starts playing something on the media player, counter starts, I come home and I can see the person is watching for X minutes. I don’t need to know how many times the media player paused or changed to idle. When person stops watching, ‘sessions’ ends, counter resets after 5 minutes.
One idea I have is create a timer of let’s say 60 minutes that’s starts counting down when the media player is playing. After 25 minutes there is 35 minutes left on the timer and I somehow invert this leftover time to wachted minutes. But also seems complicated for such a simple wish.
Maybe the way I wrote it down is not clear. It should be:
When the media player stops playing (the person stops watching) and the state changes to idle for over 5 minutes the counter can stop.
Ideally I’d like to use the options start/pauze/cancel/finish like the timer. With this options I could pauze when state is idle and start again when its playing. And when it’s idle for over 5 minutes I can finish the timer.
But since this does not exist I would like to create something that gives me an indication how long the media player is playing and is not precise.
Can we back up a little and answer two questions? I am asking because the data reported to HA is very different based on the media player device installed.
Questions
Who is the manufacturer of the media device?
What HA integrations were used to install the media player?
Hi, its a Nvidia Shield with Plex installed. I use the Plex integration and I would like to create an automation for Plex. I simply want to track how long someone is watching stuff.
Working with a timer kind of solves my problem, I set up a timer of 60 minutes and it’ll start counting down when someone starts watching. In general no one is watching longer than 60 minutes so when I see the timer is at 45 minutes I know Plex is playing for 15 minutes. But I’d like to make it neater/ cleaner and just show the time elapsed.