Error with command line binary sensor, executing python script

Hi, hoping somebody can help me with this, I’m running HA 0.37 on Docker and I’m having trouble with a command line binary sensor set to execute a python script in a virtual environment. I’ve tried setting up the command referencing both the absolute path as well as the Docker path to the virtual environment and script, and tried with sudo and still get error:

17-01-31 09:33:46 ERROR (Thread-3) [homeassistant.components.sensor.command_line] Command failed: sudo /home/david/home-assistant/hass-config/office365_venv/bin/python3 /home/david/home-assistant/hass-config/

The above command is using absolute path but I’ve also tried /config/… where config is the mapped Docker path, as well as just office365_venv/bin/python3

I’m guessing this could be a permission issue or something, but I’ve also chmod 777 on both the venv and the script. Does anybody have any ideas?


When a script is executed from HA it’s done as the HA User. (In my case, since I did an AIO install from before December 2016, mine is ‘hass’. Yours may be different depending on your install.) You need to add the HA User to your sudoers list.

There’s a good (albeit long) thread about this here:

If you don’t NEED sudo to run whatever your script is and were just doing this to test, then all you have to do is to make the HA User the owner of the script file. Then it should run fine.