How to get states from external software



I'm just starting with node red and I'm very impressed of this absolutly cool software.
I tested some simple things, like ping a host and display it on a dashboard.

Now I'm searching for a way to get information about the nodered system (e.g. state of node).

Lets say, I have a ping-node with a led to display it on the dashboard. How can I get this information from an external programm? Is there something like a rest interface to call or do I have to store this information somewhere else?



Your question is a little vague as getting the information from an external program could mean many things. However, it may well be that MQTT would be a good way to solve your problem. Give us more information about exactly what you are trying to do and no doubt a clearer answer will be forthcoming.


Which way are you trying to get the information ?
You want to send the ping info to a remote program ? Or you want a remote program to be able to query Node-RED for the info ?


Ping was only an example. I'm searching for a right way to get "information" from the node red system.
Lets say, I ping a host and show the state on dashboard. Or I have a dashboard switch, which turns on an output (what ever the hardware is).

After that, i want read some information from external about the switch states or the ping status or something else.

Is there a node-red approach for this, like a rest interface which I can call? Could I write to some context and read it from outside? Do I have to store this information in an database and read it from my external software there? Or (in the answered from colin) should I always send (remap the states/triggers/...) to mqtt message(s) and store this information externally?

This was my first idea,too. I write an external mqtt client, which listen to special topics and save my "state" information there. But isn't there a solution in node-red which I haven't found yet.


Firstly it doesn't need to be an external mqtt server, that can (and very often is) on the same machine running node-red.
Secondly the mqtt server will save the state if you publish the topic as Retained (provided that feature is enabled in the mqtt server) so you don't need to save it anywhere else. When your external application needs to get the value it can merely connect to the server and subscribe to the appropriate topics and it will be informed of the values.
The other approaches you mention are also viable, you could provide an http api in node-red or you could use websockets, or store the data in a externally accessible database, or likely any number of other possibilities. However using mqtt may well involve much less work than these approaches. Most languages provide mqtt clients libraries.


Though setting up an http endpoint isn't hard. See the cookbook for examples