Skip to content
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

[pidcontroller] Implement previous state recovery on startup #13003

Merged
merged 6 commits into from
Jul 2, 2022

Conversation

lnagel
Copy link
Contributor

@lnagel lnagel commented Jun 24, 2022

This feature allows the PID controller parameters to be updated and OpenHAB to be restarted without losing the current controller state.

This is especially important for systems with a long response time. For example it might take up to a day for an underfloor heating
controller to stabilise after losing state and having to build up the integrator value from zero.

In case the controller instance has configured OpenHAB items for the integral part, derivative part and error inspectors, then we can query the previous value from the persistance layer for these items and restore them during the controller startup.

I have been using this successfully for about 4 months now during the last heating season.

@lnagel lnagel requested a review from fwolter as a code owner June 24, 2022 12:53
This feature allows the PID controller parameters to be updated and
OpenHAB to be restarted without losing the current controller state.

This is especially important for systems with a long response time.
For example it might take up to a day for an underfloor heating
controller to stabilise after losing state and having to build up
the integrator value from zero.

Signed-off-by: Lenno Nagel <lenno@nagel.ee>
@lnagel lnagel force-pushed the pidcontroller-state-recovery branch from 6eed376 to 466f5d2 Compare June 24, 2022 12:59
@jlaur jlaur added the enhancement An enhancement or new feature for an existing add-on label Jun 24, 2022
Copy link
Member

@fwolter fwolter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like a handy solution!

Can you add a short note to the readme, that you need to enable the inspector items to recover the values? And maybe add a reference to the core documentation how to setup persistence on Items?


