CEC command for TV on/off
#1
Hi,

I‘m using FLIRC-USB to control Kodi, everything runs smoothly. I programmed the Power button of my remote to stop playing, working well. Now I‘d like to additionally trigger the power of my Samsung TV via CEC, unfortunately doesn‘t work. That‘s how I ammended the keymap.xml (F8 is mapped to the Power button of my remote):

<F8>Stop</F8> <!-- Power button -->
<F8>CECToggleState</F8> <!-- Power button -->

Does anyone know, what’s missing? Any hint highly appreciated!

harry
Reply
#2
Been a while since I did this, see the link in my sig for some notes/instructions.
Need help programming a Streamzap remote?
Reply
#3
(2019-05-19, 23:05)graysky Wrote: Been a while since I did this, see the link in my sig for some notes/instructions.

Thanks, but this refers only to using double commands for one key, right? Maybe I was not clear, but my main issue is to get the CEC command working at all, even if it’s the only command on this key.
Reply
#4
I think the double-commands are allow but you need to add the action in the appropriate section... in other words, home screen action vs in video action.  Again, it's been a while but that's my memory.
Need help programming a Streamzap remote?
Reply
#5
Keymaps are loaded in the following order:

1) the default ones that ship with Kodi (and shouldn't be edited).
2) any defined in your main profile.
3) any defined in any secondary profile you may be using.

Within a folder, the keymaps are loaded in alphabetical order, and within a given keymap the global commands are loaded first, and then specific window ones afterwards.

This is set-up so that the user keymaps will overwrite any duplicated actions from the default ones, and that the global ones act as a "safety net" beneath any defined within the specific window sections.

So in the case above I would expect you will only get the CEC command assigned, as that will overwrite the stop assignment immediately before it.

What you can do is trigger a script running from the keypress and move the commands there, or there is also a callback addon which might be worth looking at as well.
|Banned add-ons (wiki)|Forum rules (wiki)|VPN policy (wiki)|First time user (wiki)|FAQs (wiki) Troubleshooting (wiki)|Add-ons (wiki)|Free content (wiki)|Debug Log (wiki)|

Kodi Blog Posts
Reply
#6
Hi,

Those are really interesting insights in the logic of keymap relations. When I get it right, two commands shouldn’t be a problem here, as they are both independent of any window.

But obviously I was still not able to articulate my real issue properly: I‘m not (yet) struggling with triggering two commands at the same time. My issue is that the CEC command just doesn‘t work, even if it‘s the only command mapped to the power button:

<F8>CECToggleState</F8> <!-- Power button -->

Does anybody know, which command allows me to switch on and off my TV from RPi via CEC?

harry

PS: Also tried some shell commands:
echo "on 0" | cec-client -s -d 0   -> works to switch on TV!
echo "standby 0" | cec-client -s -d 0    -> doesn't work (although TV-Menu -> Settings -> Anynet+ (HDMI-CEC) -> Settings -> Auto Turn Off: Yes)
Reply
#7
Nodody knows, how I get CECToggleState running?
Reply
#8
If you make a shell script for on and another for off you can map a key to them.  See my sig again wherein I do this with an audio source toggle via a script as I recall.
Need help programming a Streamzap remote?
Reply
#9
I would, if I knew a working script for switching off my TV ...
Reply
#10
Have you looked at the ‘Turn Off’ Screensaver? I don’t use it myself, but it might do what you need?

Personally, I’ve got Kodi CEC settings configured to ‘Put devices in standby mode when activating the screensaver’, and my power button mapped as:

~/.kodi/userdata/keymaps/gen.xml
<keymap><global><keyboard><key id="254">xbmc.runscript(/home/osmc/.kodi/userdata/shutdown.py)</key></keyboard></global></keymap>

~/.kodi/userdata/shutdown.py
import xbmc

xbmc.executebuiltin('Action(stop)')
xbmc.executebuiltin('ActivateWindow(Home)')
xbmc.executebuiltin('ActivateScreensaver')
Reply
#11
Also, at the risk of unintentionally insulting you... you have got CEC enabled on the TV, yeah?

Edit: Ignore above, just spotted that you’ve already managed to turn the TV on via CEC!
Reply

Logout Mark Read Team Forum Stats Members Help
CEC command for TV on/off0