i’m trying to run a python script from within HASS (hassbian) using the command line switch.
the script runs ok from the terminal when i am running as the homeassistant user in an activated virtual environment. I have given 777 perms, and changed the owner and group to homeassistant.
I believe the command line switch will create a new shell, which will not have the virtual environment activated. If the script needs the virtual environment activated, then the command needs to activate it within the command line.
@gpbenton thanks for the info - i had already played around with adding the activation command in the command line switch, which hadn’t worked. A little knowledge is never quite enough…
@petro I had tried using the python script component, but it also didn’t work. i wondered if that was because it is sandboxed/limited…
i have solved the problem by adding the path to python (in the venv) to the start of the script, and at the start of the hass command. the hass command now looks like this:
I assumed you were trying to use the python_script component because you placed the file into the correct location as if you were trying to use the component.
It is limited. Ignore my advice if you aren’t trying to use that component.