My flow uses many gates. A malfunction began a few months ago in all of my automated lighting that I’ve traced to those gates resetting to their Default State, untriggered but quickly. I could manually open a gate and check on it 5 minutes later to find that it’s closed. I’ve verified that there’s no way the flow is triggering them. This is a new behavior. Does anyone know what’s happened to the gates?
Gates are not a standard part of NR - are you referring to node-red-contrib-simple-gate? I use this one, and it has a “Restore from state” option - do you have this checked? Otherwise I expect every full deploy it will forget. Looking at mine it has a drop-down beside this field for where the store is located. I don’t remember this from when I first set them up. In my case there is nothing selected and only “default” in the drop-down. This looks like it could be some previous breaking change, but mine all still appear to work fine without it set.
You could also check the NR logs - perhaps it is restarting for some reason? I run NR separately (not the addon), and therefore you have to configure context manually to be stored in a file rather than just in memory, or a restart will cause it to forget. I’m guessing the NR addon does this for you.
It doesn’t. It is the same process you would take to enable it on a stand alone. The file settings.js
is located in \addon_configs\a0d7b954_nodered
https://nodered.org/docs/user-guide/context#saving-context-data-to-the-file-system
Yes, that is the gate. I’ve tried with that “restore from state” checked and unchecked. I don’t even use full deploys, but only modified nodes for this reason. The only option I have in that drop-down is for memory. The NR logs show that it is definitely restarting, but no indication as to why.
I tried writing a function to use in place of the “faulty” gate node, but needed to store the state in a flow, or context, variable. And guess what? Those default with the restart too. So the question becomes: What in HA is restarting NR unexpectedly?
I’ve tried copying that contextStorage config into settings.js but changing to default: “file” but NR refuses to restart. I’ll keep trying, but this is just a workaround anyway. I need to stop the unexpected restarting. It’s happening even with Watchdog disabled.
Like cut and pasted the example into settings.js? The key already exists in the file and is set to memory, you need to modify that entry.
That key is NOT already in my settings.js. That’s why I added it. As it is, the file is mostly commented-out settings & instructions. Active settings are easy to spot, and none of them are contextStorage.
My mistake, I thought it was there already. Place it between 2 keys.
Existing
functionGlobalContext: {
env: process.env,
// os:require('os'),
// jfive:require("johnny-five"),
// j5board:require("johnny-five").Board({repl:false})
},
// The following property can be used to order the categories in the editor
// palette. If a node's category is not in the list, the category will get
// added to the end of the palette.
// If not set, the following default order is used:
paletteCategories: [
"home_assistant",
"subflows",
"common",
"function",
"network",
"sequence",
"parser",
"storage"
],
Context added
functionGlobalContext: {
env: process.env,
// os:require('os'),
// jfive:require("johnny-five"),
// j5board:require("johnny-five").Board({repl:false})
},
contextStorage: {
default: "file",
memoryOnly: { module: 'memory' },
file: { module: 'localfilesystem' }
},
// The following property can be used to order the categories in the editor
// palette. If a node's category is not in the list, the category will get
// added to the end of the palette.
// If not set, the following default order is used:
paletteCategories: [
"home_assistant",
"subflows",
"common",
"function",
"network",
"sequence",
"parser",
"storage"
],