Skip to content

House Model

Jan Brandsma edited this page Dec 4, 2026 · 1 revision

House model

ZenMaster treats the house as a heat buffer. A heat pump for space heating (consumer type heating_heat_pump) is planned inside the linear program (LP) of the planner: every quarter of an hour the plan decides how many kW the heat pump draws, and a thermal model of the house says what that does to the room temperature. Heat bought when power is cheap is stored in the air and the building, so the expensive quarters can do with less.

Two heat stores

The house is modelled as two stores, both in kWh per °C:

Store Symbol Default Meaning
Air Ci 8.0 kWh/°C the room air and what warms up with it quickly; this is what the room sensor measures
Building mass Cm 12.5 kWh/°C walls, floors and furniture; it has no sensor
Coupling Him 2.4 kW/°C how fast heat flows between air and mass

The heat pump heats the air, the air warms the mass, and the air loses heat to the outside. Per quarter (0.25 h) the LP holds two heat balances, all in kW of heat:

Ci * dTi = COP * P_useful + Him * (Tm - Ti) + g * sun + Q_int - (UA + w * wind) * (Ti - T_out)
Cm * dTm = Him * (Ti - Tm)
  • UA is the heat loss coefficient (kW per °C of indoor minus outdoor temperature), default 0.2.
  • w is the extra loss per m/s of wind, from the wind forecast.
  • g * sun is the solar gain. When solar meters are configured, sun is the expected solar production; otherwise it is the global irradiance (W/m²) of the weather forecast.
  • Q_int is the internal gain (people, appliances), default 0.4 kW.
  • T_out is the outdoor temperature forecast.

Because the mass has no sensor, ZenMaster keeps its own estimate: every run it moves the mass towards the measured room temperature at the rate Him / Cm per hour, and the plan starts from there. The first quarter of the air store is pinned to the live room temperature.

flowchart LR
    HP[Heat pump<br/>COP x P] --> AIR[Air store Ci]
    SUN[Sun and internal gains] --> AIR
    AIR <-->|Him| MASS[Building mass Cm]
    AIR -->|UA + w x wind| OUT[Outdoor air]
Loading

COP model

The COP (coefficient of performance: kW of heat per kW of electricity) is computed for every quarter from the outdoor forecast and the room floor of that quarter:

carnot = (T_in + 283.15) / max(1, T_in - T_out + 15)
COP = clamp(0.39 * carnot * (1 - defrost), 1.5, 6.0)

This is the Carnot limit between a condenser 10 K above the room and an evaporator 5 K below the outdoor air, at 39 % of that limit. The lift is at least 1 K, so mild weather hits the cap of 6.0 instead of dividing by zero. The defrost share is the part of the heat the defrost cycles cost, per outdoor band:

Outdoor temperature Defrost share
below -3 °C 5.2 %
-3 to 0 °C 6.4 %
0 to 3 °C 5.5 %
3 to 6 °C 4.5 %
6 to 9 °C 4.8 %
9 °C and up 4.6 %

The knee

A heat pump is most efficient at low output. Above 0.6 kW of electrical power, each extra kW gives only 64 % of the heat the COP promises. In the LP an auxiliary column holds the power above the knee, and the useful power is P - 0.36 * max(0, P - 0.6). The calibration uses the same rule, so plan and fit agree.

Comfort

The house has a setpoint, like a thermostat. It comes from a linked setpoint_entity (the target temperature of a climate entity, otherwise the entity state) or else from the setpoint number on the ZenMaster device (default 19.5 °C). The floors and the ceiling follow it:

Time of day Floor Default offset
07:00 to 17:00 day floor: setpoint minus day_drop 1.0 K
17:00 to 23:00 the setpoint itself (the evening) 0 K
23:00 to 07:00 night floor: setpoint minus night_drop 1.5 K

The hour is taken from the real clock, also across a daylight saving change. The ceiling is the setpoint plus headroom (default 1.0 K).

