How to trigger a node-red flow from shell script process or from systemctl service

hello everyone,

I would like to know if is possible trigger a node-red flow from a shell script process or from a systemctl service when the server is started up. Could you help me? Thank you in advance

Hi @Jasper

You could create a flow that listened for an incoming HTTP Request, and then use curl in your shell script to trigger it. Similarly, you could use the TCP Node and netcat. Lots of different options - depends which you think suits your needs.

Or simple sledgehammer techniques like watching a log file for text indicating something of interest is happening.
And there is always MQTT of course, you could publish to it from the script.

Thank you all for your answers.

What I want to do is have a node-red flow subscribed to a specific MQTT topic to keep track and control based on the information received from that topic. For it, the node-red flow has to instantiated by a shell script process or by a systemctl service when starting the server where it is stayed

Can you explain what you mean by that? Node red flows are running all the time that node red is running, waiting for messages or events. If you configure an MQTT node subscribed to a topic then it will generate messages whenever MQTT gives it data. There is no need to instantiate the flow.

I intend to have a flow that receives information from several sensors and that registry that information on a data base as a history without the need for a user to run a dashboard that subscribes to a specific MQTT topic

Again I don't understand, what exactly do you mean by "a user to run a dashboard that subscribes to a specific MQTT topic". You don't need to run a dashboard. Just configure MQTT input nodes to subscribe to the topics you want and they will send messages when data are received. There is no need for any dashboard.

Thanks Collin, excuse my ignorance but it is my first project on node-red. As I understand you, if I configure an MQTT node on a flow, it will automatically receive messages from the topic to which it is subscribed by simply deploying that flow, Am I right?

Yes you are! :sparkler: :tada:

One of the great things about node-red is the sort of tool that you can easily experiment with. You could have answered your own question by simply trying it and feeding the output of the MQTT node into a debug node.

I will try it tonight when I arrive to my home. Thanks again.

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.