Writing values to a node's config

How do you write to a node's config from the backend?

Backstory: I want to use the node's config to cache data from a physical home automation device.

The problem I am facing is that you can only read these values from the physical device when the device is awake.

Because the config node that represents the device is torn down on each deploy of the node, I need to cache some important data from the device so that the node can be re-deployed without the physical device needing to be awake.

I don't think that is really the purpose of the config data which requires an admin to Deploy after it has been changed. While it might be possible to do that via API calls, it doesn't really seem to be the "Node-RED way"?

For uibuilder, I use a file to cache data that I need to have saved between restarts but don't want to have to force admins to hit the deploy button for.

Hi Julian - I wasn't thinking about the deploy problem, that makes sense.

The configuration node that I'm writing is for insteon devices. There are many devices which are battery operated that also have local settings. In the case of a motion sensor, we can adjust the sensitivity as well as the motion timeout and a number of other settings.

I want to be able to show these settings to the user in the configuration node's UI, but in order to display the current values, I have to read them from the device when the device is awake.

I know that the device is awake when the user links it into the eco system for the first time.

I guess what I will do is setup an ajax server that provides all of the device's configuration settings when linking the device in, then dynamically create the configuration node in the editor. These values could then be passed in, and will be stored when the user deploys.

This puts most of the heavy lifting on the front end, which I don't love, but it might be a good compromise.
The only other thing I could do is role my own cache / local database.

Here's a video of the linking and config node creation process as it stands:

This is really simple with Node-RED. Do have a look at the uibuilder code and you will see that I set up a number of API's that reuse Node-RED's admin ExpressJS server. In my Editor panel, I can call those API's to update data. For example, there are API's that list the files available to edit and that pull/push the code. There are others that pull in the list of managed packages that uibuilder will serve up for you - that also pulls data from a file.

Again, the Node-RED editor makes this as easy as it can be and you have access to jQuery to assist as well.

And to reiterate, you don't need any additional servers. Node-RED already has everything you need to be able to serve up API's to both admin and end users.

I tackled this from the font end. Work's just fine.