Req Stop playback when television switched off
In the Kodi Menu System -> Input -> CEC I can select what happens when the television is switched off. I can select either shutdown or suspend. Neither of those choices is an option with the RaspberriPi because suspend is not supported and shutdown is a bad idea since you can't boot it without plugging power.

So I let my pi with OpenElec run 24/7 but at least I want to make sure that the playback, especially in case of broadcasting, stops after switching the TV off. It would be nice if you add an option to stop playback when the TV is switched off.
Moving this to the correct forum...
Texture Cache Maintenance Utility: Preload your texture cache for optimal UI performance. Remotely manage media libraries. Purge unused artwork to free up space. Find missing media. Configurable QA check to highlight metadata issues. Aid in diagnosis of library and cache related problems.
1+ for this request

@athei, have a look at this:

It's not what you asked for, e.g it wont stop playback with CEC, but it is a timer, that will stop the stream... I have a daughter that uses a RPI2 and watches TV using the MythTV addon.. she would often turn the TV off but leave the stream running... which meant the stream was constanlty being recorderd on my backend - not a big problem, but i just didnt like the idea...

With this addon it will turnoff the stream at set time when there's been no interaction - i've set mine at 4 hours i think
Should be quiet simple to add, but I think we will need a libCEC change/feature for it to be clean code.
Needs to be added here
and in some xmls then.
a colleague of mine is actually working on this. No ETA though, since its his first ever try at kodi
That sounds good. Maybe can drop a message here when the feature is done Smile
+1 request


I created a patch, but i can not build patched kodi from source (and don't know, how it works).
wsnipex, please, add this feature. It's very useful for cec users.

Link to patch:
I'm not sure about the call Action(Stop), maybe need other method here.

Updated 14.12.2015:
I built patched Kodi. Everything works, but there is a problem with the display and update settings.
New patch:

Manual for Ubuntu:
PHP Code:
apt-get source kodi
sudo apt-get build-dep kodi
cd kodi_15.2~git20151019.1039-final/
mkdir debian/patches

Then download two files into debian

sudo dpkg -../kodi-bin_15.2~git20151019.1039-final-0trusty_amd64.deb
sudo dpkg -../kodi_15.2~git20151019.1039-final-0trusty_all.deb 
I found interesting solution.
I powered it from TVs usb Smile
(2016-09-03, 20:06)Winters Wrote: I found interesting solution.
I powered it from TVs usb Smile

That's probably not the best solution for two reasons:
1. Your Pi will suddenly lose power, which can cause your sd card to become corrupted.
2. Your TVs USB ports probably don't output 2A+, which is recommended for the Pi to work properly.

A Logitech Harmony could solve your problem!
(2016-09-03, 20:06)Winters Wrote: I found interesting solution.
I powered it from TVs usb Smile

Is there a setting to stop playback when the pulse-eight adapter is turned off?
I really also wanted this feature but found out that none of the suggested solutions are ideal. I wanted to stop the Live TV almost instantly when TV is switched off. I tried to see if commands tvservice -s or fbset return any different information when the TV is on or off but those returned same output regardless if the TV was on or off.

However, I found out one easy solution that works if you have connected the Kodi via HDMI to a receiver which has network connection and you have connected the receiver to your local network. You can simply monitor when your receiver stops responding to ping and then call Kodi with JSON-RPC API to stop playback.

For example, my receiver has IP and I have enabled HTTP JSON RPC from kodi settings (see this: ). I have then added the following script via SSH to system running Kodi to /storage/scripts/

if ping -c 1 -W 1 >/dev/null; then
  echo "$(date -Iseconds): TV is on. Doing nothing."
  echo "$(date -Iseconds): TV is off. Stop Kodi playback."
  curl -H "Content-Type: application/json" -X POST -d '{ "jsonrpc": "2.0", "method": "Player.Stop", "params": { "playerid": 1 }, "id": "mybash"}' http://username:[email protected]:8080/jsonrpc
  echo ""

Then with crontab -e, I modified crontab to have these:
0 3 * * * echo "$(date -Iseconds): Log cleared" > /storage/scripts/detect_tv_off.log >/dev/null 2>&1
* * * * * /storage/scripts/ >> /storage/scripts/detect_tv_off.log

So every minute, the script checks whether the receiver responds to ping, if not it calls Kodi to stop playback. This works well for me since when I stop watching TV, I switch off the receiver. Now I don't have to remember to press stop from my remote but within one minute playback will be automatically stopped.

EDIT: Also I found out that there is command line tool cec-client which could also work to detect if TV is off and then one could run the same JSON RPC command to Kodi to stop playback. But using ping in this case is much more simpler.
Solution found in this post:

Logout Mark Read Team Forum Stats Members Help
Stop playback when television switched off1
This forum uses Lukasz Tkacz MyBB addons.