[Custom component] Smart Autotune Thermostat

Hi,

We have created an OpenTherm Thermostat that works with an OpenTherm Gateway ( OTGW ). The operation is based on heating curve and an embedded autotuned PID controller ( automatic gains ).

Features

  • Multi-room temperature control with support for temperature synchronization for main climates
  • Adjustable heating curve coefficients to fine-tune your heating system
  • Target temperature step for adjusting the temperature in smaller increments
  • Presets for different modes such as Away, Sleep, Home, Comfort
  • Automatic gains for PID control
  • Overshoot protection to prevent the boiler from overshooting the setpoint
  • PWM and Automatic duty cycle
  • Climate valve offset to adjust the temperature reading for your climate valve
  • Sample time for PID control to fine-tune your system’s response time
  • DHW Setpoint control

Smart Autotune Thermostat

6 Likes

Thank you, has been working like a charm

1 Like

I would like to share some details about what is happening under the “hood” when SAT is working.
We intentionally wanted to keep this development as simple as it can be for the end-users. That’s why we worked really hard for the past 2 years to deliver an apparently simple OpenTherm thermostat. A LaPlace transform function ( Heat Curve ) delivers the optimal boiler flow temperature to keep the temperature on setpoint while a PID algorithm controls the internal temperature and adjusts accordingly the control setpoint.

Q: OK, but why you don’t let the users define their own PID gains?

A: When you try to tune at the same time the heating curve coefficient, kP, kI and kD it’s like trying to tune a 4-axis system. As a result, tuning the correct gains would be a painful procedure and time-consuming process, that’s why we designed the automatic gains. This development changes dynamically the gains based on the Heat curve algorithm output. This means that there isn’t any need to tune the PID gains and at the same time they are always perfectly tuned, even if you change the heat curve coefficient the PID gains stay well-tuned. This development can save a lot of time in tuning the system while we ensure the seamless heating operation.

Q: Why don’t use a typical PID controller?

A: A typical PID controller has 2 major flaws.
a) Integral windup. When you open a window then the controller needs some time to stabilize the integral and resume heating. SAT hasn’t that kind of issue because the heat curve value acts as a fast and low amplitude modulation of the integral value and the integral value as a low speed losses compensation. Given these circumstances SAT will resume its operation immediately.
b) No need to tune the kI value in different max boiler temperatures or various heating systems ( underfloor or radiators ).

Q: Why SAT acts as an ON/OFF thermostat and the control setpoint sent to the boiler is higher than the calculated control setpoint value?

A: Nowadays most modulating boilers are oversized because of heavy insulation on most homes. That leads the energy that is needed to heat a home, most of the times, to be lower than the minimum boiler capacity at 0% modulation. This led us to create the overshoot protection mechanism ( Low-Load Control ). SAT calculates the higher boiler water temperature when running at 0% modulation and then uses this value to calculate the ON and OFF times in a 15 minutes intervals while respects a minimum 3 minutes ON time in order to prevent wear to boiler. But in mild weather the 3 minutes ON time condition cannot be met, that’s why we created the automatic duty cycle and we extend the duty cycle while respecting the 3 minutes ON of the boiler. As a result of this sequence SAT sends the calculated Overshoot protection value as control setpoint, lower the max modulation to 0% and then manipulates the ON/OFF times.

Q: Are you going to let users use their own PID values for experimental purposes?

A: It is already an option in the new version that we are currently working. During the config flow the user can choose the manual tuning. But of course we discourage everyone to choose that path. We also intent to let the user out of the tuning process, because we are working on a new heating curve coefficient fuzzy tuner. When this development will be ready, SAT would become a completely autotuned controller.

Q: SAT overshoots/undershoots the room setpoint, what steps should I follow to correctly tune it?

A: If SAT undershoots use a higher heating curve coefficient value in the General tab until
the room temperature is equal to setpoint, if overshoots then use a lower heating curve coefficient.

Q: Is SAT only an OpenTherm Thermostat?

A: No, while our primary purpose is to control opentherm boilers through mqtt or serial connection, we also support ON/OFF boilers. Latest beta version supports during the config flow the configuration of an ON/OFF PID Thermostat. Moreover SAT is modular, so it can easily support more protocols ( EMS, modbus etc. ). If anyone interests to contribute, please contact with us.

