Predictive Heating and Cooling control

Due the low flow temperature required for UFH I use a thermostat to control heat pump. However the floor is 100mm thick concrete with UFH pipes and the thermal lag is pretty huge. Everything is single zone so CoP is good, but always think I am using more energy than needed. From ASHP starting it runs for many hours to get hours back to temperature. So house temp yoyos a little - not excessively but think I can stop it.

So have been working on a predictive control via home assistant on/off for quite a while.

Idea is the normal thermostat control will remain in place as a fall back and the predictive system will sit on top of it. If internet goes off, normal service of the thermostat remains, so nothing major lost.

The way I have designed it, is use basic sensors with a little additional logic applied.

So use a weather forecast sensor to make an average temp over the next 24 hrs, this is used as a rolling average.

Use a temperature sensor connected to home assistant to measure hall temperature. But have connected it to another template sensor that predicts likely temp in one hour. This is then fed into a statistics template looks at minimum temperature 4 hrs ahead. So now I have a likely house temp in 4 hrs time. This gives a basis for decisions. To make it suitable for our heating we have a further sensor, that looks at the average outside temp for the next 24 hrs and only if below 10 degs it reads the correct value, all other times it reads a static temperature of 21 degs. This is then used as the sensor within a generic thermostat.

The generic thermostat hysterisis is set to start ASHP 0.05 degs below target temp and stop heating or cooling -0.03 below target.

An image showing house temp and heat pump running. As house starts to cool it continues, starts to cool at 8pm and ASHP starts around 8am. House temperature continues to fall for a further 3 hrs, before recovering. At around 2pm the heat pump stops. But house continues to be heated, some of that maybe solar gain, but most is overshoot. The changes should start the heat pump 4 hrs early, but also stop when predictions thinks the house will be hot enough in 4 hrs time. This can be manipulated via the start and stop setting within the generic thermostat.

I also have a forecast-based UFH cooling offset. It looks something like:

Target = 21 - (Indoor - 20) + (18 - Outdoor_3h_Forecast) * 0.4 - (UV_Forecast* 0.1)

Instinctively feels right, and 90% of the time it’s ‘good enough’ - I basically asked AI to generate a formula that takes into account these factors. I did think of rolling average like you did to avoid swings (e.g. if it’s gonna be super hot for 1h then cool again, I’ll just ride it out) but the variation in temp between my top/ground floor is bigger than any better temp targeting I’ll get by spending more time testing this formula.

Similar idea to yours, but I only do it for cooling.

One thing I’d suggest is having multiple sensors scattered around instead of one hall temp. I’ve had all kinds of outliers - powercut restarting a sensor (that causes a drop to zero then a spike), faulty or disconnected Thread sensor/hub, someone coming out the shower…

Good point about multiple sensors, may also add a time out on the Shelly so no signal for X hours switch the Shelly output off. Just incase of an internet outage and the Shelly stops playing ball.

Have also added EcoEdge AI to Home Assistant to learn the house and how it responds to changes in outside temp etc.

Been going down an AI rabbit hole. Built a regression model of the house based on last heating season, this gives a variable output to a generic thermostat.

To sit over this, currently modelling a solar and climate look ahead to make a decision on if it’s actually a good time heat based on Cosy cheap/expensive periods and what likely to happen temperature and solar wise. So this should say it’s zero currently, but is likely to be sunny and 10 degs later, so maybe add some heat but don’t do a full heat, conversely it’s not going to be sunny and stays cold heat now.

Must have too much time in my hands!

Decided after all to use a system I already had with home assistant - Predbat, enabled Predheat, used the work AI had done to put meaningful numbers in for the house and set it going. Will be able to monitor how it manages over the next few weeks before heating season. Predheat is a monitoring only, but made a template sensor to drive a generic thermostat, based on 1h, 2h and 8h predictions for internal temp.

{% set indoor = states(‘sensor.sleepieshill_lounge_temperature’) | float(19.6) %}
{% set h1 = states(‘predheat.internal_temp_h1’) | float(indoor) %}
{% set h2 = states(‘predheat.internal_temp_h2’) | float(indoor) %}
{% set h8 = states(‘predheat.internal_temp_h8’) | float(indoor) %}
{% set heating = is_state(‘binary_sensor.sleepieshill_pump’, ‘on’) %}

{# Hard safety override #}
{% if indoor < 19.2 %}
19.50

{# Heating is running: use +1h to decide whether to stop #}
{% elif heating %}
{% if h1 > 19.65 %}
19.70
{% else %}
19.50
{% endif %}

{# Heating is off: use +2h and +8h to decide whether to start #}
{% else %}
{% set future_min = [h2, h8] | min %}

{% if future_min < 19.55 %}
19.50
{% else %}
19.70
{% endif %}
{% endif %}

So basically the the thermostat is set for 19.6 degs and the sensor gives a slightly higher or lower temperature to the thermostat than is real. We use the 2h and 8h predictions to decide if heat is actually going to needed and the 1h prediction to see if we have added enough heat to the floor. So now in monitor and modify mode. If all looks good will add some further logic to heat within Cosy periods if suitable

Snap shot of the predictions

After going down a bit of a rabbit hole have settled on a pretty simple system. Settled on heating only for now predictions.

Predheat does the indoor predictions at 1h, 2h and 8h. Some analysis shows it doesn’t model solar gains, which is ok. Most of our current heating was done at night, so costs the most as CoP is likely worse than day time as temperatures are colder. Got AI to look at previous history from home assistant and it seems the afternoon 8h prediction are pretty accurate, the morning prediction not very accurate if you get any solar gains it can be miles out.

Historically unless super cold a single multi-hour charge of heat into the floor lasts all day.

So we now just look at the 8h prediction from 1pm to 4pm and if the house looks like it will need heat we start the heat pump and run until the 8h prediction says we are hot enough. Another layer is used with the 2h prediction 24/7 to see if we need heat missed by the 8h prediction. It also adds a to not letting the floor deplete its energy too much and gives the ASHP an easier life. We use a “keep alive signal” to the Shelly relay to switch off if internet or home assistance stops. A bog standard thermostat is used as fall back.

How about 0.02°C precision? :smiling_face_with_sunglasses:


Pretty good - UFH/radiators? Are you using anything special or something else?

First guess, gas boiler, PID thermostat with radiators?

Yes, gas boiler + k3 radiators + open source thermostat (SAT - smart autotune thermsotat)

Looks good, unfortunately no use with low temperature thick screed floor, as response time is glacial. Tried similar when I had a gas boiler and had about 5 degs house temp variation with massive under and overshoot.

Think the solution now in place is pretty simple, HA generic Thermostat, and a simple helper that looks at the below

Look at next 24h outdoor average
If above 10°C heating off or equal to or below heating can be on.

Select prediction either +2 hours or +8 hours based on time of day, from Predheat at 1pm to 8pm use +8 hour, any other time use +2 hour.

Set desired house temperature on generic thermostat, the HA helper modifies actual house temp in line with either the 2 or 8 hour prediction - generic thermostat compares
virtual temp against its dial, either selects heating on or off.