Kodi Community Forum

Full Version: CEC Config to stop PVR Playback on TV Switch Off
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi All,

Apologies if there is another thread on this (I looked, but couldn't find).

I'd like to be able to configure CEC so that when the TV is turned off, PVR playback is stopped. It's not unusual for other members of the family, or guests to just turn off the TV, but leaving the PVR playing live TV. This leaves my tvheadend server busier than it should be and also keeps the stream open and occupied.

I know there is an option for "Pause playback" - but that's almost worse, right.. leaves the stream open but keeps it recording the live stream.

Is there any way to do this, am I missing something silly, or is it a feature request?

Thanks!
If this is a windows pc you could use event ghost to detect when your tv is turned off/disconnected and then send the stop command.
No, not a windows PC. I have 3 Raspberry Pi's, 1 Cubox and 1 Ubuntu based PC... All connected to my various TV's in the house.
So this needs to be something within Kodi I guess.
In that case I would use an IR sensor so anytime the power button is pressed on the remote then stop is sent to kodi. There are some good IR sensor tutorials for the Pi. I dont think Raspberry pi supports cec.
Raspberry Pi supports CEC, as does Cubox and my PC through use of the CEC Adapter. So building an IR sensor doesn't seem like an elegant solution. (In fact, the fact that Pi supports CEC is one of the reason's it's such an ideal device for Kodi connected to a TV)

Am I the only person that thinks this is a real requirement? :-)
(2015-11-03, 09:59)stevellion Wrote: [ -> ]Raspberry Pi supports CEC, as does Cubox and my PC through use of the CEC Adapter. So building an IR sensor doesn't seem like an elegant solution. (In fact, the fact that Pi supports CEC is one of the reason's it's such an ideal device for Kodi connected to a TV)

Am I the only person that thinks this is a real requirement? :-)

I think this is a good idea as well.

Currently I'm trying to work out how to tell a PI that a TV has been turned off using scart output ... (it's an old TV!)

There is already an option under Settings->System->Input devices->Periphierals->CEC Adapter->"When the TV is switched off" with options "Suspend/Ignore/Shutdown". (At least on the latest RPi Millhouse build)

This looks encouraging, but there is no 'Stop Playback' option... but it probably wouldn't be that difficult to add one. (It's not a bit of the code I'm familiar with unfortunately - yet... Smile.

Personally I power my main PI from a USB socket on the TV itself. If you are lucky and have 'delayed USB poweroff' on your TV, you can set this to 'Shutdown' which will hopefully work. When the TV powers up next time the PI will do a fresh start.

Not all TVs have delayed USB powerdown (my LG doesn't), so although it might still work you run the risk of periodic SD card corruption (which tends to get a hostile reception from the wife). I'd suggest, test it and see...
I've had issues with the Pi shutting down too early when using a TV's USB, so just leave them running now.

I too suspect it wouldn't be too difficult of an option to enable the option in the CEC setting you mention of "Stop Playback"
That would really apply to any content, not just live TV really, because the database holds the current position, when you turn the telly back on, you can just resume anyway.

Actually, I downloaded the source myself yesterday to see if I could figure out where the settings are for the CEC input, but I couldn't find it yet...
I have identically configured RPIs connected to different TV brands. In the case of the Sony, turning off the TV or switching away from the PI's HDMI port will stop playback. On the Hitachi it doesn't stop playback. I don't know why this happens other than it being a difference in the way CEC is implemented on the TVs. Is there anything that can be done to make playback stop on the Hitachi TV?
(2015-11-12, 16:51)jmooremcc Wrote: [ -> ]I have identically configured RPIs connected to different TV brands. In the case of the Sony, turning off the TV or switching away from the PI's HDMI port will stop playback. On the Hitachi it doesn't stop playback. I don't know why this happens other than it being a difference in the way CEC is implemented on the TVs. Is there anything that can be done to make playback stop on the Hitachi TV?

Do you mean it actually Stops playback.. or pauses? There is definitely a setting to pause, which is fine for some things.. but not for live TV playback from a PVR backend.
(2015-11-27, 18:42)stevellion Wrote: [ -> ]
(2015-11-12, 16:51)jmooremcc Wrote: [ -> ]I have identically configured RPIs connected to different TV brands. In the case of the Sony, turning off the TV or switching away from the PI's HDMI port will stop playback. On the Hitachi it doesn't stop playback. I don't know why this happens other than it being a difference in the way CEC is implemented on the TVs. Is there anything that can be done to make playback stop on the Hitachi TV?

Do you mean it actually Stops playback.. or pauses? There is definitely a setting to pause, which is fine for some things.. but not for live TV playback from a PVR backend.
Since the tuner is taken away, the last image received freezes on the screen. As long as I don't touch any player controls, I can login using ssh or access log files using samba since linux is still running. Once I click a player control button, the device freezes and the omly option is to do a hard reset by unplugging the power.
I'm pretty sure that's because it has paused playback, not stopped it. I've seen similar lock ups too, making me think it's a memory leak.
The key issue though is by pausing, your PVR back end is still recording the live TV unnecessarily.
perhaps I don't read the requirement right - but if I do, that functionality was added to Kodi months ago.

Aug-09 if I recall

https://github.com/xbmc/xbmc/pull/7160
@jmooremcc

the actual event which triggers this function is CEC msg sent from TV saying "Standby". what actually means TV went off.

if the TV is not sending it, then of course Kodi's CEC thread has no idea of it - if you change input (active source) away from HitachiTV, that one works?
normally it happens, that various manufacturers are implementing CEC how they feel right - so not always 100% according Specs. But in case of "Standby" msg this would be very very messed CEC - as practically on TVs ability to send own status depends quite big part of CEC functions.

(and for instance ONE BUTTON -> standby all devices is pronounced mostly in marketing materials - and that exactly depends exactly on TVs Standby msg - even no other device on bus is allowed to send that, just the TV).

What you can check is a menu option somewhere hidden it TVs settings - for instance Samsungs have this function being set to OFF by default).
Just checking the menu and it is System -> Anynet+ -> Auto Turn Off -> on/off (and only when ON, tv sends "Standby" when going off.
(2015-11-28, 13:58)mk01 Wrote: [ -> ]perhaps I don't read the requirement right - but if I do, that functionality was added to Kodi months ago.

Aug-09 if I recall

https://github.com/xbmc/xbmc/pull/7160

Thanks for flagging mk01 - exactly what I'm after. Just need Jarvis now :-)