-
Notifications
You must be signed in to change notification settings - Fork 50
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
How to persist values across Fledge/South Plugin restarts #1538
Comments
Yes, you can set the SP_PERSIST_DATA flag in the plugin information entry point.
This will then alter the shutdown and start procedure to persist data and reload that data. The data that is persisted should be in JSON format and is passed in and out of the plugin as a string. Unfortunately this is not currently included in the online documentation and needs to be added. The plugin_shutdown entry point should return the data to be persisted
The plugin_state entry point will be called with a string that contains the persisted data from he previous run
The example here is from a filter, but it works in the same way for south and north plugins. |
Thank you, @MarkRiddoch, for your response! I have two additional questions:
|
I believe they are available in some but not all types of Python plugins. I would need to go and check to give a definitive list and will report back once I have done this.
Yes, the data is stored in the configuration database rather than the readings database. This was done because the readings database could be an in-memory database. |
Documentation has now been added to the repository and should update shortly in the readthedocs documentation. |
Consider the following scenario:
A South plugin receives a message containing an event's start time. After some time, it receives another message containing the corresponding end time. The goal is to calculate the duration between the start time (t_start) and the stop time (t_stop).
Would using a built-in storage service be preferable, or is there a better pattern for persisting and retrieving stateful data across reboots?
The text was updated successfully, but these errors were encountered: