Execute Remote Script with SSH trough keymaps.xml

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

[b]On the RPi2.

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

In the keymap.xml i got this directions:

<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

ssh osmc@192.168.1.13 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.

remote.xml on HTCP <yellow>RunScript(ssh osmc@192.168.1.13 python "/home/osmc/hyperion/colourswitch.py")</yellow> <yellow>ssh osmc@192.168.1.13 python "/home/osmc/hyperion/colourswitch.py"</yellow> <yellow>RunScript(ssh osmc@192.168.1.13 "python /home/osmc/hyperion/colourswitch.py")</yellow> <yellow>RunScript(ssh osmc@192.168.1.13 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 :D. Im trying this 6 hours straight now

I was also struggling with a python script and get it to execute a command on linux…in the end i realized all i needed was a simple sudo.

In my keymap.xml i had, just like you, :

RunScript(/home/osmc/vnc/vncon.py)

which is basically the same thing…but in my .py script i had:

import os
os.system('sudo /etc/init.d/vncboot gui')

I dont know what you have in your py script…but maybe a sudo will make it work.

it is working, but it needs to work with ssh

i also tried
ssh osmc@192.168.1.13 python < /home/iiidefconiii/colourswitch.py

this works but not from the keymaps.xml

RunScript(ssh osmc@192.168.1.13 python < /home/iiidefconiii/colourswitch.py)

strange, or am i missing something

Why don’t you have the key XML to run a py script instead of the command, and inside that py script do what I do. Import the OS library and put the command that works under it like I did

import os
os.system('ssh osmc@192.168.1.13 python < /home/iiidefconiii/colourswitch.py')

Edit: wait. Now I see what you mean. Ok find the equivalent library to load under htcp to be able to run ssh from inside the python script. Maybe htcp has the same libraries, so give import os a try. It should work like this.

Amazing Sanbird! This worked, just perfect. Thanks im boxing against this for so long haha.!

1 Like

nice :slight_smile: damn sudo. I also lost a few hours on this hehehe

in remote.xml i did:
RunScript(“/home/iiidefconiii/hyperion/roff.py”)
RunScript(“/home/iiidefconiii/hyperion/rcolourswitch.py”)
RunScript(“/home/iiidefconiii/hyperion/rswitch.py”)

and the contents
import os
os.system(‘ssh osmc@192.168.1.13 python /home/osmc/hyperion/colourswitch.py’)

oh didnt even need to do that sudo thing…well keep it in mind at least…maybe you need to execute a script or a command, that needs elevated privileges to work

1 Like

yeah, you are right, I’ll have a try !! coque sony xperia Z5 Premium pas cher coque xperia Z5 Premium