try {
value = getItemValueAsNumber(itemRegistry.getItem(itemName));
logger.info("Item '{}' value {} recovered by PID controller", itemName, value);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be debug or trace.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

lnagel added 3 commits June 26, 2022 20:08
Signed-off-by: Lenno Nagel <lenno@nagel.ee>
Signed-off-by: Lenno Nagel <lenno@nagel.ee>
Signed-off-by: Lenno Nagel <lenno@nagel.ee>
@lnagel
Copy link
Contributor Author

lnagel commented Jun 26, 2022

Well I fixed everything, but it seems that builds are failing now (and I have a feeling that it's related to the build failures in main).

@jlaur jlaur added rebuild Triggers Jenkins PR build and removed rebuild Triggers Jenkins PR build labels Jun 27, 2022
@lnagel lnagel requested a review from fwolter June 30, 2022 11:18
fwolter added 2 commits July 2, 2022 11:27
Signed-off-by: Fabian Wolter <github@fabian-wolter.de>
Signed-off-by: Fabian Wolter <github@fabian-wolter.de>
Copy link
Member

@fwolter fwolter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks!

@fwolter fwolter merged commit 2c919c6 into openhab:main Jul 2, 2022
@fwolter fwolter added this to the 3.4 milestone Jul 2, 2022
@lnagel
Copy link
Contributor Author

lnagel commented Jul 2, 2022

Cheers!

leifbladt pushed a commit to leifbladt/openhab-addons that referenced this pull request Oct 15, 2022
…#13003)

* [pidcontroller] Implement previous state recovery on startup

This feature allows the PID controller parameters to be updated and
OpenHAB to be restarted without losing the current controller state.

This is especially important for systems with a long response time.
For example it might take up to a day for an underfloor heating
controller to stabilise after losing state and having to build up
the integrator value from zero.

Signed-off-by: Lenno Nagel <lenno@nagel.ee>

* Change logger.info -> logger.debug

Signed-off-by: Lenno Nagel <lenno@nagel.ee>

* Change debug Item -> inspector Item in README

Signed-off-by: Lenno Nagel <lenno@nagel.ee>

* Add documentation regarding state persistence

Signed-off-by: Lenno Nagel <lenno@nagel.ee>

* Update bundles/org.openhab.automation.pidcontroller/README.md

Signed-off-by: Fabian Wolter <github@fabian-wolter.de>

* Update bundles/org.openhab.automation.pidcontroller/README.md

Signed-off-by: Fabian Wolter <github@fabian-wolter.de>

Co-authored-by: Fabian Wolter <github@fabian-wolter.de>
andan67 pushed a commit to andan67/openhab-addons that referenced this pull request Nov 6, 2022
…#13003)

* [pidcontroller] Implement previous state recovery on startup

This feature allows the PID controller parameters to be updated and
OpenHAB to be restarted without losing the current controller state.

This is especially important for systems with a long response time.
For example it might take up to a day for an underfloor heating
controller to stabilise after losing state and having to build up
the integrator value from zero.

Signed-off-by: Lenno Nagel <lenno@nagel.ee>

* Change logger.info -> logger.debug

Signed-off-by: Lenno Nagel <lenno@nagel.ee>

* Change debug Item -> inspector Item in README

Signed-off-by: Lenno Nagel <lenno@nagel.ee>

* Add documentation regarding state persistence

Signed-off-by: Lenno Nagel <lenno@nagel.ee>

* Update bundles/org.openhab.automation.pidcontroller/README.md

Signed-off-by: Fabian Wolter <github@fabian-wolter.de>

* Update bundles/org.openhab.automation.pidcontroller/README.md

Signed-off-by: Fabian Wolter <github@fabian-wolter.de>

Co-authored-by: Fabian Wolter <github@fabian-wolter.de>
andrasU pushed a commit to andrasU/openhab-addons that referenced this pull request Nov 12, 2022
…#13003)

* [pidcontroller] Implement previous state recovery on startup

This feature allows the PID controller parameters to be updated and
OpenHAB to be restarted without losing the current controller state.

This is especially important for systems with a long response time.
For example it might take up to a day for an underfloor heating
controller to stabilise after losing state and having to build up
the integrator value from zero.

Signed-off-by: Lenno Nagel <lenno@nagel.ee>

* Change logger.info -> logger.debug

Signed-off-by: Lenno Nagel <lenno@nagel.ee>

* Change debug Item -> inspector Item in README

Signed-off-by: Lenno Nagel <lenno@nagel.ee>

* Add documentation regarding state persistence

Signed-off-by: Lenno Nagel <lenno@nagel.ee>

* Update bundles/org.openhab.automation.pidcontroller/README.md

Signed-off-by: Fabian Wolter <github@fabian-wolter.de>

* Update bundles/org.openhab.automation.pidcontroller/README.md

Signed-off-by: Fabian Wolter <github@fabian-wolter.de>

Co-authored-by: Fabian Wolter <github@fabian-wolter.de>
Signed-off-by: Andras Uhrin <andras.uhrin@gmail.com>
psmedley pushed a commit to psmedley/openhab-addons that referenced this pull request Feb 23, 2023
…#13003)

* [pidcontroller] Implement previous state recovery on startup

This feature allows the PID controller parameters to be updated and
OpenHAB to be restarted without losing the current controller state.

This is especially important for systems with a long response time.
For example it might take up to a day for an underfloor heating
controller to stabilise after losing state and having to build up
the integrator value from zero.

Signed-off-by: Lenno Nagel <lenno@nagel.ee>

* Change logger.info -> logger.debug

Signed-off-by: Lenno Nagel <lenno@nagel.ee>

* Change debug Item -> inspector Item in README

Signed-off-by: Lenno Nagel <lenno@nagel.ee>

* Add documentation regarding state persistence

Signed-off-by: Lenno Nagel <lenno@nagel.ee>

* Update bundles/org.openhab.automation.pidcontroller/README.md

Signed-off-by: Fabian Wolter <github@fabian-wolter.de>

* Update bundles/org.openhab.automation.pidcontroller/README.md

Signed-off-by: Fabian Wolter <github@fabian-wolter.de>

Co-authored-by: Fabian Wolter <github@fabian-wolter.de>
nemerdaud pushed a commit to nemerdaud/openhab-addons that referenced this pull request Feb 28, 2023
…#13003)

* [pidcontroller] Implement previous state recovery on startup

This feature allows the PID controller parameters to be updated and
OpenHAB to be restarted without losing the current controller state.

This is especially important for systems with a long response time.
For example it might take up to a day for an underfloor heating
controller to stabilise after losing state and having to build up
the integrator value from zero.

Signed-off-by: Lenno Nagel <lenno@nagel.ee>

* Change logger.info -> logger.debug

Signed-off-by: Lenno Nagel <lenno@nagel.ee>

* Change debug Item -> inspector Item in README

Signed-off-by: Lenno Nagel <lenno@nagel.ee>

* Add documentation regarding state persistence

Signed-off-by: Lenno Nagel <lenno@nagel.ee>

* Update bundles/org.openhab.automation.pidcontroller/README.md

Signed-off-by: Fabian Wolter <github@fabian-wolter.de>

* Update bundles/org.openhab.automation.pidcontroller/README.md

Signed-off-by: Fabian Wolter <github@fabian-wolter.de>

Co-authored-by: Fabian Wolter <github@fabian-wolter.de>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement An enhancement or new feature for an existing add-on
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants