User Tools

This is an old revision of the document!


Smart Heating

Your home, most probably, has some kind of heating system for those months of the year when the outside temperature is too low to be comfortable. At least, in most of the world, every home has some kind of heating system. Of course, then, why don't we make it smart?

The goal of this smart heating is to warm up our home in a more efficient way, spend less money in doing so, and perhaps also help the environment along the way.

Let me describe my heating approach and how my home heating system is structured, so the following will be easier to understand. Please consider that this is a complex matter, and many of the issues i have encountered over the years can be different from your experience, because every heating system is different, and mine is indeed a bit unique.

My heating system

I live in an 100 years old house, built mostly out of solid bricks and river stones, almost 1 meter thick walls. It's a multi-stories independent home, with four sides open to the winter wind and chill. During summer time my house stays cool even with 35+°C outside, and while we have installed A/C in the upper floors, it's not really needed. On the other side this means that in winter time heating is important. I usually turn on my heating by the start of October and i turn it off be the start of May.

The house itself has radiators in every room, while floor heating is a trend now, i didn't installed it when i moved in for various reasons. My heating system is pretty complex because i have both a gas boiler and a wood pellet (=pellet) boiler. As it is customary in these cases, the gas boiler is directly installed on the radiators water circuit, while the pellet boiler has a dedicated water circuit and a copper heat exchange is in charge, coupled with a dedicated circulation pump, to heat the radiator water circuit and, well, circulate it when the gas boiler is off.

This solution is pretty complex and requires a lot of logic to function properly, i will add a schema soon.

  • When the gas boiler is on, it's internal pump will circulate the water in the radiators, and that's pretty simple.
  • When the pellet boiler is on, it will heat the water in the pellet water circuit, the heat exchange will in turn heat the water in the radiators circuit, and the dedicated circulation pump will circulate the water in the radiators.

In order for this to work, a water thermometer needs to be placed on the pipe coming out of the pellet boiler so that when the water is hot, the dedicated circulation pump can be turner on. This also requires relays to turn on and off power to the pump.

As things cannot be that easy, it's mandatory that both boiler are never on at the same time, as this would cause an over-temperature in the pellet boiler water circuit which in turn will shut down the boiler itself. And, lastly, the pellet boiler doesn't always turn on properly as for many reasons the startup phase might fail (bad pellet, burner filled up with sooth, defective ignition…) and in this case it's nice if after a reasonable timeout, if the pellet boiler fails to heat up the water, the gas boiler could be started automatically instead.

That's pretty complicated, eh.

Of course, there is yet a missing piece: unless you want to turn on and off the system yourself, it's nice to have some automation that can do that for us, and maybe be able to program it so it turns on early morning to warm up the house before you wake up.

First solution attempts

At first i went fully traditional. I placed an old fashioned thermostat (actually, two), run the wires from those to a nice set of switches that i manually switched to choose gas or pellet, plus a pretty complex approach with relays and such amenities to control the pump.

I quickly moved to a smarter self-made approach using an OrangePi Zero board with a few 12v relays, a 1wire igro-thermometer and wrote a custom dedicated software composed of a C++ backend and a Javascript frontend to replace most of the original solution. I kept the 220v relay to start the pump, and that's it. This brought a very nice improvement, since i was able to control and check my heating system from the web.

The smarter solution worked fine for a few years. I improved the software and the logic behind it a few times, until i discovered Home Assistant and ZigBee devices, now new amazing opportunities where available!

The smart solution

For a more efficient heating system, you need to be able to stop heating each room when it reaches the desired temperature. This will save you money on whatever fuel you are using (also solar, if you use heat pumps, more power for your accumulators or to resell), and will put less strain of your heat generators as well.

To achieve this solution, unless your house has already been equipped with a thermostat in every room (mine wasn't) and unless your heating system has every room separated with electro-valves (mine wasn't), ZigBee and Home Assistant will come to the rescue. ZigBee is an amazing wireless system that can connect many smart objects that can then be controlled via automation in Home Assistant.

I have replaced all (most, actually) of the valves of the radiators with ZigBee controller valves (so called thermostat valves), and added in each room a dedicated ZigBee thermometer in a logical place to measure effective temperature. In fact, the all-in-one thermostat-valves suffer from a common issue of having the thermometer too close to the radiator itself. While you can control this by setting an offset to the measurement, it doesn't work well specially when there is not a good airflow nearby, like when the radiator is behind a curtain or near furniture. The solution is to add a separate thermometer, then use a Home Assistant blueprint to automatically adapt the thermostat-valve offset.

Now i have Home Assistant, trough ZigBee thermostat-valves, which takes care of turning on and off the heating in each room independently. In addition, Home Assistant can also be used to define a schedule (under devices → helpers) that can be used to define times of the day / week when you want the heating to be on, or off.

By combining the schedule, and the overall status of ALL the thermostat-valves, Home Assistant is capable to generate a single output command: heat or stop heating. This signal can be used to control the gas and the pellet boilers.

The high-level concept then can be summarized as:

  • The heating schedule in Home Assistant defines when the heating should be on
  • Each thermostat-valve has it's offset corrected automatically using a dedicated thermometer trough a blueprint
  • This information can be collected and sent to the OrangePi Zero to actually control the heat generators.
  • The OrangePi Zero controls the generators turning them on or off depending on the Home Assistant conmmand.

