Hi, im trying to get a shell command to run which is hosten on HASSIO with HASSIO.
I tried several different things that i found on this forum… none of them work.
The command itself works perfectly fine if i SSH into my HASSIO manually.
Does HASSIO use a different user than root on PI3?
set_alexa: ‘ssh -i /config/.ssh/id_rsa root@HASSIO /share/alexa_remote_control.sh -d Wohnzimmer -e vol:10’
set_alexa: ‘/share/alexa_remote_control.sh -d Wohnzimmer -e vol:10’
set_alexa: /share/alexa_remote_control.sh -d Wohnzimmer -e vol:10
The errors i get range from Code:1 to Code:255.
Do i really need to add the SSH command if i want to execute the shell script on the same machine?
petro
(Petro)
March 30, 2018, 11:43am
2
I’m pretty sure that command will not work even if you had SSH. Hassio is limited with cli.
Do you mean from HASSIO itself?
When i manually SSH into my rpi and run this command it works fine
petro
(Petro)
March 30, 2018, 11:54am
4
If that’s the case, why are you trying to use ssh in your shell command? You are local to the CLI, you shouldn’t have to ssh into it.
Yes… i know… but it doesnt work… how can i do it without SSH into my CLI?
set_alexa: '/share/alexa_remote_control.sh -d Wohnzimmer -e vol:10’
would usually execute it directly, right?
Do you know if maybe hassio is using a different user than root?
petro
(Petro)
March 30, 2018, 12:17pm
6
I don’t remember honestly. It’s been a while since I snooped. I think you just need to cd into config/share, then call the file. You may want to search for shell_commands in the hassio area of the forum instead of configuration.
A quick google search turned up this thread which sounds familiar to what you are running into:
I can do whatever i want i can not bring Hassio to run my command. I tried lot of things like setting chown to root or root:root set commands in script files or direct into hassio
shell_command:
server_oben_runterfahren: ‘bash /config/bin/shutdown_server.sh’
server_oben_runterfahren_sudo: ‘sudo bash /config/bin/shutdown_server.sh’
server_oben_runterfahren_direkt: ‘ssh -i /data/.ssh/id_rsa -o StrictHostKeyChecking=no [email protected] “sudo shutdown -h now” > someFile.txt’
write_date: ‘date…
ok was able to narrow it down via adding the command
"2> /config/error.log"
to the end of the shell command.
As always…once you figure one thing out, several new problems come up…
It turns out that one of the required tool (jq - JSON Parser) cannot be found from the shell_command line.
However, it works perfectly fine when logging in to the terminal manually via putty… any idea why that would be?
petro
(Petro)
April 2, 2018, 11:25am
8
is jq used by the sh file?
Tinkerer
(aka DubhAd on GitHub)
April 2, 2018, 12:14pm
9
However, when you SSH to your Pi, that’s a different docker container than the one that runs HomeAssistant. That’s why you’re having these problems.
petro
(Petro)
April 2, 2018, 1:37pm
10
I was wondering if that was the case. Is that a different docker because the SSH component is an “ADD-ON” to hass.io ?
Tinkerer
(aka DubhAd on GitHub)
April 2, 2018, 4:02pm
11
Yes. Each add-on is a separate container. Items like /config
are shared to those containers (I’m not sure what the entire list is, I don’t actually use Hass.io ).
What’s your script? Are you using full paths for commands?
You can see the final working version here: Better Alexa Multiroom Volume Control & Alarm Scraping
Turns out running a script from within a very simple script works pretty good as opposed to be running the script just by itself…