Remote ssh does not start effect

  • Hi all!
    I'm running an ongoing home automation project with two Raspberry Pi's, one has Hyperion installed/connected to it. After a morning's work I figured out how to start an effect using a remote ssh connection from one rPi to another:

    Code
    sshpass -p 'pass' ssh osmc@192.168.1.33 sudo hyperion-remote -p 50 -e \"Knight rider\" -d 6000 > tempoutput.txt 2>&1


    This works, as I can see the effect and read the output in tempoutput.txt. However, I want to start this from within a php script. This is the (same) code:

    PHP
    exec("sshpass -p 'pass' ssh osmc@192.168.1.33 sudo hyperion-remote -p 50 -e \"Knight rider\" -d 6000 > tempoutput.txt 2>&1");


    I can see the same output in tempoutput.txt, which would mean the effect is started, but it doesn't. The lights stay off. I'm asuming that the remote ssh does work since a ping test works fine, but I have no clue what could be the case here.
    Who can help me?

  • What kind of construction would I need to do that? I'm not used to JSON. I have a working script which activates a web stream:

    PHP
    exec('curl -i -X POST -H "Content-Type: application/json" -d \'{"method":"Player.Open","id":44,"jsonrpc":"2.0","params":{"item":{"file":"http://icecast.omroep.nl/radio2-bb-mp3"}}}\' http://192.168.1.33:8080/jsonrpc');


    So I combined this with the JSON RPC found here to come up with this result:

    PHP
    exec('curl -i -X POST -H "Content-Type: application/json" -d \'{"jsonrpc":"2.0","id":1,"method":"Addons.ExecuteAddon","params":{"addonid":"script.hyperion","params":{"command":"effect", "effect":"Snake"}}}\' http://192.168.1.33:8080/jsonrpc');


    I think the syntax is correct, but this doesn't work. Can you point me in the right direction on how to start an effect remotely by using JSON?

  • I couldn't get JSON to work since I really don't know how to send a JSON message via php.
    However, I did find a (not so pretty) solution! Instead of directly executing the effect script, I placed it in a shell script that I uploaded to the remote Pi.

    Bash
    #!/bin/bash
    sudo hyperion-remote -p 50 -e "Knight rider" -d 6000


    The php file now executes the shell script using:

    PHP
    exec("sshpass -p 'pass' ssh osmc@192.168.1.33 sudo ./shellscriptfile");


    And this works! It seems that Hyperion won't start the effect if the command comes from a remote machine - even though it outputs that the effect has started. One disadvantage though: there's a huge delay (multiple seconds) between calling the php script and the effect execution. So if there's a way to pass the command directly to the remote machine using JSON, that would still be an improvement.


    In case anyone's interested: using the mobile app Tasker, Hyperion will now show the Knight Rider effect when somebody calls me on my mobile phone :) Now that I have Tasker and Hyperion working together, imagine the possibilities! Effects for receiving email, change of colour according to my phone's battery life, etc etc.

  • Hopefully we have soon new multi platform apps, the source code will be open and everyone is invited to add more functions to it. This should bring a better handling of automation.
    Also to work better with automation systems in general is on the list (openhab for example).


    But for this we need more devs, more people who want to contribute :)

Jetzt mitmachen!

Sie haben noch kein Benutzerkonto auf unserer Seite? Registrieren Sie sich kostenlos und nehmen Sie an unserer Community teil!