Persistent global context - missing variables

I am using around 30 persistent global variables saved in my local Store.
Today I had to restart the Raspi after a kernel update and after restart I found that 5% of the variables were set as "undefined", not stored in the context.
This is not the first time it happens. How can I rely on the persistent global storage?

This is my settings.js:

 contextStorage: {
        lilioStore: { module: "localfilesystem"},
        lilioStoreLuci: { module: "localfilesystem"},
        default    : { module: "memory" }
    },

and I am setting the variables with :

global.set("variable-name", value,"lilioStore");

Everything looks very straightforward.

You still have two local filesystem stores where you have not given them different directories.

That is going to cause problems. Until you fix that, it isn't worth investigating anything else.

Yes, I am studying how to separate them without losing variable states...
How can I extract all variables from a store?

There was a thread on this very recently (like 1 or 2 days ago)

However, IMHO, it is better store related global (or flow) values in a single object.

config = {
    "ip": "1.2.3.4",
    "enabled": true,
    "params": [ 5, 33, 123, 54 ],
    "maintainer": {
        "name": "fred",
        "email": "fred@here.com"
    }
}

That way it is a simple matter of var config = global.get("config") (or the change node equivelant)

and you can access config.ip and config.enabled etc.

Additionally, as well as all values being neatly "packaged" in one object, you can click the copy value button on the global viewer in the side-bar & get all values in one go (manual backup if you like)

0Lz4dg0gHn

↑ Feel free to ignore this if this is of no value :slight_smile: (its just a suggestion)

1 Like

I think I will move all variables from a store into the other, and then remove the first store, so I will have just one:

a = global.keys("lilioStoreLuci");

for (var x in a) {
    temp = global.get(a[x],"lilioStoreLuci");
    global.set (a[x],temp,"lilioStore");
    global.set (a[x],undefined,"lilioStoreLuci")
}

removing it also from settings.js

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