contextStorage in later versions of NR. Confused

NR 1.1.2

From this link
New in 0.19 So I believe I am included in this.

contextStorage: {
   default: {
       module:"localfilesystem",
       config: {
           // see below
       }
   }
}

So, off I go to settings.js.
contextStorage
not found

Looking.....

    // Anything in this hash is globally available to all functions.
    // It is accessed as context.global.
    // eg:
    //    functionGlobalContext: { os:require('os') }
    // can be accessed in a function block as:
    //    context.global.os

    functionGlobalContext: {
        // os:require('os'),
        // octalbonescript:require('octalbonescript'),
        // jfive:require("johnny-five"),
        // j5board:require("johnny-five").Board({repl:false})
        myDeviceName: "BedPi"
    },

So we have gone from contextStorage to functionGlobalContext.

How do I set it up so context is stored in/on the filesystem?

(Just to check:)
(now things are getting vague for me)

I have seen some nodes talking about context (gate for instance) but then the switch/button node has no mention of this.

I want the switch (as in dashboard type) to get their previous state back if the machine is rebooted.

Is this the better way of doing it?

How old is the settings.js file?
It's easy to keep updating node-RED (which does not update the settings.js file), and then find that new options have been added which require a setting in the settings file.
Compare your settings file with the current version - available from github.

1 Like

(Me showing my stupidity.)

Thanks.

So next dumb question: How do I make the settings.js file up to date?

My efforts at finding the latest settings.js file on github are only showing stuff that are old.
Like > 2 years ago.

As I have already said;

If you just want to add the context storage, just add & edit this, to your settings;

    // Context Storage
    // The following property can be used to enable context storage. The config$
    // provided here will enable file-based context that flushes to disk every $
    // Refer to the documentation for further options: https://nodered.org/docs$
    //
    //contextStorage: {
    //    default: {
    //        module:"localfilesystem"
    //    },
    //},

So the part I posted is....... redundant? Superfluous? not needed/used?

What part?

This:

// Anything in this hash is globally available to all functions.
    // It is accessed as context.global.
    // eg:
    //    functionGlobalContext: { os:require('os') }
    // can be accessed in a function block as:
    //    context.global.os

    functionGlobalContext: {
        // os:require('os'),
        // octalbonescript:require('octalbonescript'),
        // jfive:require("johnny-five"),
        // j5board:require("johnny-five").Board({repl:false})
        myDeviceName: "BedPi"
    },

Oh, is that more for global context rather than general context?

As I said: I'm confused.

That isn't the section that you need.

Ok, so I may not be actually doing the right thing then.

I'm not sure.

If I want the switch nodes to go back to the state they were in before an unexpected reboot, is that under this of which I am now asking - or that you showed me - or something else?
And other things as well.

Reboots can be painful if I am not here/on site.

I get that some things will default to things, but a lot of stuff I want to go back to how it was before the reboot.

Correct.
See node-red/packages/node_modules/node-red/settings.js at master · node-red/node-red · GitHub
This is what you need to establish context storage.

1 Like

I hope it works.

Obviously I removed the leading // on the required lines and I had to restart NR.

Andrew, maybe this will help too

1 Like

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