Q: How many persons developed SAT?

A: Alex - Integration developer, George - Heating algorithm.

1 Like

thank you for this project. It looks like a tremendous amount of work that you guys have put in this. Before I start with this, I just want to double check to see if I’m the right audience for this. I have a boiler that supports opentherm. I have used opentherm ESP projects before to control the HW and DHW and climate and so on.
I have the DIYless Master opentherm shield (+ESP8266) to control the boiler. Can I use this hardware with SAT? And if so, which firmware would you recommend for the esp8266? tbh, I don’t know what’s what anymore because there are so many projects + forks on github that I don’t know which to use anymore.
What I want is to set a setpoint for the HW heating. I can then use a bunch of automations to automate whatever I want (set temp when user X is home between Y and Z and such)

Thank you for you kind words. Currently we support the OpenTherm Gateway from Nodo shop for serial connection and the OTGW-firmware esp8266 firmware for MQTT connection. We don’t own any master OpenTherm shield so we can’t support it at the moment. But since SAT is modular and if anyone want to create a new connection for this kind of shields we can happily accept PR’s and bring support to this shield. As I already mentioned in the previous post, SAT is a controller and theoretically is able to support multiple protocols or devices.

This is exactly what i was looking for (i think… :smile:). Compliments for this fantastic integration!

I use an on/off thermostat but due to the presence of otgw the heat pump expects steering and no longer applies its out of the box heat curve. Hope to use this integration to actively steer the heatpump based on a heat curve.

My setup is as follows:

  • elga ace hybrid heat pump with gas heating as back up (heat pump controls back up in case more economical and/or subject to certain thresholds)

  • otgw connected to heat pump, on/off relay (Homematic IP WHS2) connected to otgw

  • Homematic IP TRV on all radiators. Living room group with central thermostat is the main actor, other rooms can also request heat (if valve > 30%) and trigger the on/off relay

To get the most out of smart autotune do i need to make changes to the hardware setup? Do i need to disconnect the relay or can that remain in place?

Would you recommend to start with the main room or to directly implement an active multi room setup?

What i miss in the integration is support for a smart grid set up; concretely, increase the internal set point if electricity prices are low. My heatpump supports this with 2 open/close contacts.

Also two more questions, i am on the development version, where/how do i set up multi room? Cant find it based on the setup instructions on GitHub.

I seems to work for my main thermostat, what i am not sure about though is what i should expect to see:

  • heat curve sensor indicates 29.6
  • error value 0.7

Based on this i would expect to see a water temperature of no more than 29.6, however its over 35 with a return of over 31. Eg. I would expect the heatpump to modulate back but instead its increasing its heat generation.

These are the attributes of the climate entity

hvac_modes:
  - "off"
  - heat
min_temp: 7
max_temp: 35
target_temp_step: 0.5
preset_modes:
  - none
  - activity
  - away
  - home
  - sleep
  - comfort
current_temperature: 21
temperature: 21.5
hvac_action: heating
preset_mode: comfort
error: 0.5
integral: 0
derivative: -8.432
proportional: 24.337
history_size: 6
collected_errors: 2
integral_enabled: false
pre_custom_temperature: 19
pre_activity_temperature: null
derivative_enabled: true
derivative_raw: 0
current_kp: 48.675
current_ki: 0.000399
current_kd: 80240
rooms: {}
setpoint: 40
current_humidity: null
summer_simmer_index: null
summer_simmer_perception: Unknown
warming_up_data:
  error: 0.8
  started: 1913902.134285942
warming_up_derivative: 0.41
valves_open: true
heating_curve: 29.5
minimum_setpoint: 10
outside_temperature: 13.2
optimal_coefficient: null
coefficient_derivative: null
relative_modulation_enabled: true
pulse_width_modulation_enabled: false
pulse_width_modulation_state: idle
pulse_width_modulation_duty_cycle: null
friendly_name: Living Room
supported_features: 17

Hi Ronald,

I will try to answer your preliminary questions. I have to say that you are the first SAT user with OpenTherm heat pump, which makes us quite happy.

No, you don’t need to make any changes to your set up as long as you own a smart thermostat. You can keep your thermostat connected to the OTGW and work as back-up thermostat if HA fails for any reason. SAT has the ability to synchronise the SAT built-in thermostat with your main room thermostat.

