Custom Script on custom remote key[Remote app]

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

<keymap> <global> <HTCP> <blue>RunScript("/home/osmc/toggleHyperion.sh")</blue> </HTCP> </global> </keymap>

I tried changing the HTCP to remote as mentioned in http://blog.nadnerb.co.uk/?p=11
I tried changing remote.xml to keymap.xml as mentioned here https://discourse.osmc.tv/t/execute-remote-script-with-ssh-trough-keymaps-xml/7626
I tried kodi keymap editor addon and it is detecting a keypress (as the timer goes of when the key is pressed) but not able to detect the key.

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 don’t recall ever seeing htcp tags like this. What have you seen that caused you to think they should be necessary?

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

This is what I get when I reload keymaps
16:27:55 140135.203125 T:1958007344 INFO: Loading special://xbmc/system/keymaps/appcommand.xml 16:27:55 140135.203125 T:1958007344 INFO: Loading special://xbmc/system/keymaps/gamepad.xml 16:27:55 140135.218750 T:1958007344 INFO: Loading special://xbmc/system/keymaps/hama_mce.xml 16:27:55 140135.218750 T:1958007344 INFO: Loading special://xbmc/system/keymaps/joystick.Alienware.Dual.Compatible.Controller.xml 16:27:55 140135.218750 T:1958007344 INFO: Loading special://xbmc/system/keymaps/joystick.AppleRemote.xml 16:27:55 140135.234375 T:1958007344 INFO: Loading special://xbmc/system/keymaps/joystick.Harmony.xml 16:27:55 140135.250000 T:1958007344 INFO: Loading special://xbmc/system/keymaps/joystick.Interact.AxisPad.xml 16:27:55 140135.250000 T:1958007344 INFO: Loading special://xbmc/system/keymaps/joystick.Logitech.RumblePad.2.xml 16:27:55 140135.250000 T:1958007344 INFO: Loading special://xbmc/system/keymaps/joystick.Microsoft.Xbox.360.Controller.xml 16:27:55 140135.281250 T:1958007344 INFO: Loading special://xbmc/system/keymaps/joystick.Microsoft.Xbox.Controller.S.xml 16:27:55 140135.296875 T:1958007344 INFO: Loading special://xbmc/system/keymaps/joystick.Nintendo.Wii.U.Pro.Controller.xml 16:27:55 140135.296875 T:1958007344 INFO: Loading special://xbmc/system/keymaps/joystick.Ouya.Controller.xml 16:27:55 140135.312500 T:1958007344 INFO: Loading special://xbmc/system/keymaps/joystick.PS3.Remote.Keyboard.xml 16:27:55 140135.312500 T:1958007344 INFO: Loading special://xbmc/system/keymaps/joystick.PS4.Controller.xml 16:27:55 140135.328125 T:1958007344 INFO: Loading special://xbmc/system/keymaps/joystick.Sony.PLAYSTATION(R)3.Controller.xml 16:27:55 140135.343750 T:1958007344 INFO: Loading special://xbmc/system/keymaps/joystick.WiiRemote.xml 16:27:55 140135.359375 T:1958007344 INFO: Loading special://xbmc/system/keymaps/keyboard.xml 16:27:55 140135.375000 T:1958007344 INFO: Loading special://xbmc/system/keymaps/mouse.xml 16:27:55 140135.390625 T:1958007344 INFO: Loading special://xbmc/system/keymaps/remote.xml 16:27:55 140135.406250 T:1958007344 INFO: Loading special://xbmc/system/keymaps/touchscreen.xml 16:27:55 140135.421875 T:1958007344 INFO: Loading special://masterprofile/keymaps/remote.xml 16:27:55 140135.421875 T:1958007344 INFO: Loading special://profile/keymaps/remote.xml 16:27:55 140135.421875 T:1958007344 INFO: Loading special://xbmc/system/Lircmap.xml 16:27:55 140135.437500 T:1958007344 INFO: * Adding remote mapping for device 'mceusb' 16:27:55 140135.437500 T:1958007344 INFO: * Adding remote mapping for device 'XboxDVDDongle' 16:27:55 140135.437500 T:1958007344 INFO: * Adding remote mapping for device 'Microsoft_Xbox' 16:27:55 140135.437500 T:1958007344 INFO: * Adding remote mapping for device 'PinnacleSysPCTVRemote' 16:27:55 140135.437500 T:1958007344 INFO: * Adding remote mapping for device 'anysee' 16:27:55 140135.437500 T:1958007344 INFO: * Adding remote mapping for device 'iMON-PAD' 16:27:55 140135.437500 T:1958007344 INFO: * Adding remote mapping for device 'Antec_Veris_RM200' 16:27:55 140135.437500 T:1958007344 INFO: * Adding remote mapping for device 'MCE_via_iMON' 16:27:55 140135.437500 T:1958007344 INFO: * Adding remote mapping for device 'TwinHanRemote' 16:27:55 140135.437500 T:1958007344 INFO: * Adding remote mapping for device 'linux-input-layer' 16:27:55 140135.437500 T:1958007344 INFO: * Linking remote mapping for 'linux-input-layer' to 'cx23885_remote' 16:27:55 140135.437500 T:1958007344 INFO: * Adding remote mapping for device 'mediacenter' 16:27:55 140135.437500 T:1958007344 INFO: * Adding remote mapping for device 'devinput' 16:27:55 140135.437500 T:1958007344 DEBUG: CButtonTranslator::Load - no userdata Lircmap.xml found, skipping 16:27:55 140135.546875 T:1770927088 DEBUG: script.module.osmcsetting.updates : - blurp 864 - SettingsCategory.xml

I’ve ordered “MXIII 2.4G Wireless Keyboard Air Mouse Remote For Kodi XBMC Android TV & GBox US” http://www.ebay.com/itm/131494008154?_trksid=p2057872.m2749.l2649&ssPageName=STRK%3AMEBIDX%3AIT

Let’s see how this works.

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

Tried this and not working.

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).

Am I looking in to the wrong log or something?

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.

Debug log should show any keypresses received by Kodi, if it isn’t then I’m not sure what to do. It has always worked for me.

I’m not using the any remote.I’m using the IOS Kodi remote app.
Pressing blue button by settings->...more->...->execute a specific action->blue

If Kodi sees no keypress from the remote, then it’s an “IOS Kodi remote app” issue that should be reported to their developers.

I checked and that is not the case.
I did a Tcpdump in OSMC and found that blue button is received.
This is the http request and response.

`Host: 10.0.1.100:80
Accept-Encoding: gzip, deflate
Content-Type: application/json
Accept-Language: en-gb
Content-Length: 91
Accept: /
Connection: keep-alive
User-Agent: DSJSONRPC/1.0

{“method”:“Input.ExecuteAction”,“id”:-450699119,“jsonrpc”:“2.0”,“params”:{“action”:“blue”}}’

Resopnse from OSMC 'HTTP/1.1 200 OK
Connection: Keep-Alive
Content-Type: application/json
Content-Length: 47
Cache-Control: private, max-age=0, no-cache
Accept-Ranges: none
Date: Mon, 04 Apr 2016 00:03:48 GMT

{“id”:-450699119,“jsonrpc”:“2.0”,“result”:“OK”}`

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.