I’m facing a similar issue with my heating controls. It does seem that the I-part will get stuck at the lower bound for some reason. Here’s my config and I’m running the latest .jar file posted here in this thread.
Here’s the graph of temperature, setpoint, controller output and inspector items. I have done 2 manual resets of the automation during this time - these are the points where the I-part is reset to zero and the graph starts moving again.
The internal integralResult value is unbounded. I was expecting that it would be limited by the min/max values I set, so whenever the temperature crosses into the other side of the setpoint, the integral value would immediately change.
EDIT2: I prepared a pull request in attempt to fix this.
I have some more work in progress that I can share. Since I’m running floor heating, then losing state for the integrator component is rather painful, it will take a day for the system to stabilize after each rule change or openhab restart. So I implemeted recovery for the PID controller’s internal state from the inspector items on startup. This can be combined with restoreOnStartup strategy in the persistence module to create a system where you can restart openhab or edit rule parameters without upsetting control.
Feel free to take a look at my dev tree here:
While working on this code I start to realize that it would benefit from some cleanup among the helper functions defined in these classes and such smaller things. Since you’re the package maintainer for this addon, could you maybe suggest how should the workflow be for this?
Also, how do we get this code upstream for the next release?
Great to see progress on the PID controller! Your changes look good so far. Go ahead and do the cleanup. When you’re finished, you can file a PR against the upstream repo. I will file the I limiting PR tomorrow, after the milestone release is out. After it has been merged, you can rebase your changes onto the upstream/main branch and file your PR. I will review it and merge it upstream when everything is alright.
@rgabo74 you can do it using openhab-js (part od jss plugin) but PID controller is available only in master (not relased branch). You can do install npm i openhab in /etc/openhab/automation ten git clone the openhab-js repo and move the files manually
PID controller is not reseting on every RESET command. Don’t know exactly how to log/reproduce this but i have a suggestion to change PID code to reset the controller on ReceivedCommand not ItemChanged. It will help to resolve the issue which i am describing below. What do you think @fwolter
1/ i know one situation when this could happen : PID controller rule is temporarly disabled and is receiving RESET command.
2/ when you enable the rule again RESET string is sitting in the item and sending it again will not reset the controller.
but i think it’s not the case i am facing here
2022-11-08 22:56:06.372 [INFO ] [openhab.event.ItemCommandEvent ] - Item 'RadiatorAC3_PID_commandItem' received command RESET
2022-11-08 22:56:06.377 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'RadiatorAC3_PID_commandItem' changed from NULL to RESET
2022-11-08 22:56:06.383 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'RadiatorAC3_PID_commandItem' changed from RESET to NULL
2022-11-08 22:56:06.548 [INFO ] [openhab.event.ItemCommandEvent ] - Item 'RadiatorAC3_PID_commandItem' received command RESET
2022-11-08 22:56:06.556 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'RadiatorAC3_PID_commandItem' changed from NULL to RESET
2022-11-08 22:56:06.563 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'RadiatorAC3_PID_commandItem' changed from RESET to NULL
2022-11-08 22:56:06.655 [INFO ] [openhab.event.ItemCommandEvent ] - Item 'RadiatorAC3_PID_commandItem' received command RESET
2022-11-08 22:56:06.663 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'RadiatorAC3_PID_commandItem' changed from NULL to RESET
2022-11-08 22:56:06.670 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'RadiatorAC3_PID_commandItem' changed from RESET to NULL
2022-11-08 22:56:07.708 [INFO ] [openhab.event.ItemCommandEvent ] - Item 'RadiatorAC3_PID_commandItem' received command RESET
2022-11-08 22:56:07.723 [INFO ] [openhab.event.ItemCommandEvent ] - Item 'RadiatorAC3_PID_commandItem' received command RESET
2022-11-08 22:56:07.734 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'RadiatorAC3_PID_commandItem' changed from NULL to RESET
2022-11-08 22:56:07.741 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'RadiatorAC3_PID_commandItem' changed from RESET to NULL
2022-11-08 22:56:07.942 [INFO ] [openhab.event.ItemCommandEvent ] - Item 'RadiatorAC3_PID_commandItem' received command RESET
2022-11-08 22:56:07.949 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'RadiatorAC3_PID_commandItem' changed from NULL to RESET
2022-11-08 22:56:07.956 [INFO ] [openhab.event.ItemStateChangedEvent ] - Item 'RadiatorAC3_PID_commandItem' changed from RESET to NULL
2022-11-09 08:20:11.505 [INFO ] [openhab.event.ItemCommandEvent ] - Item 'RadiatorAC5_PID_commandItem' received command RESET
2022-11-09 08:22:13.636 [INFO ] [openhab.event.ItemCommandEvent ] - Item 'RadiatorAC5_PID_commandItem' received command RESET
2022-11-09 08:26:44.954 [INFO ] [openhab.event.ItemCommandEvent ] - Item 'RadiatorAC5_PID_commandItem' received command RESET
as you can see AC5 is not responding to RESET, .state of the item is keeped “RESET” i need to send empty string ‘’ comand and then it works again:
Hi,
just finished my heating / cooling system based on PID and PWM automation. You can easily use it also to cooling system.
1/ Heat pump supports only Heating OR Cooling so there is only one switch to control all rooms/thermostats
2/ logic is based on PID rule (i am using js-scripting to write my rules, but you can easily adjust it. I am manipulating the dutycycle result based on a switch item which is ON or OFF (or doesn’t exist). If it’s ON - cooling, the dutycycle is negative
There’s an issue with the RESET command if the state is already in RESET when the rule is enabled. Then, there will be no ItemStateChangedEvent when the RESET command is sent and we’ll see the behavior you describe. You could work around it by sending NULL when enabling the rule or do it periodically.
Confgratulations on managing to implement a cooling system, too, looks good!
I’m sure I must be missing something, but I can’t find the CommandItem in the configuration which can be used for the RESET of the I (and D) part? I am running the latest official OpenHAB release 3.3.
Here is the configuration that is produced when I add a rule with the PID-Controller template.
I saw this doc from you.
but in the first quick reading my thought was that it is not for my use case, because I want to play a little bit with the pid controller in general.
I think that the pid controller can be used out of the box.
so define input item and output item and it works.
nearly it is so, but not for the output.
but thanks again for the hint with you documentation.
I will read it with more concentration.
maybe I will find the solution why I see no output in my side.
I just scrolled thru and I think I know what you are trying to do. I can’t remember it now but I think it wasn’t that simple because of underlying metric casting.
Spirit needed an Integer value 0 - 100 while PID provides Float as output.
When I was setting it up it wasn’t also possible to limit output to range so I was getting numbers like -356,28… What also wasn’t proper value for dimmer.
I think this is why I ended up with virtual items.
But tbh I can’t recall now.
If I see correctly, you linked the setpoint Item of the PID controller to the setpoint Channel of the device. The PID controller’s setpoint item needs to be an independent Item, not linked to anything, otherwise the system can behave weird.