0

I have written a home automation script for controlling lights, music on kodi, and my TV. I have everything working except for turning off the TV. I have mapped my keyboard.xml file within kodi to recognize the "CECToggleState", and this works fine, but I would like to trigger this inside a python script.

In the past, one could import the xbmc module, then use the command "xbmc.executebuiltin()" to run built in kodi functions, like "CECToggleState". The xbmc module has been replaced by the kodi module. I have seen examples where it is suggested that "kodi.executebuiltin()" can be used, but the kodi module does not appear to actually support "executebuiltin". When I try running this command in python, I get an error that reads:

"AttributeError: 'module' object has no attribute 'executebuiltin'"

Can anyone confirm that this is true, or offer what has replaced this command? Or, does anyone know of a good alternative to get the same effect -- ie, send "TV off" command programatically through HDMI CEC?

2 Answers2

1
import xbmc
xbmc.executebuiltin('XBMC.CECToggleState()')

This works in my python addon in Isengard. To turn off TV use:

xbmc.executebuiltin('XBMC.CECStandby()')

or to turn on:

xbmc.executebuiltin('XBMC.CECActivateSource()')
Michael
  • 101
  • 1
  • 10
0

You have to write xbmc.executebuitin("XBMC.CECToggleState()"), not kodi.executebuitin("XBMC.CECToggleState()"), and please upgrade your kodi from isengard to a stable version (i.e, Kyrpton).

Pyves
  • 6,333
  • 7
  • 41
  • 59
Rachit kapadia
  • 705
  • 7
  • 18