question

markess avatar image
markess asked

Node-RED default dashboard values after Cerbo reset

I have Node-RED running on my Cerbo GX. I have a Node-RED dashboard where I set some numerical parameters for the flows (as flow variables). Recently I had to reboot my GX due to connectivity issues and after rebooting, as you might expect, all the dashboard values change (seem to either not be set or go to their range extremes).

After a GX reset Node-RED appears to come back up, running the flows it did previously, so it's important to make the dashboard values come back set to something sensible.

Is there a way to set a default dashboard value, which it will take after a reset of my GX?

The image shows how I use the function node to set a flow variable from the dashboard. Do I just need to use 'On Start' tab and set a hard value there? e.g.

flow.set("socthreshold_dash", 50);

return msg;


screenshot-20230529-085538.png


screenshot-20230529-085830.png

Node-RED
2 |3000

Up to 8 attachments (including images) can be used with a maximum of 190.8 MiB each and 286.6 MiB total.

5 Answers
derrick thomas avatar image
derrick thomas answered ·

Use an inject node set to inject once then not repeat. Set the inject node payload to whatever value you want as default upon system reboot. This will send the payload message to the dashboard switch only once upon flow deployment.

2 |3000

Up to 8 attachments (including images) can be used with a maximum of 190.8 MiB each and 286.6 MiB total.

markess avatar image
markess answered ·

Thanks. This worked. This results in changes to the dashboard values

1. If new changes are deployed in Node-RED

2. If Node-RED is disabled and re-enabled via Remote Console

3. The GX reboots

2 |3000

Up to 8 attachments (including images) can be used with a maximum of 190.8 MiB each and 286.6 MiB total.

markus-001 avatar image
markus-001 answered ·

Write the values to a file using the “write to file” node under the storage group then on a restart / reboot read the file once with an inject node this should recover the last stored value that was present in the dashboard before the reboot. Make sure to write the file in a place that does not get overwritten during a firmware update. Also attach a debug node after the “write to file” so you can see the number writes in the debug area, it’s not a good idea to have a high frequency of writes per minute as the memory is flash and could degrade over time with a high number of rewrites per minute. I use a separate tab for all my write to file nodes 30+ of them.

2 |3000

Up to 8 attachments (including images) can be used with a maximum of 190.8 MiB each and 286.6 MiB total.

derrick thomas avatar image
derrick thomas answered ·

There is an option in the settings.js to enable local storage and node red will take care of it automatically without any additional steps or added nodes or variables. With this option enabled node red automatically writes the variables data to storage every 30 seconds and upon reboot automatically loads the last stored information for all variables.

2 |3000

Up to 8 attachments (including images) can be used with a maximum of 190.8 MiB each and 286.6 MiB total.

markess avatar image
markess answered ·

Thanks, yes I see that here

https://nodered.org/docs/user-guide/context

Having fixed values from one-time inject node is fine for me, to save on this IO, as this is just to set dashboard values.

2 |3000

Up to 8 attachments (including images) can be used with a maximum of 190.8 MiB each and 286.6 MiB total.