Handle RC Input
#1
I am writing a program addon to control the volume on my TV through IP. I want to have it run all the time so it doesn't have to re-connect every time the volume buttons are pressed. Is there some kind of callback system where I can map a key on the remote to a function in my script? Like "onVolumeUp()"? Or set a key mapping to a function in a script?
Reply
#2
I don't know if you can map a remote key to a function in your script. What I know you can do is map a key to a built in function. From there you could try the RunScript,RunPlugin,RunAddon,Container.Update or Container.Refresh built in functions and pass some parameters to your script such that it executes the specific function you want.
Reply
#3
Take a look at the onAction function. You can put something in there to capture a keystroke or certain defined actions. I use it with one of my addons to close the window if either previous menu or back are pressed.
Code:
def onAction( self, action ):
        #captures user input and acts as needed
        lw.log( ['running onAction from SpeedFanInfoWindow class'] )
        if action == ACTION_PREVIOUS_MENU or action == ACTION_BACK:
            #if the user hits back or exit, close the window
            lw.log( ['user initiated previous menu or back'] )
            global __windowopen__
            #set this to false so the worker thread knows the window is being closed
            __windowopen__ = False
            lw.log( ['set windowopen to false'] )
            #tell the window to close
            lw.log( ['tell the window to close'] )
            self.close()

Here's a list of all the action IDs:

http://kodi.wiki/view/Action_IDs
Reply
#4
Thanks but I think you need a window for that and my script does not have a window.

Reconnecting every time seems to work ok. I am posting what I have so far. I am not new to programming but am new to Python, Kodi plugin development, and smart tv integration. So any input would be welcome.

The script is meant to be used on a system connected to an LG Smart TV. I am using a RPI3 with OpenElec and Kodi as a PVR front end. I have a MCE remote. I mapped the volume keys to run this script to control the volume on the TV and not in Kodi.

Code:
<key id="208">runaddon(script.lg_remote, VU)</key>
<key id="209">runaddon(script.lg_remote, VD)</key>
<key id="192">runaddon(script.lg_remote, M)</key>

To use you first have to go to the plugin setup and click the "Click Here to Display Key on TV" button then enter the code shown on the tv.

Download here.

Or view the code here: http://pastebin.com/1hcAupmZ
Reply

Logout Mark Read Team Forum Stats Members Help
Handle RC Input0