Closed warfanax closed 3 years ago
Please confirm you are saving global context.
Please refer to : https://nodered.org/docs/user-guide/context#saving-context-data-to-the-file-system
The alarm state is stored in global context and you therefore need to save global context to disk to survive restarts.
Please confirm you are saving global context.
Please refer to : https://nodered.org/docs/user-guide/context#saving-context-data-to-the-file-system
The alarm state is stored in global context and you therefore need to save global context to disk to survive restarts.
I don't think I save it.
Unfortunately I don't know have much experience with these and don't know coding so I just follow instructions most of the time to solve issues.
How would I save global context? Contrib-alarm nodes don't have a section to write a JSON.
Do I put a change node after a specific node and write a JSON there?
If you could guide me how and where to do it I will be grateful.
I figured out how to write to global.js or flow.js but for the love of god nothing works. I am beyond pissed. I put a change node after "state changed" and write msg.payload to global.initialState, I go double check global.js and its in there but after nodered restart never sends what's in file. Keeps sending
"SecuritySystemCurrentState": 0 "SecuritySystemAlarmType": 0 after every restart. There isn't even such entry in /context/global.js file. no such thing exists but still keeps sending it as an initial state.
I tried to even catch the initial state message with switch node, separate it and put a change node to change it with what's written in file ( "SecuritySystemCurrentState": 3) but still doesn't work.
Even if I uncheck "send initial state" from the node, it still keeps restarting with "armed home" and logs still show
"initialState": true, "payload": { "SecuritySystemCurrentState": 0, "alarmState": "Home", "SecuritySystemAlarmType": 0, "isAlarm": false } }
Spent literally 10h on this today and really need help.
Hi, sorry to hear you have had such an issue.
Writing manually to the global state is not required, the nodes manage that for you.
By default mode-red only stores global state in memory, so a reboot will not persist anything. So even if you use a node to write to disk, it won’t know to read from disk on reboot.
You need to alter the node red configuration to tell it to persist on disk, and remove the node you added to write to disk.
You need to set this option in your settings.is:
contextStorage: { storeName : { module: "localfilesystem" } },
More information: https://discourse.nodered.org/t/a-guide-to-understanding-persistent-context/4115
Let me know if that does not resolve your issue.
Sent from my iPhone
On 8 Feb 2021, at 9:54 am, warfanax notifications@github.com wrote:
I figured out how to write to global.js or flow.js but for the love of god nothing works. I am beyond pissed. I put a change node after "state changed" and write msg.payload to global.initialState, I go double check global.js and its in there but after nodered restart never sends what's in file. Keeps sending
"SecuritySystemCurrentState": 0 "SecuritySystemAlarmType": 0 after every restart. There isn't even such entry in /context/global.js file. no such thing exists but still keeps sending it as an initial state.
I tried to even catch the initial state message with switch node, separate it and put a change node to change it with what's written in file ( "SecuritySystemCurrentState": 3) but still doesn't work.
Even if I uncheck "send initial state" from the node, it still keeps restarting with "armed home" and logs still show
"initialState": true, "payload": { "SecuritySystemCurrentState": 0, "alarmState": "Home", "SecuritySystemAlarmType": 0, "isAlarm": false } }
Spent literally 10h on this today and really need help.
— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or unsubscribe.
I already entered that in settings. No problem with that. I even have a drop down menu now to select memory or file if you choose "flow" or "global", means I entered it correctly.
If I don't have to write to file myself then I don't know what else to do?
node-red-contrib-alarm uses "default" global state, so please confirm you have this exactly in your settings.js:
contextStorage: {
default: {
module: "localfilesystem"
}
},
If not, please make sure it does and test again, you should see that if the state changes on the alarm system, the global persisted state file on disk should change within about 30 seconds. It uses the "default" context storage for loading the state on restart.
If this is definitely not working for you, can you post any errors that might be getting thrown? Maybe something else is getting in the way.
On Tue, Feb 9, 2021 at 9:02 AM warfanax notifications@github.com wrote:
I already entered that in settings. No problem with that. I even have a drop down menu now to select memory or file if you choose "flow" or "global", means I entered it correctly.
If I don't have to write to memory myself then I don't know what to do?
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/Anamico/node-red-contrib-alarm/issues/19#issuecomment-775521412, or unsubscribe https://github.com/notifications/unsubscribe-auth/AGHK2LH5UHTN4AX73AITEQTS6BUR3ANCNFSM4XE6KCJQ .
Alarm was set "off" for a while (not less than 30sec) and I just restarted Nodered and its set to "Home" again by itself. Here are Nodered restart log and my settings.js entry:
Edit:
Even if I uncheck "send initial state" from "state changed" node, my log will still show as true:
"initialState": true, "payload": { "SecuritySystemCurrentState": 0, "alarmState": "Home", "SecuritySystemAlarmType": 0, "isAlarm": false } }
where is the state exactly saved? I can't find it in:
/config/node-red/context/global/global.json
Ok found the problem and I think it is almost solved. In my entry "default" location was memory. Although when I first tried the entry with "localfilesystem" as being default, it never worked. I changed it to what is it now when playing with change nodes.
I made localfilesystem default now and I can see the global.js entry as "SecuritySystemCurrentState": 3. After the restart log shows the "SecuritySystemCurrentState": 3. Great! I am very grateful for your help!
However there is one minor problem.After bordered restart iOSHome app shows the alarm as constantly stuck at "arming home". Only after the restart. iOS Home app displays the correct state changes any other time.
Seems like initial state message doesn't have "target state" and if I am not mistaken it is the one that sets the Home app icons display correct state. Do you have any idea how can this be fixed?
edit: I dont think it has anything to do with target state message. Before it was showing as armed home now problem in iOS Home app.
"initialState": true, "payload": { "SecuritySystemCurrentState": 3, "alarmState": "Off", "SecuritySystemAlarmType": 0, "isAlarm": false } }
with this message it doesn't set it to off. Its stuck at arming...
Seeing the same issue and it does come down to when the state is loaded from the localfilesystem the "SecuirtySystemtTargetState" is not loaded on a node-red restart and only "SecuritySystemCurrentState" is loaded. That causes Homekit and the UI to go to "arming..." state and not finalize. The code needs to be changed to send both states on restart of node-red and it will be fixed.
I modified the callback in panel.js in .node-red/node_modules/node-red-contrib-alarm/alam/panel.js to be the following:
By uncommenting the "SecuritySystemTargetState" area and using the exact same variable to set it to the same setting as Current State I am able to maintain system status across restarts of node-red without issue now.
wow. That was it. Amazing. Thank you so much for the fix!!!
rolled in to 1.2.5
No matter what I do, if Nodered restarts, alarm is always set to "armed Home" even If the state of the alarm was "Disarmed" before restart. its always "Home".
I have tried to uncheck "send initial state" box, but still logs show:
"initialState": true, "payload": { "SecuritySystemCurrentState": 0, "alarmState": "Home", "SecuritySystemAlarmType": 0, "isAlarm": false } }
Tried to change or set msg.initialState message to false or to "0" value with a change node to make it restart with "Disarm", still every time it arms itself to "Home".
Coud you please help me figure this out? It would be good if it remembered the last state of the alarm and set it at the restart instead of always arming "Home".