Thermostat with PID controller

Interesting, when your set point rises, the PID_P remains almost flat : if you do large set point variations, you need bigger kp to react fast. I would say multiply P, let’s set it to 70.
Your PID_I is increasing quite fast, with larger kp it will increase the overshoot, I would recommend to decrease ki to 0.004.
And PID_D is totally flat while your temperature takes 0.5°C in 3 hours with 50% output. Let’s boost that kd to 50000 to see how it behaves.
Use the set_pid_gain service to set the values, so that you don’t need to restart HA.

1 Like

I am fine with reboot, but I will use service in the future. I set them accordingly, will monitor tomorrow. Thank you for having patience with me.

Kp: 70
Ki: 0.004
Kd: 50000

I assume that this tuning would be unique for each zone if I decide to convert other generic thermostats? Or I could apply same settings to others as well? Because so far, I am still catching up and do not quite understand what has influence on things.

1 Like

The gains depends on the heating system (type, power…), the volume of the room and the insulation of the house.
So as far it’s in the same house with same heating source and the room volume is similar, the settings should just match.

You’ll find in the readme on GitHub some useful links explaining how a PID is working.

Hi. Removing the force_pid_refresh fixed the “on” time problem. I don’t know about the set temperature reverting to 22. Thanks!

Regarding the new service in latest beta (set_pid_mode), by turning off PID the thermostat behaves like a generic thermostat, how can the “cold_tolerance” and “hot_tolerance” parameters be set? I don’t see any equivalent in smart_thermostat.

HI,

I’m really interested in implementing this, however I have some questions before I begin.

My current situation:

Downstairs our heating is done by pellet stoves so the gas heater is only used for the 2 bedrooms upstairs and occasionally some extra rooms when they are in use.
All rooms have a temperature sensor and a virtual thermostat.
The 2 bedrooms have zigbee TRV’s.
When there’s heating required a relay switch is opened to trigger the gas heater to turn on. The heater will choose the temperature based on an outside sensor.
The 2 TRV’s in the bedrooms will switch to 30° (open) when the room’s thermostat is on heating and they will switch to 5° (closed) when the target temperature has been reached. This with a delay of 10min as the heater pump will stay on that long after the off signal has been sent (can’t change that)

The issues:
Overshooting by more than 1° every time there’s a heat request.
TRV’s aren’t really dependable. Sometimes they don’t open/close when they’re supposed to resulting in a cold room while the heater is running for 2h.

Questions:

  • I understand the modulation part, but how does it work with multiple rooms? When modulating different rooms, the heater will be working more (unless the multiple thermostats will talk to eachother) and the rooms will be too hot? Or am I wrong?
  • Is it still necessary to use the TRV’s or do I just limit the flow with normal thermostatic valves?

Obviously more questions will come up when I start implementing it.

All tips are welcome to get me started as I’m fairly new to this.

Thanks in advance!

@adrien.b I did not have time to post yesterday, but here is the result for past 2 days. Friday wasn’t great example day, as there was a lot of sun and heat gains from it. I still get overshoot of 0,5 degree though.

image

@kimme1024 building anything reliable on unreliable valves is a challenge. I would focus first on getting those either fixed or replaced.
As for the multi-zone and demand for heat, the way I do it is that actual “heater” in smart thermostat config is the valve(s) I want to open/close for zone. I use 220V valves, they open/close within ~2 minutes.
Outside of thermostats, I have automation that checks every minute if there is heat demand. If yes, it will turn on boiler. I also have a fail safe - my boiler relay is fibaro that I configured for auto-off in 15 minutes. So as long as it gets signal every time to open, it won’t stop. it it does not get signal (my zwave will break or anything), it will auto turn-off in 15 minutes. I also need to say that I have daikin heatpump, meaning when I set boiler signal to “on”, it doesn’t actually mean it will start heating in a minute. There is some process behind, run pump, check in/out water temperatures to determine if it needs to start heating, etc., so you might do something similar for yourself, depending on your heat source.

@stomko : the system is heating while temperature is increasing, you should double the kd to benefit from the inertia.

@kimme1024 : you should keep the valves, as mentioned by Stomko, try to make them more reliable (maybe Zwave TRVs could be more reliable network wise).
If you change with classic mechanical TRVs the thermostat may trigger the heater while the TRV remains closed, definitely not a good option.
The smart thermostat can be used in such multizone system, you’ll need one Smart Thermostat entity (so one sensor and one relay/trv as heater per zone), and do a logical “or” to enable the relay controlling the stove or boiler based on the need of each thermostat.

with kd set to 100000, system was heating today when temperature was already above set limit, and also heating a bit in the evening:

image

It integrates too much, so your I part is too high and not compensated by the P and D parts, so it continues to heat.

Change with -20% on ki, clear the integral using the corresponding service, and add +10% on both kp and kd.

Did that in precise order

Kp: 77
Ki: 0.0032
Kd: 110000

Last 2 days, I am getting again even bigger overshoot, with heating even when temperature is already reached
image

Hi, your pid_i is still larger than pid_p and pid_d, so it will give positive output and heat. You should increase kp so that pid_p reaches at least 75%, and increase kd by the same amount.

Means increase Kp from current 77 by how much (%)? And same percentual increase on Kd (currently 110000)?

Try with Kp: 100, and double the Kd, as the pid_d looks very low. You should also use the sampling_period to a few minutes to filter the very fast spikes on the temperature sensor.

OK, I will try with:

  kp : 100
  ki : 0.0032
  kd : 220000
  sampling_period: 00:10:00

When looking at the P, I and D curves with set point steps, the integral should be quite stable, P should have the biggest amplitude, and D should progressively cancel the P when P is decreasing.

My curves:
Please note I’m using an alpha version taking outdoor temperature as an additional input, to compute E = Ke * (set_point - outdoor_temp), and output = P + I + D + E
In the end the integral is reduced and seems more stable as the thermal losses of the building are compensated by E.

1 Like

It surprises me that that E component of yours isn’t standard stuff. It seems so obvious.

What do you mean by not standard ?

I am back, with last 2 days. I don’t know what am I doing wrong, or should I just count as the fact that it will be like that. I still get overshoot of 0,5 degree. Before, that overshoot was even larger, so what I adjusted as recommended above resulted in not heating when over set point, but overshoot is still there.
Ignore those shifts in set temp, that was just me trying things.

image

@nilux definitely not a standard. I used Danfoss heating control before, that did not know about outside temperature at all. But my heat pump knows, and adjusts leaving water temperature based on outside temperature.

1 Like

I’m using also a PID thermostat but a different one ( multizone) in combination with low temperature floor heating and can confirm it is tricky in achieving a constant temperature. At my place some sunlight or heat from making dinner can already give a 0.5 degree change.

Could you give it a try with a constant setpoint for a few days. You’re rise and drop might be amplified by the setpoint changes between 21.5 and 22.