Can't figure out how to send shell commands via ssh

Hi all,

Here’s what I’m trying to accomplish:

  1. Roku goes into “screensaver” mode, which HassIO sees as changing to “idle” state.
  2. An automation (successfully) detects this state change and calls a shell_command
  3. I have a change_HDMI_input.sh that issues a cec-client command via ssh to an RPi that’s connected via HDMI to the TV. This bash script works fine if I manually execute from the CLI of either the RPi or the HassIO instance (which is a VM running in Docker).

In troubleshooting this, I’ve tried a few different things - here’s an overview of what I’ve tried, and the outcome from each attempt:


# these work: 
# /bin/ping -c 3 192.168.2.107 > sshout.txt
# /usr/bin/ssh -V > somefile.txt
# /bin/echo tx 2F:82:40:00 > echo_test.txt

# these return 127 - path error
# /usr/bin/rsh -h > /config/sshout.txt
# /usr/bin/rsh [email protected] hostname
# /usr/bin/ssh -i /config/id_rsa [email protected] /bin/echo "tx 2F:82:40:00" | /usr/osmc/bin/cec-client -s -d 4

# returns 255 - ssh error since adding ' marks (was 127 without)
# /usr/bin/ssh -i /config/id_rsa [email protected] /bin/echo '"tx 2F:82:40:00" | /usr/osmc/bin/cec-client -s -d 4' > cec-client-test.txt
# /usr/bin/ssh -i /config/id_rsa [email protected] ls


What I’m seeing is that any command that has to go over ssh fails in some way (when called from the Automations section of HA; however I can successfully execute any command manually via the CLI.

Note that I’ve got cert-based authentication working, so I think I can eliminate that as a culprit.

Try here Hassio Integration with other entities using SSH