Execute Remote Script with SSH trough keymaps.xml
#1
Hi,

I have a Logitech Harmony Ultimate Remote.
I have a decent HTCP desktop with kodibuntu installed on it. (doesnt have a SPI, GPIO to control my led so
I also have a RPi2 (has OSMC and hyperion application)

Facts:
* Logitech Harmony doesnt work with Kodi (yet) soon supports ip remote)
* I can only connect to one IR device, otherwise both devices will pick up the signal
* I wont use CEC, cause then i can only switch the light when RPi2 is on the tv screen with a active signal

So i tought, i would use HTCP for running kodibuntu and use the RPi2 as hyperion server, included in OSMC).

On the RPi2.

Im using some scripts that are loaded with buttons on my Harmony Remote to a IR receiver


In the keymap.xml i got this directions:
Code:
<red>RunScript("/home/osmc/hyperion/off.py")</red>
<yellow>RunScript("/home/osmc/hyperion/colourswitch.py")</yellow>
<blue>RunScript("/home/osmc/hyperion/switch.py")</blue>

This always works locally.

After creating RSA tokens on the HTCP i can ssh run this following command from the HTCP to the RPi2
Code:
ssh [email protected] python "/home/osmc/hyperion/colourswitch.py"
and the lights on the rpi will change. So far So good.

BUT:
workflow now is
Harmony Remote yellow button -> IR device -> HTCP Desktop keymaps.xml receives [yellow] -> ssh to raspberry -> run command python "/home/osmc/hyperion/colourswitch.py" -> hyperion changes the colour of the leds connection to spi (gpio pins)

On the HTCP i also made an remote.xml with almost the same script as in remote.xml on the raspberry but including the ssh connection i tried this followings but none of them push the code true ssh and activate the script. It looks like the keymap.xml receives the button, well it should, but never run the script remote.

Code:
remote.xml on HTCP
<yellow>RunScript(ssh [email protected] python "/home/osmc/hyperion/colourswitch.py")</yellow>
<yellow>ssh [email protected] python "/home/osmc/hyperion/colourswitch.py"</yellow>
<yellow>RunScript(ssh [email protected] "python /home/osmc/hyperion/colourswitch.py")</yellow>
<yellow>RunScript(ssh [email protected] python "/home/osmc/hyperion/colourswitch.py")</yellow>

Does anyone have a clue why its not working? Sorry for my bad english if i need to re-explain myself please let me know, i barely understand this myself Big Grin. Im trying this 6 hours straight now
Reply
#2
Put your command in to a python script and then run that with RunScript via the keymap.xml
Reply
#3
(2015-09-07, 11:17)teeedubb Wrote: Put your command in to a python script and then run that with RunScript via the keymap.xml

I dont get it, i have my command in a python script and it is in keymap.xml
Reply
#4
(2015-09-07, 15:47)IIIdefconIII Wrote:
(2015-09-07, 11:17)teeedubb Wrote: Put your command in to a python script and then run that with RunScript via the keymap.xml

I dont get it, i have my command in a python script and it is in keymap.xml

No you do not.
"ssh [email protected]" is not python,
you need to wrap that ssh line in a python script, eg with subprocess.popen
Reply
#5
(2015-09-07, 15:58)asavah Wrote:
(2015-09-07, 15:47)IIIdefconIII Wrote:
(2015-09-07, 11:17)teeedubb Wrote: Put your command in to a python script and then run that with RunScript via the keymap.xml

I dont get it, i have my command in a python script and it is in keymap.xml

No you do not.
"ssh [email protected]" is not python,
you need to wrap that ssh line in a python script, eg with subprocess.popen

mmm, could you make an example for me what i should try, im not very linux friendly, found this out so far
Reply
#6
Something like:

import os
os.system('ssh [email protected] python "/home/osmc/hyperion/colourswitch.py"')
Reply
#7
It works pefectly, only import os is securty risk right? what if read
Reply
#8
You can also use subprocess.popen, but thats a security risk too..
Reply
#9
(2015-09-08, 08:38)teeedubb Wrote: You can also use subprocess.popen, but thats a security risk too..

haha which one is safer its behind a router in lan i disabled upnp in router
Reply

Logout Mark Read Team Forum Stats Members Help
Execute Remote Script with SSH trough keymaps.xml0