Thermostat with PID controller

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

Did you add the debug: true setting in yaml ?

Hmmm… that was too simple… Thanks!

Hi,
First thank you for the integration. I have been using it for a year now.
I tried to start my thermostats a few days ago, as the temp dropped enough, however they are not working properly now. I have not changed anything since last winter, so I thought let’s check if there is an update, as I have been updating HA. After the update nothing changed. The thermostats change to heating every now and then, but not long enough to heat the room to target temp. I decided to modify the PID values just to try, but no luck. The weird thing is, that the control output is 100%, but the thermostat stays on idle. Do you have any idea, why this could happened?

It looks the problem is not related to the PID controller. It looks, that the relay I am using to switch the heater pump switches itself off after a few seconds. I am investigating now.

HI all, just a quick question as i just started to play with this amazing thermostat:

I started with a pwm of 30 mins and PID factors of 5, 0.01 and 500, got this:

I have a floor heating, the “rising” part seems ok but not the “falling”, as it is useless to turn the heating on for a few minutes, the valves alone take 2mins to be fully switched on. So first of all i doubled the PWM period (maybe i’ll try even more), and also multiplied by 10 the integral factor, does this make sense?

Now i’m wating to see the effect of the configuration i’m writing below, but in the meantime i was wondering something of what i see now in debug:

Configuration:

 - platform: smart_thermostat
    name: Termostato Cameretta
    unique_id: termostato_cameretta
    heater: switch.riscaldamento_cameretta
    target_sensor: sensor.thp_cameretta_temperatura
    min_temp: 10
    max_temp: 26
    target_temp_step: 0.1 
    ac_mode: False
    away_temp: 18
    cold_tolerance: 0
    precision: 0.1
    keep_alive:
      seconds: 60    

    kp: 5
    ki: 0.1
    kd: 500
    
    debug: true
    sampling_period: 00:10:00
    pwm: 1:00:00

Debug:

hvac_modes:
  - heat
  - 'off'
min_temp: 10
max_temp: 26
target_temp_step: 0.1
preset_modes:
  - none
  - away
current_temperature: 20
temperature: 21.5
hvac_action: idle
preset_mode: none
away_temp: 18
eco_temp: null
boost_temp: null
comfort_temp: null
home_temp: null
sleep_temp: null
activity_temp: null
control_output: 26.6
kp: 5
ki: 0.01
kd: 500
ke: 0
pid_mode: auto
pid_i: 19.3
pid_p: 7.4
pid_d: -0.1
pid_e: 0
pid_dt: 600.0040857791901
friendly_name: Termostato Cameretta
supported_features: 17

If my total output is 26%, with a pwm of 1h, why is the heater off? Shouldn’t it turn the heater on for 26 minutes?

Also, a theoretical question: If i set the sampling period to be 10 minutes, this means that the control output will be updated every 10 minutes, right? So if the control output still generates, as an example, an output of 26mins, does this mean that the heater will be turned on for another 26 minutes?

Any suggestion on the tuning is appreciated. Thanks!

Hi!
How long does autotune take? Mine has been started for over 3 days (for 6 zones at the same time) and I have no results in any of them. What must happen for the algorithm to return any result?

[So far, there have only been two/three heating phases. The house is well insulated and the heating is underfloor water with very high inertia and after such slow heating, the heat stays practically all day long.]

I am not an expert, but your graph looks OK to me considering you’re only controlling the heating. Maybe the heater could be tuned to rise faster but floors are sized to heat slowly and retain that heat. If you want the room temp to drop faster, you’ll need AC as well.

Hello, I am new to this topic, and want to setup a PID control for my floor heating. It uses a gas boiler to heat concrete floor.
I tried some variants but it seems to be harder than expected.
I was thinking for the beginning to just start with Kp and the rest of parameters commented of.
kp: 70

What would be a appropriate value to start from?
Also I want to display on a graph the control output but I can’t find it as an entity.

Your curves are good, you may add more D to get more anticipation and reduce overshoot and undershoot.
However, it’s not recommended using daily schedule to decrease the setpoint overnight on a floor heating. The inertia makes the system much too slow and the energy required to heat up in the morning will compensate the benefits durin the night.