I recommend to directly implement an active multiroom set up through config flow.

Since we don’t own a heat pump i think you can help us build this feature for heat pump users. We can talk about this feature on GitHub.

The multiroom set up can be achieved through the initial configuration of SAT. In config’s flow multiroom card, add as main thermostat your ( probably ) living room thermostat and in Rooms sections add the climate entities of your valves.

No, since the error value is 0.7 the calculated control setpoint is way above that. If the error comes to 0 then yes, 29.7 is the correct control setpoint. By thee time I am writing this post probably the error is closer to 0 and the control setpoint value is near or on heating curve value.

Question: Did you wait to finish the overshoot protection calculation during the config flow ( The last card which you have to wait at least 20 minutes )? Because I see a pretty low minimum setpoint value. If you didn’t wait to finish this calculation, please delete SAT and re-add it and perform this action. It is a crucial mechanism which affects the whole development.

Note: When you are calculating the Overshoot protection value you should have all your valves open 100% ( Use a very high setpoint e.g 28 °C).

1 Like

Thanks, will try this. Its already working, i see the set point moving down. I will set it up again though as i dont see multi room nor did i wait 20 minutes.

Do you mean i need to activate all radiators and the living room prior to installing the integration? And then when i am in the last step wait 20 minutes before closing off?

Curious to see if this works with a heatpump. Response time is very slow compared to a traditional Central Heating - lets see though! I have limited the set point to 38 from a hardware perspective, want to avoid an overshoot / inefficiënt heating. Whole idea is after all low and slow. Typically i would expect the heat curve for a heat pump therefore to be capped at the outcome based on outside temperature and the coëfficiënt - have an example url. In Dutch, looking at your GitHub thats not a problem i think? If it is, let me know! Will translate or find a different source:

In latest develop’s version config flow we have a dedicated card for multiroom installations. Also it very important to wait for the system calibration.

When you are about to start the calculation open all your valves.

You can set also your max boiler temperature in SAT integration → Configure → General → Maximum Setpoint

1 Like

To illustrate my earlier observation (also on git) the SAT pushes a too high control setpoint for a heatpump see below screenshots. Its clear that with an error of 0.2 the heatpump is pushed the max control set point of 38. Even though the heat curve suggests a much lower value.

Result is a peak in power consumption and a sudden drop to zero. Efficiency would be best served with a more gradual heating profile.


Note, the gradual power reduction on graph one is the built in modulation of the heat pump as the water temperature exceeds set point.

Thank you for your precious graphs! They helped us improve even more SAT operation. In the latest develop commit we added support for PID gains aggressiveness. You can change the value in SAT integration → Configure → General → Automatic gains value.

1 Like

Great, will try in the weekend!

Really cool project, first feedback from my prime stakeholders was positive (more comfortable and stable temperature)… until yesterday for some reason SAT instructed 0% max modulation which capped my heatpump at 200w electrical usage (20% of max) resulting in 3 angry women :smile:

Could not discover the trigger so disabled the integration restoring the peace.

My worst nightmare the past 2,5 years was 2 angry women, so I understand you. I know why the modulation stayed at 0% ( which is totally normal for some installations ). You tried to tweak the minimum_setpoint value and caused that inefficiency. That’s why we want to keep this calibration process out of the user :wink:. So I think you owe them an apology :joy:.

Edit:

Can you please post some graphs of this behavior?

I didnt tweak it but also calibration was not successfully completed so probably that is the reason.

I somehow lost history values when i disabled the integration. Sorry. Will try to install everything again tonight and try to replicate

If you remember the flow water temperature when your heat pump was working at 0% modulation, use this overshoot protection value. Otherwise run the overshoot protection calculation in config flow. Remember when you want to report an issue please add some graphs, as the previous report, because they are precious for us and will make us understand the heat pump behavior faster and better.

1 Like

Water temp was maintained at ca. 30c, return temp 27c.

If the machine works at the lowest modulation (i now see this was around 330watt electrical power) the actual generated power is much higher at an outside temp of 15c compared to 5c though - with that in mind , does your logic hold? This is after all inherently different from a gas fired boiler where the added energy is relatively stable irrespective of outside temperature.

@sergeantd83 what would you recommend in relation to automatic gains value? Standard is 5, is higher faster?