In theory, by using dry-contact ZigBee relays i could skip the OrangePi, but implementing the logic behind to properly manage both generators, including the dedicated pump and the various emergency conditions is something i have not yet moved to Home Assistant, so i am still using the OrangePi with it's relays, i just simplified and rewrote the custom software backend.

Let's break down this approach step by step.

Selecting the ZigBee components

I am a big fan of Sonoff ZigBee devices. I own many and they are of top quality. Their thermo-valves (the TRVZB) works fine. The only complaint i have is the size, which is a bit large.

As thermometers, i have different models from different vendors. I tend to purchase the cheapest i find when i need them. The Sonoff one is nice and has a huge display, but they use a pretty strange battery, so i only purchased two then switched to a different vendor that uses the more common CR2032 battery. A single battery in geenral seems to last over one year.

Go ahead, install the thermo-valves, connect them all to Home Assistant as well as the thermometers. Remember to give them meaningful names!

Creating the schedule & main temperature set

Device → helpers → create a new schedule (TBD)

The heating control Blueprint

While it is indeed possible to write a custom automation script in Home Assistant, i did some research and found out an amazing Blueprint that already does what i need, and even so much more. It is the Advance Heating Control Blueprint. It is actually pretty complex and at first, it can be overwhelming.

You need to create an automation for each thermostat-valve and thermometer, which means one for each room:

  • Create a new automation from the blueprint
  • Assign the thermostat entity and the thermometer entity for the room
  • Assign the schedule
  • Setup both an “eco” and a “comfort” temperature (here you can use the temperature set defined in the previous step)

You can fine tune lots of details, i will not get too much specific, it's fun to explore by yourself.

At the end of the customization, you will have one automation based on this blueprint for each room of your house. This automation will automatically adjust the thermostat-valve offset to match the thermometer value and change the thermostat-valve threshold value depending on the time of day / week and the schedule, automatically switching between eco (=heating off) or comfort (=heating on) values. You can specify an external helper (the temperature set above) so that all your rooms can share the same temperature, or use room-specific value at your liking.

Commanding the generators

The basic logic is simple: whenever at least ONE thermo-valve is open (heating), the generators should be operative. Only when ALL the thermo-valves are closed (idle), then the generators can be turned off (actually the pellet is not turned on or off, but switched from minimum to modulation…).

The point now is how to connect Home Assistant with the OrangePi Zero… Well, using MQTT of course! So, setup your Mosquitto broker as defined in the link on Home Assistant.

I have rewritten the OrangePi Zero code to become an MQTT client and connect to the Home Assistant broker, this is pretty simple following the Mosquitto documentation and example code. In the future, i will post the code i am using.

So, let's assume we have the MQTT topic heating/consensus, which will be true if the generators shall produce heat, or false otherwise. You can use the following automation script to automatically publish the topic when the termostat-valves state change:

alias: Send Heating consensus to OrangePi Zero
description: publish topic
triggers:
  - trigger: state
    entity_id:
      - sensor.termo_livingroom_hvac_action
  - trigger: state
    entity_id:
      - sensor.termo_bathroom_hvac_action
  - trigger: state
    entity_id:
      - sensor.termo_bedroom_hvac_action
actions:
  - action: mqtt.publish
    data:
      payload: >-
        {{  is_state('sensor.termo_livingroom_hvac_action', 'heating') or 
        is_state('sensor.termo_bathroom_hvac_action', 'heating') or
        is_state('sensor.termo_bedroom_hvac_action', 'heating') }}
      topic: heating/consensus
      retain: true
mode: single

Of course you need to specify all the thermo-valves here. You should check under Developers → states exactly which states your thermostats use. Usually, it should be under the entity hvac_action of the thermostat, but you need to check as YMMV for different devices, maybe, i have no idea.

Future steps

Currently i have no way to choose whether to use gas or pellet from Home Assistant, this is something i will work on in the future. Currently the old program on the OrangePi Zero must be used to that extend, i know this is not optimal.

Maybe i could remove the OrangePi Zero altogether using some ZigBee relays, or maybe coupling ZigBee switches with the relays i have today. This would require to rewrite in Home Assistant the logic between switching the generators and the various protection logic.

I also need to publish my code for the backend and the frontend on the OrangePi Zero so you can check it out and copy if needed.

Smart thermostatic valves

Thermostatic valves are valves that will open or close the flow of hot water in your heating elements according to a set temperature. Smart thermostatic valves are exactly the same kind of valves, but in addition they can be controlled remotely. This means not only set the temperature, but also open and close them remotely.

This is pretty interesting, because one of the issues with this kind of valves is having the controlling thermostat inside the valve, which is located, of course, very close to the heating elements. This creates issues with airflow and pockets of heat that will falsify the readings of the valve itself. The best approach would be to place the thermometer on the opposite side of the room, and this is there home automation comes into play.

You will need to take care that:

  • The gas furnace is turned off when the pellet generator manifold is hot, or the pellet generator will not dissipate it's heat and will result in a forced shutoff.
  • The additional circulation pump is turned on when the pellet generator manifold is hot, or the hot water will not actually reach the rooms
  • The gas furnace is turned on if the pellet generator fails to start, which can happen sometimes

This website uses technical cookies only. No information is shared with anybody or used in any way but provide the website in your browser.

More information