I tried several hours to work with a global (and persistant) variable. After many tries i realized, that everything works fine, when i'm using context, saved as memoryOnly, but it doesn't if i try to use a global context wich is saved to file...
I've followed the NodeRed docs and used this in my settings.js:
contextStorage: {
default: "memoryOnly",
memoryOnly: { module: 'memory' },
file: { module: 'localfilesystem' }
}
If i now create a global Variable with this function:
global.set("lightsPower",msg.payload);
return msg;
i can read and use it like this:
var M = global.get("lightsPower");
msg.payload = M;
return msg;
But if i create it with a change-node and select file instead of memoryOnly as destination (?!) i can't get it, no matter what i tried.
Do i need to point to the filesystem in anyway?