I'm all new to Node Red and are stuck. I have Homeassistant installed in a Docker on Ubuntu. Have Installed the Node Red Integration. Integration works well. I have a simple flow in Node Red with an exec node that runs a Python script when a sensor changes. Flow is triggered as it should but it fails on the exec node. The Node Red node runs the following script and argument:
python3 ~/home/joern/Documents/flysjekk.py NAX9T
but it fails with the following error messages:
python3: can't open file '/root/home/joern/Documents/flysjekk.py': [Errno 2] No such file or directory
Properties on the flysjekk.py file is as following:
/home/joern/Documents
Running the above command from the terminal works like a charm.
I have very little experience with ubuntu so I hope someone are able and willing to help me through this.
Thanks in advance.
The normal file system is not accessible from a Docker container unless you specifically allow access to the areas you want. That is one of the points of running in a container, the rest of the system is not accessible from the container and therefore cannot be messed up by it. If you do need access from within the container then the first question to ask is why are you running in Docker? Unless you have a good reason it is generally simpler not to run in Docker.
What did you enter in the exec node? If you mean that you entered it correctly (that is without the ~) then I don't believe that you get exactly the same error. If you do then show us the config of the exec node and the error.
You have told it to append msg.payload to the command, I suspect that is not what you want. If you don't want that box ticked then clear it. I don't think it will make any difference though. If not then we are back to the fact that it is running in Docker (if node-red is in fact running in docker).
The fact that ~ resolved to /root tells that Node-RED is running as the root user. This won't work unless you have specifically created a directory /home/joern/Documents inside the Docker conftainer and added the Python script there. Even if it was, it's not guaranteed the Docker container running Node-RED includes a Python runtime.
Id also suggest asking from the Home Assistant community as this is not really a Node-RED issue but related to it being run inside a container. And in this case the container is set up and started by the Node-RED plugin or the HA runtime.
ok. I got a step further. I also have these python script in another directory under the homeassistant directory. It looks like Node Red is able to finde the python scripts. I changed he path in the exec node to the following:
python3 /config/python_scripts/flysjekk.py NAX9T
That gives me this error:
Traceback (most recent call last): File "/config/flysjekk.py", line 1, in import flightawareparser File "/config/flightawareparser.py", line 6, in import requestsModuleNotFoundError: No module named 'requests'
OK. Folks. I abandoned this and chose another path. Just rant in to many problems.
I solved this with a command line sensor in Home assistant.
Thanks a lot for your input. Even if it didn't solve my problem I appreciate your efforts. Hope I can come back another time with Node Red related problems.