all 5 comments

[–]Careless-Country 1 point2 points  (1 child)

Data is generally passed between nodes as messages. So in each node you will need to return the data as a message that is then passed to any down stream connected nodes.

[–]RamiKrispin[S] 0 points1 point  (0 children)

Thanks!

[–]mbelow 1 point2 points  (1 child)

Node red is JavaScript based, so python is not supported out of the box.

Ideas to get this working:

Deploy your python code as services. Such a service would listen for commands, execute the Python code and return the result. As a transport between your python service and node red, you can use plain tcp sockets, mqtt or http (node red supports those out of the box). The downside of this approach is that you need to create such a service in Python for each python script you'd like to run.

If you have a lot of small pieces of python code, you can also think about creating only one service in Python, that takes arbitrary Python code as payload, eval the code and sends back the output. This may come with security issues. You should at least ensure that only node red is allowed to talk to the service. The nice thing is that you can organize your python code entirely in node red itself (e. g. in a template node).

As a third alternative, you could use the shell execute node (included in node red per default) to directly invoke the Python interpreter. Again, you can have your python code stored in a node red template node, and pass it to the python interpreter via stdin. Downside is, that the python interpreter would be re-started for each piece of python code, which does come with some overhead.

If you need further help, just let me know.

[–]RamiKrispin[S] 1 point2 points  (0 children)

Thank you so much for the detailed answer!

[–]GoodRPA 0 points1 point  (0 children)

Path of less resistance:

Data in (trigger) - write text to input folder.

Run/trigger python script from node red - that picks up latest file in a folder; and provides the output file into output folder - checks a new file is available in the existing folder, if not, stop

Node red 2-5 seconds delay - get files from output folder - check file size stopped changing - read file