Dashboard backup

Hi,

is it possible to save dashboard data (for example chart data) for restart node-red service? At the moment i lost all Data.
At the Moment i use node-red-dashboard

Thank you

Alex

hmm what does the info box for the chart node say ?

"The node output contains an array of the chart state that can be persisted if needed. This can be passed into the chart node to re-display the persisted data."

But i dont know how i can do this.

Full Text:

Plots the input values on a chart. This can either be a time based line chart, a bar chart (vertical or horizontal), or a pie chart.

Each input msg.payload value will be converted to a number. If the conversion fails, the message is ignored.

Minimum and Maximum Y axis values are optional. The graph will auto-scale to any values received.

Multiple series can be shown on the same chart by using a different msg.topic value on each input message. Multiple bars of the same series can be shown by using the msg.label property.

The X axis defines a time window or a maximum number of points to display. Older data will be automatically removed from the graph. The axis labels can be formatted using a Moment.js time formatted string.

Inputting a msg.payload containing a blank array [] will clear the chart.

See this information for how to pre-format data to be passed in as a complete chart.

The Blank label field can be used to display some text before any valid data is received.

The label can also be set by a message property by setting the field to the name of the property, for example {{msg.topic}} .

The node output contains an array of the chart state that can be persisted if needed. This can be passed into the chart node to re-display the persisted data.

First of all, you need to create a file based context store, see https://nodered.org/docs/user-guide/context which is a means to save your chart data to your SD/hard disk so the data will survive a reboot.

Once you've done that, add a change node on the output of your chart node, and set it to save the output to flow.context

And finally, add a inject node to the input of the same chart node, set to inject once on startup, and inject the flow.context back into the chart node, which will restore the chart to how it was before the reboot.

2 Likes

There is an example in the flows site that purports to do exactly what you want
https://flows.nodered.org/flow/92920b4fd450bf92a3035e061947daa0

1 Like

Ok i will test it today.
Thank you

Isn't that an old example - pre context data?

1 Like

Yes, but it still works. Probably the author should update it, I don't suppose he is very busy at the moment. :slight_smile:

1 Like

@corin.corvus give me 5 minutes and I'll do you an example flow...

Set up your file based context store first as per the link above, then see this flow -

[{"id":"8bc18a0c.193898","type":"ui_chart","z":"c53060.842a0fa","name":"","group":"61d2dced.3db8f4","order":1,"width":0,"height":0,"label":"chart","chartType":"line","legend":"false","xformat":"HH:mm:ss","interpolate":"linear","nodata":"","dot":false,"ymin":"","ymax":"","removeOlder":1,"removeOlderPoints":"","removeOlderUnit":"3600","cutout":0,"useOneColor":false,"useUTC":false,"colors":["#1f77b4","#aec7e8","#ff7f0e","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"useOldStyle":false,"outputs":1,"x":350,"y":670,"wires":[["764ce7e5.7d6fe8"]]},{"id":"764ce7e5.7d6fe8","type":"change","z":"c53060.842a0fa","name":"","rules":[{"t":"set","p":"mydata","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":500,"y":670,"wires":[[]]},{"id":"2d5661a2.898ebe","type":"inject","z":"c53060.842a0fa","name":"","topic":"","payload":"mydata","payloadType":"flow","repeat":"","crontab":"","once":true,"onceDelay":0.1,"x":350,"y":630,"wires":[["8bc18a0c.193898"]]},{"id":"61d2dced.3db8f4","type":"ui_group","z":0,"name":"flowtest","tab":"3c94630c.13381c","order":1,"disp":true,"width":22,"collapse":false},{"id":"3c94630c.13381c","type":"ui_tab","z":0,"name":"Test","icon":"dashboard","order":9}]
1 Like

Hi,
now i think i did it.
i have a context folder in .node-red with a file.

now i impored your flow. may i connect all charts with one change node or i have to add a change node for each chart?

ok i tested it with one chart. after restart the data was dropped.

i set this in settings.js:

contextStorage: {
    default: {
        module:"localfilesystem"
    },
},

But i can see the data in "contextdata" in webgui but without data before restart.

You need to have a different store for each chart, otherwise all of your charts will display the same data.

Example -
flow.temperature
flow.windspeed
flow.humidity

Did you reboot after setting up the context store to make it available?
Can you try again.

is this ok?

data are in

can i "service nodered restart"?

That looks ok, however I can't see the inject node feeding into the chart node, I'll assume it's off-screen.
You need to inject the saved data back into the chart when it restarts (just like my example flow)

Can you stop/start again.

save

the test works fine!
grafik

do i need both for each chart ? do i need click on all before i restart or only one time forever?

Yes, a change node to save the chart data, and a inject node to restore the chart data.

You don't need to click the inject node at all. It will inject the data automatically after a reboot/restart because the 'Inject once...' box is ticked.

inject

It will look after itself with no interaction necessary.

1 Like

Ah ok.

its done. Thank you :slight_smile:

1 Like

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