I want to execute a custom script when [Blue] key is pressed from the remote app (IOS:Kodi Remote).
It can be done by clicking settings->…more->…->execute a specific action->blue
This is what I did.
I changed the contents of remote.xml in /home/osmc/.kodi/userdata/remote.xml to
I used to have a similar setup - I had the power button turn on/off an LED on the front of my enclosure and enable/disable the HDMI output to make it look like it was switching on/off to keep the wife happy!
The only differences from what I was doing are:
I had the script in a folder in the userdata folder to keep it out of harms way (/home/osmc/.kodi/userdata/pyscripts/pwron.py)
I used python scripts - not sure if this would be a problem?
I didn’t use quotes in remote.xml (RunScript(/home/osmc/.kodi/userdata/pyscript/pwron.py))
Also - make sure the script is executable!
I think the quotes in remote.xml would be the first thing to look at.
Thanks @salawinder.
It didn’t work though. I tried python code before. import subprocess subprocess.call(['/home/osmc/toggleHyperion.sh'])
this python script will execute the same sh script.
The python script and the sh script are executing fine. Both had executable privilege. Checked the quotes.
So you are saying the remote.xml Should work. Did it work with the remote app (IOS app) for you? Do you have the same <HTCP> tag?
I’ve never seen the tags either - mine was: <keymap> <global> <remote> <power>RunScript(/home/osmc/.kodi/userdata/pyscript/pwroff.py)</power> </remote> </global> </keymap>
I also never used the iOS app - I had an MCE remote.
My suggestion would be to use remote.xml, get rid of the tags, and make a script that does something simple. if it works, then you can work on getting the code in your final script to work, knowing that the script IS being called.
@ActionA I don’t know were I got it from. But it’s one I tried among others. @salawinder Thanks Again. I have tried this before but now I tried without quotes. No luck. <keymap> <global> <remote> <blue>RunScript(/home/osmc/Hyperion/toggleHyperion.py)</blue> </remote> </global> </keymap>
Now I am starting to think that this only works with the remote and not the remote app
Try changing this line to something simple like<blue>Down</blue>
now test if the blue button performs a down action. If it does proceed with figuring out the correct context for your script, if it doesn’t work then you need to figure out what Kodi is seeing when the button is pressed. If you put Kodi in debug then tail the log you should see what the key is sending
I Tried tailing /home/osmc/.kodi/temp/kodi.log with ‘Enable event logging’, ‘Enable notification event logging’, ‘Enable debug logging’ and ‘Enable component-specific logging’ checked on. but nothing. Nothing is seen when I press the actual down button(the selection moves down though).
This means that your television does not pass the blue button by CEC. This is not uncommon and expecting that every button on the TV’s remote is passed by CEC is a flawed assumption. Find another button that the tv actually sends to Kodi if possible.
From the tcpdump, I figured that the app is just sending JSONRPC Calls
so I currently have <blue>Down</blue>
curl -v -H "Accept: application/json" -H "Content-type: application/json" -X POST -d '{"method":"Input.Down","id":416382513,"jsonrpc":"2.0","params":{}}' http://127.0.0.1:80/jsonrpc
This is moving the selection down but
curl -v -H "Accept: application/json" -H "Content-type: application/json" -X POST -d '{"method":"Input.ExecuteAction","id":-450699119,"jsonrpc":"2.0","params":{"action":"blue"}}' http://127.0.0.1:80/jsonrpc
this is not triggering the keymap action for Blue, which is also down in this case.