Monitoring TV status?

Hi, is a a way to monitor the status of the TV via CEC? My kind of elderly parents keep forgetting to stop the TV stream from tvheadend when they switch off their TV. This increases power consumption, but especially, they keep blocking a tuner on the TV server.
Right now, I am monitoring the TV status through the power on USB port of the TV. it is connected to a RPi GPIO via an optocoupler. When the TV switches off, I send a stop command to Kodi with a python script.
In the next upgrade, I want to use to the Vero 4, so I don’t have GPIOs available anymore. An external hardware solution would be an Arduino Pro Mini, which can send the stop key to the Vero via USB. But in general, this should not neeed any external hardware, only CEC.

What would be the most elegant way to deal with this? Do I have to poll the TV with the cec-client, or is there a logfile I can monitor or even a hook?

I think there is an option to stop kodi playback when tv is being shut off in the cec options (system - input - peripherals i think).

Thanks. On my RPi3 I do have this option (but my projector doesn’t react on it.) On my Vero 4k, There is only Ignore/Switch off/Standby, but no Stop. Stop is only featured in the selection for what to do when the source is changed.

Can you:

Screenshot both
Make sure settings are on Expert mode

If you want a programmatic way to determine TV power for scripting purposes I can do this as well

Sam

Can you:

Screenshot both
Make sure settings are on Expert mode

If you want a programmatic way to determine TV power for scripting purposes I can do this as well

Sam

Here is a screenshot. The other two options are “Suspend” and “Shutdown” - which both don’t really make sense since there is no way to switch the Vero on again, is there?

I have to add that I have trouble with CEC anyway. It is a Medion P18088 that I got for really cheap. Despite the fact that I activated HDMI-CEC in the options, the Vero does not show up in the device list and I cannot use the TV remote for controls. ‘echo “standby 0” | cec-client -s -d 1’ does not result in anything.
The Vero CEC worked on my projector.
Since the background illumination is really bad, I am seriously thinking about sending the TV back.

Try changing the HDMI cable
Make sure your Vero 4K is up to date

Sam

Vero is up to date, but changing the HDMI cable from the one shipped with the Vero made controlling the TV via the remote working. However, the menu options did not change, not even after a reboot.
The option to send the TV to standby when the screensaver is activated also has no effect.

Unfortunately, I found that the picture quality is terrible (foggy scenes look like watched trough a veil, due to terrible background illumination and a few other issues), so I am going to return the TV. If the options in the CEC menu are somehow defined by the TV, I’ll be back in two weeks if it doesn’t work with the next one :slight_smile:

Though a working “Stop playing on TV off” would be sufficient for my current needs, I would still be interested in programmatic way.

Ok, reporting back with a new TV (Hisense). Everything regarding CEC works now, I can switch it on and off via commandline CEC client and all that sort of jazz. I am in general much happier with it.
The option for actions to be performed when the TV is switched off are unchanged, though.I cannot make it send a stop command, which is a real bugger because if the TV stays on on the Vero, it blocks a tuner und the tvheadend server.
Any ideas?

That’s good to hear.

I don’t quite get the question. Do you mean that you want to be able to Stop playback using the Stop button on the TV remote when the TV is off? I’m not sure that would work.

From a programattic perspective, /sys/class/amhdmitx/amhdmitx0/hpd_state will equal 0 when the TV is off or the HDMI cable is not connected.

No, this is not about the TV remote.
Right now, the CEC options in Kodi seem to offer me to suspend or shut down the Vero when the TV is switched off (highlighted menu option in the screenshot above). Neither seems to make much sense vor the Vero, because as far as I understood, the S905 does not have a real shutdown state.
Instead, I just want to stop the current playback when the TV is switched off. (Else, the TV program will keep running on the Vero and block a tuner.)
/sys/class/amhdmitx/amhdmitx0/hpd_state is always 1, regardless if the TV is switched off or on, even when I do it via echo "standby 0" | cec-client -s -d 1

Hi

Just to give you some background about this. Vero could be put in to suspend mode, and we could use the scp_task firmware to listen for wakeup events via CEC and even IR, but this wouldn’t be possible for USB events (RF remote), so we don’t bother implementing this at this time.

Are you turning the TV off or standbying it?

I just double checked to be sure, and hpd is now always unmuxed on power loss or unplug because some people had ‘No Signal’ issues on Vero 2 with some TVs.

I suspect either of the two will change:

/sys/class/amhdmitx/amhdmitx0/ready
/sys/class/amhdmitx/amhdmitx0/disp_cap

When your TV is being turned off.

I can always make the HPD mux a tunable (module_param), and then you’d be able to change this behaviour. Then hpd_state would probably reflect the state more accurately.

Cheers

Sam

Same issue re: CEC direction to stop playback when TV is turned off.

Sorry, should have been more accurate. I am mainly talking about sending the TV to standby, i.e., pressing the red button on the remote. When I do that, I do not want a TV program to keep running, since it would unnecessarily block a tuner un the TV server that could be used e.g. for recording.

/sys/class/amhdmitx/amhdmitx0/ready
/sys/class/amhdmitx/amhdmitx0/disp_cap

Unfortunately, non of these changes. ready is always 1 and the modes in the other stay the same.

Thanks for clarifying.

It seems like your TV is still holding the state when it’s turned off. This can make things a bit trickier to detect when the TV is actually off.

I’m working on some updates for OSMC at the moment, so please remind me in a few days to look at this again and I’ll see if I can come up with anything

Sam

Hi ElCaron

Someone posted a workaround here

http://forum.kodi.tv/showthread.php?tid=235026&pid=2570377#pid2570377

Thanks for the suggestion, but not putting a strange Chinese device into my network was one central reason to buy the Vero.

It is not necessary, though. echo "pow 0" | /usr/osmc/bin/cec-client -s -d 1 returns

opening a connection to the CEC adapter...
power status: on

and

opening a connection to the CEC adapter...
power status: standby

just fine, so I can poll for that as a workaround.

Nothing in /sys/class/amhdmitx/amhdmitx0/ changes between on and standby. There is a directory power, bt it is empty.

Hm, well, or not …this seems to kill CEC ability for kodi as soon as I run the command … I guess the Kodi CEC session gets disconnected?
Edit: Yup, Running cec-client disconnects tv/kodi · Issue #123 · Pulse-Eight/libcec · GitHub

Edit2: Nothing in journalctl or the whole .kodi directory changes, either.

You can use Kodi jsonrpc to turn off the player. I have a cron job which turns on a radio channel in the mornings, and off again in the evening. It’s just a curl to a few lines of php.

You could just run off the player, say at 11pm (or whenever), and that would release the tuner.

Let me know if you want and I can dig it out for you.

I know HOW to stop the player. I have implemented that myself in the USB monitoring script via GPIO mentioned in the first post, and I could take it from the ping workaround mentioned above. What I need to know is WHEN to stop the playback. Randomly letting my TV run until late at night and then switching off with a cronjob while watching a movie is by no means an appropriate solution.

Before I give in to that, I’ll rather solder a USB cable to an Arduino Pro Mini, which could issue an ‘s’ keypress when the voltage on the USB port goes away. But all of that is quite a ridiculous solution given that the Vero COULD know perfectly well if the TV is running or not.