All of these are soft: the plan may cross them at a price.

  • Below the floor of the quarter: 50 EUR per °C per quarter.
  • Above the ceiling: the same 50 EUR per °C per quarter, so cheap power does not overheat the house. There is no hard ceiling, because without a cooling path a hard ceiling makes the LP infeasible in summer.
  • Below the setpoint: 0.0125 EUR per °C per quarter, so the plan only dips under the setpoint when that saves more.

The only hard limit is the floor at 3 °C under the setpoint. If the room is already outside the band, the bounds start at the live temperature, so the LP stays solvable while it climbs back.

From plan to heat pump

The raw LP plan is post-processed before anything is sent:

  1. Smoothing. Each quarter becomes the mean of itself and the two quarters after it, but never more than 25 % off its own plan. A quarter that is slightly cheaper does not make the heat pump jump.
  2. Minimum power. The heat pump runs from 0.6 kW. A quarter planned below that is saved up until the savings reach 0.6 kW, and then runs at 0.6 kW.
  3. Minimum run. A run lasts at least two quarters: a run shorter than half an hour loses most of its heat to the start. The savings carry over from one quarter to the next.

The plan is shown in steps of 0.1 kW.

Sending the setpoint

The value of the current quarter is written to control_entity, a number (number.set_value) or a climate (climate.set_temperature). The control setting picks what is written:

Control Value
power planned kW (times 1000 if the entity is in W)
capacity 100 * kW / max_power in %
delta the room temperature the plan reaches by the end of the quarter, minus the floor of the quarter (0 when the quarter does not run)
temperature (default) the floor plus that delta

The value is rounded to the entity's step (step, target_temp_step, or 0.5) and clamped to its minimum and maximum. It is written every quarter, also when unchanged, because a heat pump falls back to its own heating curve without it. When the device comes back after a restart, it gets the value of the current quarter at once.

Weekly calibration

On start and every 7 days, fit_house fits the house from the last 365 days of hourly mean statistics in the Recorder: heat pump power, room temperature, and any solar meters. The outdoor temperature, global irradiance and wind of the same hours come from the Open-Meteo archive API for the configured location. If that request fails, the current parameters stay.

Preparation. The standby draw (the median of all hours under 0.1 kW) is taken off, because fans and control give no heat. The heat per hour is COP * useful power, with the COP model and the knee from above. Solar comes from the meter with the longest history, scaled by what the other meters add in the hours they all report. Only whole days with 24 hours and a reading at the start of the next day are used; the room change of a day runs from its first hour to the first hour of the next.

Which day gives what:

Days Condition Gives
Cold daily mean outdoor below 12 °C sun gain g, internal gain Q_int, total capacity C = Ci + Cm
Cloudy cold, mean irradiance below 40 W/m², heat above 0.2 kW heat loss UA and wind loss w

At least 40 cloudy days are needed. On warm days the heat pump cannot deliver negative heat, so their balance says nothing. The loss is fitted first on the cloudy days, so it is not mixed up with the sun; the sun, internal gain and capacity then follow by least squares from what the loss asked for that the heat pump did not give, on all cold days.

Air share from cooldowns. In the first hour after the heat pump stops at night, only the air cools noticeably, at UA / Ci of the indoor minus outdoor difference. ZenMaster collects these hours (irradiance 0, room more than 5 °C above outdoor, heat pump on the hour before, off this hour and the next) and sets Ci = UA / median(drop). Then Cm = C - Ci and the coupling is chosen so the air hands its heat to the mass in about 2 hours: Him = Ci * Cm / (C * 2).

Plausibility. The fit is rejected, and the old parameters kept, when there are fewer than 10 cooldown hours, when Ci is not between 0 and C, or when the wind loss, sun gain or internal gain comes out negative. An accepted fit is saved and a new plan is solved at once.

In the code: custom_components/zenmaster/solver/heating.py, custom_components/zenmaster/coordinator.py

Clone this wiki locally