Control TV ON/Standby/Toggle using CEC Kodi built-in functions

Dear all,
I am running up to date OSMC release on RPi2. It works just great and stable.
OSMC over HDMI CEC control from my TV (Panasonic TH-37PX80E) remote control works also OK.

I tried the opposite direction and control also my TV using CECclient from RPi side: echo ‘standby 0‘ | cec-client –s RPI & echo ‘on 0‘ | cec-client –s RPI also works just OK and I am able to turn on and standby my TV (however this kind of control disconnects xbmc CEClib so I try to use xbmc buit-in fuctions to control TV over CEC (

I have created some scripts scenarios using xbmc python scripts to control TV on/off depending of the file type (scenarios when xbmc.Player().isPlayingVideo() shall turn on my TV, when xbmc.Player().isPlayingAudio() I want push my TV into standby mode).

I can successfully turn on my TV sending xbmc.executebuiltin(‘CECActivateSource’) from my xbmc script.
However xbmc.executebuiltin(‘CECStandby’) and xbmc.executebuiltin(‘CECToggleState’) does not work at all.

Does anybody have an experience with those built-in functions whether working properly please? (I have of course enabled on my Panasonic TV Viera link remote on and standby features).
I am not sure if this is a problem of my TV support or some problem with CECStandby and CECToggleState xbmc built-in functions in OSMC (again, from CEC client I can control TV on and standby).

Thank you for your help.

I have a Samsung TV and I’m experiencing a similar issue.

I’ve attempted to create a main menu shortcut called “TV off” which issues the command CECStandby(), but nothing seems to happen when this main menu item is selected.

The TV does correctly power up when a button is pressed on my keyboard, and Kodi responds to the TV’s remote, so the CEC connection seems fine.

I’m sorry I don’t have an answer, but I join you in looking for one.

I’m having the same issue. CEC standby and toggle used to work on Raspbmc but a few months ago my previously functioning scripts stopped working. I was hoping the switch form Raspbmc to OSMC would fix the issue but no luck.

Edit: I tried running
echo "standby 0" | cec-client -s
from the command line and the tv turns off so it appears to be an issue within osmc/kodi.
The log file shows it executing but the command seems to go to a black hole because the TV is still on after.
‘DEBUG: ToggleDeviceState - putting CEC device on standby…’

1 Like

Hi everybody,

I have the same problem. After using custom cec-client command the TV remote stop operate the OSMC. Can somebody help to re enable it please? …Sometimes it reenable after a long period but it is not sufficient for my intends:)

Thx in advance for any possible help.

If anybody with the same issue… web search showed me two or three similar topics.

I checked KODI 14 and libcec2 and there is not a nice solution for this in the present. Kodi auto reconnects cec on wake without custom possibilities.

I disabled the native kodi cec input and I am using my own solution. On the end of this week I can provide the solution for Panasonic Viera… if there is an interest

More possibilities will come with libcec3, which comes with KODI 15. I think its waste of time to prepare a native solution for libcec2, KODI 14.

If KODI 15 will miss wider cec possibilities I can prepare a proper patch for KODI… if there is an interest

Hello, I’m having the same problem with Panasonic. When i try to use my remote control it gives ‘’ Feature is not available’’ message. Could you tell me about your solution?

Thanks in advance.

Hello, my issue was that cec works great with OSMC but after using cec-client from command the remote control stopped working with OSMC.

Does following command show you the CEC devices?

echo "scan" | cec-client -s -d 1

If not, you have different issue.

After previous post I slightly change my mind because I found this , which is great for my intention.

A few important features not implemented yet so I added methods like “cec.set_active_source()” and a few more…

I also inspired in this simple daemon. …I thought that different tv brands have different key codes… apparently not:) Using uinput, remote control works well.

Finaly, I am writing python script (called from, using class xbmc.Monitor(), Player(), … described here. The script also turn on and off different hdmi devices and many others.

Just to inform, I have reported the disconnect (using cec-client will cut the link with Kodi/OSMC) issue over here

So the problem is not solved with Kodi 15 (and therefoe libCEC 3.0).

Is there already a solution.
I’d like to turn off the TV without losing control over CEC afterwards.
“kodi-send --action=“CECStandby”” doesn’t work at all.
There is a new Yatse feature to turn off and on the TV. Activating the TV via CEC and Yatse works, standby doesn’t.

This is how I did it. Works with my Samsung TV.

  1. install Nyancat screensaver

  2. navigate to osmc:~/.kodi/addons/script.screensaver.nyancat

  3. In edit the onInit and exit functions. Add subprocess calls to cec-client:

     def onInit(self):'/bin/echo "standby 0" | /usr/osmc/bin/cec-client -d 1 -s', shell=True)
         self.exit_monitor = self.ExitMonitor(self.exit)


    def exit(self):
        self.abort_requested = True
        self.exit_monitor = None'/bin/echo "on 0" | /usr/osmc/bin/cec-client -d 1 -s', shell=True)
  1. Additionally I have configured the Power button on my remote to toggle the screensaver - for manual control of the TV.

Above works with the April OSMC release. I remember cec-client was broken some time Q3 2015 (if you refer to cec-client not working as the python import issue). I’ve solved this by explicitely calling cec-client from /usr/osmc/bin/cec-client. See also Cec-client - November update - #8 by amos

Just stumbled upon the same problem even though years later. I got it to work by altering the XML file stored in home/osmc/.kodi/userdata/peripheral_data/.
Change <setting id="standby_devices" value="231" /> to <setting id="standby_devices" value="36037" /> and then reboot. 36037 seems to be the ID of the TV. After this change i can call the built in function ‘CECStandby’ and the TV turns off.

Found the solution here: CEC Control via JSON API


What if that folder is empty?