soloam / ha-pid-controller

PID Controller to Home Assistant
MIT License
105 stars 13 forks source link

Analog output instead of only PWM? #39

Open R5fan opened 1 year ago

R5fan commented 1 year ago

Im helping a friend who has a dumb heatpump with a terribly inaccurate thermostat. The absolute temp is off by several degrees and probably because it measures temp on the convectors, its hopeless at maintaining a steady room temp.

We can control the HVAC using a broadlink IR remote, and we can measure room temperature. By combining those we should be able to change the HVAC target temp in order to achieve an actual room target temp.

Im already using the smart IR integration to control the HVAC, which sets temps on the HVAC (by full degrees only unfortunately) and I created a dummy thermostat which contains the actual desired room temp. I made a fairly simple automation that adjusts the HVAC target based on the desired virtual thermostat temp and actual measured temp. Basically it measures the difference between desired and actual temp, say, 21C desired and 18C actual, difference is 3C difference, I add that difference to the HVAC target temp, so it will be set to 24C. As the room approaches target temp, the hvac target temp is gradually reduced.

This works, but of course, its very limited, you still get significant temperature swings.

The correct way to do (beside modding the hvac) this is a PID loop. Ive tried a few PID integrations, including this one, but so far Ive only seen ones that are designed to control a "binary" heater, turn it on or off using PWM modulation. Im not sure how I can apply this to my situation, turning the HVAC on/off to achieve a temperature is far from ideal when it has an ability to more gradually adjust.

I think I need a PID controller that gives me an "analog" signal, a control input strength, that I can use to calculate a temperature offset. So when the room is at 20.5C, the longer it is at that temp, the stronger this signal would become so eventually the HVAC is put at a higher temp to achieve 21C.

Any suggestions how I do this?

martin3000 commented 10 months ago

https://pypi.org/project/PID-Py/