Thermostat with PID controller

  target_temp_step: 0.1
  precision: 0.1
  noiseband: 0.2
  keep_alive:
    seconds: 120
  kp: 15
  ki: 0.0001
  kd: 6000
  ke: 2
  pwm: 00:31:01
1 Like

Never mind - got it. I should use the climate integration. It has the necessary service calls to set the temperature and the preset.

Hi Alex
I am trying to use it with belimo actuator to and 3 way mixing valve, hoping to be able to attach a thermostat on the out pipe and be able to control the actuator to provide set output temperature - will it work for that?

I think that is a proportional valve and you would like to to position it anywhere between fully open and closed? You could take from the thermostat the attribute with the pwm signal and use it for control.

But for more detail you better can ask @adrien.b

When setting up autotune, what ruler should I use? I’ve no idea of what values I should use for the PID so I want to let autotune run so I have a starting point

You can use ziegler-nichols, it’s a standard one. But I would rather recommend to manually measure the oscillation of the temperature with PID off and compute the coefficients by yourself, the method is described here : Autotune feature usage. · Discussion #21 · ScratMan/HASmartThermostat · GitHub

Hi,

I computed myself and get this: kp=0,489709 ki=0.0020362 kd= 78.5166763 but always overshooting So something wrong. Yosc: 1,3 and Tosc about: 9620 (“no-overshoot” 100, 40, 60)


Last year I use with that what you give: kp=64 ki=0.007 kd=2000 This is better but still overshoot.
Don’t know how to fine tuning it.


Tryed autotuning but after one day no result from it, so it isn’t working for me.
Can you help me? Why it is so different what I computed and what you give?

(use ke=0.6) maybe turn outdoor temperature off?

You should monitor the control_output with pid_p, pid_i, pid_d and pid_e by using sensor templates to get them from thermostat’s attributes. This will help finding which one is triggering the heating. As control_output = pid_p + pid_i + pid_d + pid_e, the biggest one will easily activate the heating, and it’s gain could be reduced.

Looking at your curves, Kp seems too low Vs Kd.

Hi I’m novice in HA nd trying to setup smart thermostat to control heaters. My question is how to control tow diferent devices (heaters) by one thermostat? Heaters are MQTT Number devices, that resieves number 0-100. Hard solution is to re-communicate electric heaters so that they wil be one device, but first I want to try to do it in HA settings

If the devices can receive 0/100 values, you may try to set pwm: 0

It will directly set the output of the PID to the device.
You may then create a group with your two devices and use the group as heater entity. This would apply the output to both.

Can this adapt its’ pid settings depending on outside temperature or the room temperature reducing quicker than usual?
because I suspect that a pid configuration for a room that gets cold quicker than usual will cause more overshoot than one that was configured while the room gets cold at the usual rate.

edit: looks like you’d have to do that yourself

Can one set it up to only predictively stop heating without pulsing? I fear that the switches’ sound will annoy me if it’s pulsing. And I don’t know any solid state relay switches

I have a couple questions about this setup:

I have a home with 6 zones, electric resistance heaters in each room.

Currently using the generic thermostat integration with Shelly Plus 1s, and a crap load of the Mi temp/humidity sensors.

I have the large kitchen/living room area which is heated with two Shelly plus 1 devices and 4 sensors setup in groups (sensor group is averaging).

In each of the other zones, it’s 1 Shelly plus 1 and 2 sensors in an averaging group.

Currently the system over shoots by a whole 1°F and I have the current tolerance set to half a degree.

Would this integration be appropriate for my hardware? I worry about switching on and off the Shelly devices too often.

Would this integration potentially save me money in electric/heating costs?

No a pid controller per se won’t save you any money. It might be able to keep the temperature in a tighter range if you tune it properly. What might save you money is using only the P component, and allowing the room temperature to vary - then keeping it comfortable using the fireplace or a heat pump.

Could you please explain how you managed to get all these values in such a graph?

Hi, could you please explain, how you made these graphs?

Using ApexCharts-card

Hi @adrien.b would you mind point into right values for thermostat working in cooling mode?
Just installed esphome controlled stepper motors for my duct HVAC so now I can open them in 1% steps - 0-100%. Having xiaomi BLE sensors installed as well as aqara zigbee sensors so I can get average for each room based on two sensors from different places. My goal is to get HVAC to cool rooms per user needs so kids rooms - normal temp let’s say 21.5 deg C overnight, non used rooms minimum cooling just to keep temp below 23 degC during heat wave or have duct closed if less and bedroom slightly colder 20.8 degC. This kind of multizone termostat should be possible yes?
What you advise - go every room step by step to get kp ki kd or do everything at once or maybe there’s universal set point to start which can be adjusted further or fine tunned by adding outdoor sensor temp?
The hard part of this is that once you close 4 of 5 ducts you’ve got more airflow coming to that room you’re trying to tune - PID should handle that but it’ll take time to get right values? As airflow in my typical scenario will be - coldest room 30%, kids 2 x 25%, non important 2 x 10%.


hvac_modes:
  - cool
  - 'off'
min_temp: 19
max_temp: 25
target_temp_step: 0.1
preset_modes:
  - none
  - away
  - comfort
  - sleep
current_temperature: 21.9
temperature: 21.9
hvac_action: idle
preset_mode: none
away_temp: 14
eco_temp: null
boost_temp: null
comfort_temp: 22
home_temp: null
sleep_temp: 20.8
activity_temp: null
control_output: -11.3
kp: 350
ki: 0.01
kd: 0
ke: 0.6
pid_mode: auto
pid_i: -0.8
pid_p: -10.5
pid_d: 0
pid_e: 0
pid_dt: 77.49026250839233
friendly_name: biuro termostat
supported_features: 17

Hello,
at the begginig - thanks for such an amazing project.

I have 4 rooms connected to HVAC via a throttle that can be switched ON or OFF. I want to measure PID parameters with autotune, but I don’t get how can I measure and set keep_alive and pwm.

To be honest I can do it manually (as described by @adrien.b ), instead of autotune - I just need to set appropiate parameters to get that nice, regular-shaped curve.

Any help would be appriciated.

Best regards,
Jakub

Please help me, how can I see the actual values ​​of pid_p, pid_e, pid_dt, pid_i, what should I do for this?

1 Like

Yes, I (also) only see pid_i not the other values!
Other people in here can read them and make nice graphics, but whatever config i use, i just don’t get them.

image