Hey, I’ve been trying to find a way to do multi-line shell commands in Hassio, using SSH (I had these working with AIO back in the day). And needed some help. I’m trying to get a shell command to turn my tv on and off, but am struggling. I think I’m missing something small because when I do these in the terminal individually, it works fine.
My shell_command.yaml (although I had the SSH portion as part of the .sh before, just trying to troubleshoot) is
neither seem to work. nor did when I put the ssh as part of the sh file. I’ve done chmod on it.
The turn_tv_on.sh errors out at the echo portion saying cec-client isn’t found, and turn_tv_off.sh just stops at bin/bash, but doesn’t send the other command.
but I can’t seem to get it all on one line. I can’t figure out the script thing to wait for the bash subshell (I’m really unfamiliar with the terminology here) and then execute the 2nd part. Do you have any ideas on that?
Shell_command runs in the homeassistant container already. There is no need to ssh to the resinos host then docker exec back into the homeassistant container.
Can you please explain? I’ve tried almost everything and still can’t get that’s echo cec-client command to work. That command only seems to work when I ssh into the docker root and use bash. Have you been able to do it without SSH’ing into docker root and then going to bash?
Running a shell_command in Home Assistant is equivalent to you manually running the command after you docker exec into the homeassistant container.
I don’t use HDMI CEC personally, but I’m curious why you’re using shell_command instead of the native HDMI CEC component (https://www.home-assistant.io/components/hdmi_cec/). It appears as though the commands you’re attempting to run are already supported natively by the component.
Thanks. I did try it before, but it errored saying the echo command isn’t found. It’s because the HDMI_cec component stopped working for me and a lot of people on hassio back around 0.60, and it looks like no one found a solution yet (it can read the state, but not control it). I mostly want it to turn my TV off when I leave my place, and I don’t want to buy a 2nd pi or harmony hub to do it (what a lot of people on this forum said they did after giving up), if it is possible to fix it with code. Figure I’d try to give people a solution to that problem too.