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, here is a very simple schema of it all:

  • 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 boilers 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 pellet 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, ah.

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 controlled 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 command.

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 between 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.

The choice between heating with the gas or the pellet boiler, or both, is controlled by two dedicated Home Assistant toggles (create them from settings → devices → helpers):

  • use_pellet toggle: if true, pellet boiler is used, if false, gas boiler is used
  • quick heat toggle: if true, gas boiler will be turner on together with the pellet boiler. This is important because the pellet boiler will take up to one hour before it's startup phase is over and the hot water start circulating. Activating the gas boiler too will speed up initial warming of the house (the safety measures inside the OrangePi will take care to turn the gass off once the pellet is hot)

I choose to chain the toggles together with the thermostat-valves states to send the associated MQTT topic to the OrangePi so that all the topics will be published together. Better send the information twice, than forget about it once.

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: Invia consenso al Pithermo
description: Manda topic
triggers:
  - trigger: state
    entity_id:
      - sensor.termo_bathroom_hvac_action
  - trigger: state
    entity_id:
      - sensor.termo_kitchen_hvac_action
  - trigger: state
    entity_id:
      - sensor.termo_livingroom_hvac_action
  - trigger: state
    entity_id:
      - input_boolean.usa_pellet
  - trigger: state
    entity_id:
      - input_boolean.quick_heat
actions:
  - action: mqtt.publish
    data:
      payload: >-
        {{  is_state('sensor.termo_bathroom_hvac_action', 'heating') or 
        is_state('sensor.termo_kitchen_hvac_action', 'heating') or
        is_state('sensor.termo_livingroom_hvac_action', 'heating') }}
      topic: heating/feedback
      retain: true
  - action: mqtt.publish
    metadata: {}
    data:
      evaluate_payload: false
      qos: 0
      retain: false
      topic: heating/usegas
      payload: |-
        {{  is_state('input_boolean.use_pellet', 'off') or
        is_state('input_boolean.quick_heat', 'on') }}
  - action: mqtt.publish
    metadata: {}
    data:
      evaluate_payload: false
      qos: 0
      retain: false
      topic: heating/usepellet
      payload: "{{  is_state('input_boolean.use_pellet', 'on') }}"
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

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.

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