Hi guys,
I’m trying to run a simple Python script via Hass.io - I can see there’s tons of topics on this already, and I’ve gone through probably all of them to try and get this to work, but I can’t.
The common solution seems to be setting up a command line switch and having the script as either the command_on or command_off - this part is fine, and when I turn on the switch it seems to pass the right message across, but then I get a ‘command failed’ error. This is super frustrating because it’s an incredibly unhelpful error, and the same script works perfectly if I SSH into the instance (using the SSH add-on) and run it.
I’m guessing it might be a user issue since when I SSH into the instance I’m root, but I’m not sure what Hass.io runs as when these scripts are being called - how would I address this and make sure Hass.io has enough permissions to run the script? Is it even a permissions issue?
This is the error I get:
Command failed: python3 /config/tv.py
The script itself is:
import samsungctl
import time
import subprocess
config = {
“name”: “samsungctl”,
“description”: “PC”,
“id”: “25”,
“host”: “192.168.1.140”,
“port”: 55000,
“method”: “legacy”,
“timeout”: 0,
}
subprocess.check_output(‘docker exec -t homeassistant /bin/bash -c “echo “as” | cec-client -s”’, shell=True)
time.sleep(2.0)
with samsungctl.Remote(config) as remote:
remote.control(“KEY_HDMI”)
time.sleep(2.0)
remote.control(“KEY_HDMI”)
I’d really appreciate any help on this as I’ve been tearing my hair out for the last couple of days - this is something that really should be pretty simple to do and I’m sure there’s a way to do it so please help!
Thanks,
Aazim.