Missing CEC Builtins (CECToggleState, CECActivateSource, CECStandby)

In OSMC 2016.06-2 (Kodi 16.1) on a RPi 2 the CEC builtins (CECToggleState, CECActivateSource, CECStandby) seem unavailable.

Using /home/osmc/.kodi/userdata/keymaps/remote.xml like this

<?xml version="1.0" encoding="utf-8"?> <keymap> <global> <remote> <red>CECToggleState</red> </remote> </global> </keymap>

… produces the following error in kodi.log:

ERROR: Keymapping error: no such action 'cectogglestate' defined

There has been a time when registrations for CEC builtins were missing upstream (see pull request #9535).

I could provide a full log if that would help or file an issue on GitHub. Ideas?

Are you sure that this should work ? Are you sure you’re not confusing button actions with built-in functions ? CECToggleState is a built-in function that you can call using kodi-send, but I don’t think you can map a remote button directly to it using remote.xml as its a built-in function not an action.

Refer to the Kodi keymap page:


4.2 Remotes
An up to date list of the available actions can be found in the source code of Kodi in ButtonTranslator.cpp where the TranslateRemoteString() function does the work.
Note: Some remotes are actually seem as "keyboards". Those will need to use the <keyboard> tag instead.

Looking at xbmc/ButtonTranslator.cpp at master · xbmc/xbmc · GitHub I see no mention of any CEC commands…

So my conclusion is what you are trying to do cannot work.

1 Like

Yes, according to the documentation it should work.

Quoting http://kodi.wiki/view/keymap#Commands:

6 Commands

In addition to the following actions, you can also use Built-in scripting in Kodi.

Further down on that page under 6.2 Functions the builtins CECActivateSource, CECStandby, CECToggleState are listed explicitly.

Here is a report confirming the behavior.

In addition, using kodi-send --action=CECToggleState produces the same error:

09:42:37 57279.937500 T:1956897712 ERROR: Keymapping error: no such action 'cectogglestate' defined

Looking more closely into mainline git, it seems that the fix to correctly register the CEC builtins did not make it into Jarvis (16.1).

What I’m trying to accomplish here is to correct a nasty CEC interaction between a Samsung TV (UE40F6470) and an Onkyo AV receiver (HT-R558). When the TV is put to standby by its IR remote, it (correctly) switches the AVR to standby via CEC, but almost precisely two hours later, the AVR turns on without user interaction. The only reliable way I’ve found to avoid this is switching the AVR to standby before switching the TV to standby.

Since Kodi builtins did not work, I’ve tried to resolve this using cec-client, but this takes CEC control away from Kodi, which, when turning TV and AVR back on, makes the AVR switch to the TV source instead of Kodi. To regain CEC control in Kodi, I’ve tried to restart Kodi immediately after running cec-client, but this makes TV and AV receiver turn on immediately.

This is the script I’ve used:


# Set to standby: first (5) audio, then (0) TV
echo -e "standby 5\nstandby 0\nquit" | cec-client > "${TMPDIR:-/var/tmp}/standby.log"

# Kodi has now lost CEC control

# Restart Kodi to regain CEC control
# DOES NOT WORK: Makes TV and Audio switch on immediately.
sudo systemctl restart mediacenter

This must have been a bug introduced in Jarvis then, because the CEC commands were working via kodi-send in Isengard. :confused: There has been discussion on the forum during Isengard of how to do this and it was working for people then.

In that case it’s an upstream Kodi bug - your best bet might be to report the problem directly to the Kodi devs on forum.kodi.tv or on their bugtracker.

Yes this will not work properly.

Your TV will get confused because it will see cec-client as a different device on the CEC bus than Kodi, once you start sending commands from cec-client the TV will no longer recognise commands from Kodi. So unfortunately getting the CEC actions in Kodi fixed is the only reasonable solution.

1 Like

I agree.

If it were just about the missing builtins, no upstream bug report would be necessary since the fix was already merged into git master.

What’s more annoying in my case is that additional tests proved the envisioned CEC solution unviable: The only way to prevent the AVR from irregularly waking up from standby was to put it to standby via IR remote before switching the TV to standby. Trying the same via CEC messages simply did not work.

As I have found a solution to the underlying problem, I’d like to document it here in case people google this:

Samsung Series F TV (UE40F6470) wakes AV Receiver from standby unexpectedly via HDMI-CEC [Solution]


Problem confirmed with Samsung series F firmware 2116 (though previous releases seem affected, too):

  • When menu option Broadcasting - Aerial is set to Satellite, the menu section Broadcasting - Auto Tuning contains a Wake-up Timer entry, which is set to 2 hours by default.
  • Even with Standby Auto Tuning set to Off, when the Wake-up Timer fires, the TV will wake up a CEC-connected AV receiver.
  • The Wake-up Timer cannot be disabled completely (only set to different absolute and relative times).


  • Switch Broadcasting - Aerial to Air (terrestrial), then the auto-tuning section will not feature a timer and CEC wake-ups will not occur.