Execute flows only if UI needs the data / highlight outdated data on UI

Hi, I'm quite new dealing with Node-Red and have a couple of requirements where I don't find anything in the Web. This question is about just executing certain nodes if the data is requested by the UI.

Situation:

  • Flow is polling data from an external source (currently every 5 seconds)
  • UI is showing received data on different UI tabs
  • Sometimes it happens that some polled datapoints don't answer
  • Parts of the data need to be available and sent to other external software
  • Parts of the data is only needed for certain tabs of the UI

I want to minimize the data traffic and just poll the required data every 5 seconds.
That means I would need a flag for each datapoint on the UI Tab which is telling me that somebody is looking at the data - only in this case I would poll this certain datapoint every 5 seconds.

In addition I would like to have something like a data watchdog for each signal. If there was no answer for a certain datapoint after polling (let's say for 2 Minutes) I want to set either the Value on the UI to 'NA' or change the font color to grey.

I would appreciate if somebody could give me a starting point for both problems.

I think maybe you are thinking about things the wrong way. In node red you don't execute nodes, you send them messages which they act the on. So I suggest you first rephrase your question from that perspective. Then possibly nodes such as node-red-contrib-simple-gate might be useful.

Aside from Colin's feedback, here are a couple pointers that may help.

To create a watchdog flow, check out this recipe in the cookbook: https://cookbook.nodered.org/basic/trigger-timeout

The ui_control node can be used to track which tab of the dashboard is open.