-
Notifications
You must be signed in to change notification settings - Fork 38
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Request] Persistent state of nodes #227
Comments
You are able to persiste the node state in the following way:
|
Hi @ckhmer1 - firstly, a belated 'Happy New Year' from the UK, and thanks for all the work which you have done here, especially during the past year. Could I ask if |
Thank you for your reply @ckhmer1 Since I am not 100% sure when the state is lost, any suggestion to when to send the "set_state"? I was thinking as a last resort to do it every deployment, but not sure how to trigger it. @Paul-Reed I found about the "get_state" and "set_state" from the help bar for the management node: |
@AlecTBM I think the easiest way to do this is to use option 2 - using the output from the Management node, as it will save the current state to context automatically.
Where the 'device node ID' is the node ID of your thermostat, switch or whatever... Then finally, add an inject node to inject the state into your thermostat whenever you do a full deploy or reboot. So it looks like; Hope this helps! |
Hi @Paul-Reed, Regarding the persistent storage, I'll add a flag to the device node to allow the user to disable the auto save state selectively for some nodes, in this way there is no need to know the nice ID |
Thank you for all the interests in this. I did make another solution last night that I did not get time to write. Everytime the management node is either sending the "set_state" or is responding on the "get_state" message, I save it to context on file. For me this is solution should be enough 😃 the only question is if there is other circumstances where i would need to load from context other than "server start". And I know that if I for example change the setpoint on a thermostat, the management node don't send a "set_state" message, but I have so many devices that one of them is sending an update at least every 15 minutes, so this is not a big case for me. |
It should be enough to restore back the state when the server is started. |
@AlecTBM - Your suggestion works fine, and by dropping the nodes into a subflow, it makes a neat solution, and visually only adds one node to the flow. NOTE - because it is a subflow, the saved context data is not visible in the sidepanel, as it's stored within the subflow. Edit - updated with @AlecTBM 's comment in post below
|
Looks good @Paul-Reed, the only thing I would add is to only save the payload if the topic is "set_state" (and possibly "get_state") to not make it break in the future. With the post from @ckhmer1 I think we can close this "issue" for my sake 😊 thank you for all your good work here! |
Sorry for the newbie question, but how do you set the context store? I've opened the subflow and see the 'Save context' node and assume I need to have a directory or path there? What does 'Deep copy value' do? If this is writing to a MicroSD card, will it have an overhead in wear levels on the card, versus having the nodes return to defaults on reboot/redeploy? |
This it saving it to the default context store, which normaly is memory. The deep copy value is "new" a node-red thing that I haven't checked out yet 😊 |
@ChutneyMary - No, it will work without any alteration, no need to change anything in the subflow for it to work & save the context to RAM, which is probably good enough for most usage. It will restore OK if the Smarthome server is stopped/started, if you do a full deploy, or even restart the flows. I wouldn't worry too much about this causing SD wearing, it does have a small overhead, but the frequency and amount of disk writing is very minimal, compared to system logs, etc. |
Hello and thank you for a very good project!
Is it possible to make the state of each node persistent? As it is now, somethines when a node or management is updated the state is lost and the nodes goes to a default or "unknown" state.
On my thermostat all of them goes to the "Minimum threshold" for both ambient and setpoint until I either send them a message or interact with them via google. And since I mostly only update the ambient temperature, then the setpoint gets out of sync with the actual setpoint.
If it is not possible or priority to make this persistent in this project, do anyone have any workarounds? 😃
I was thinking about buffering the last state as a context saved to file, but I have not been able to find a way to detect when the state goes to Unknown or default.
Example on a TV node with unknown state:
The text was updated successfully, but these errors were encountered: