In the ever-evolving landscape of smart home technology, one aspect that has garnered significant attention and transformative advancements is the realm of heating control systems. As we strive for efficiency, sustainability, and personalized comfort in our living spaces, the traditional thermostat is making way for intelligent, adaptable solutions that promise a revolution in how we experience warmth within our homes.

Gone are the days of simple on/off switches and manual temperature adjustments; today’s heating control systems leverage cutting-edge technologies, data analytics, and automation to create a seamless and customized heating experience. From optimizing energy consumption to providing real-time insights into usage patterns, these systems are not merely about keeping us warm but about enhancing our overall quality of life.

This article delves into the customization of heating control systems, exploring the latest innovations, the impact on energy efficiency, and the unparalleled comfort and convenience they bring to modern homes. Understand the intersection of technology and warmth as we uncover the features, benefits, and future trends of these intelligent systems designed to redefine how we manage and enjoy the heating in our homes.

The system under investigation

The system under investigation involves two connected heating sources. Both the sources are connected to a main puffer which stores thermal energy ready to give it to the radiators or to the sanitary hot water. The main source is the solar system, driven by their proprietary control unit which will be updated in the following. Since we cannot control the sun, we also need a gas boiler. Moreover, a thermal fireplace will be added in the following months as a third source.

This energy is needed to heat the sanitary water as well as three floors with different subdivisions in rooms and environments. To control and visualize the thermal state of the home a front-end dashboard is built using Home Assistant since it is well integrated with other IoT devices. Behind that, several actors play pivotal roles in both software and hardware backends.

Home Assistant allows us to easily build a graphical interface that can be shared across different devices and for connections from outside the local network. Moreover, it is an open software that allows you to build your DIY integration, custom plugins, and several other features. All these aspects will be fundamental to completing the entire system without spending weeks writing code but rather focusing on the control logic.

The project

As mentioned before, several main characters are playing a pivotal role:

  • Fireplace (now it is present, but it wasn’t when I started this project)
  • Gas boiler
  • Puffer
  • Solar panels
  • Radiators
  • Pump and electrical valve
  • A lot of sensors, as you can read here.

This project started several years ago with the idea of improving the solar panel control unit by integrating weather, water consumption and seasonal thresholding. It remained mostly an idea while I was investigating some options for smart monitoring the state of the involved characters with ad hoc sensors. Until I discovered Home Assistant and everything changed.

HA allowed me to build an entire control system with nearly zero code. There is still some coding but it is mostly done at a high level and we can call it nearly zero code if compared to manually writing in C++ firmware for several microcontrollers to manage all the involved devices. In addition, it allows the integration of all the other IoT devices available in the home network.

Wall mounted tablet with Kiosk browser showing Home Assistant dashboard for rooms temperature
Home Assistant mobile application in dark mode showing temperature for rooms and thermal system


Despite having built several sensors to monitor whatever I need, there are still some needs. I decided to rely, as much as I could, on the Tasmota firmware. It allowed me to quickly put together temperature sensors, like the well-known DSB1820, actuator, for instance, a standard relais module, and communication with the HA server.


By using several WemosD1 mini or NodeMCU Esp8266, loaded with the Tasmota firmware, the system can hold a lot of temperature sensors and output signals. In particular the different devices allows for the following splitting:

  • WemosD1 N1 reads 8 DSB1820 temperature sensors for the boiler monitoring
  • WemosD1 N2 reads 8 DSB1820 temperature sensors for the thermal fireplace monitoring
  • WemosD1 N3 reads a MAX31865 with a custom Tasmot firmware to read a PT1000 sensor
  • ESP8266 N1 controls 4 relais to manage electrical floor valves for radiators
  • ESP8266 N2 controls 4 other relais

I used the ESP8266 board to control relais because they have more pins than the Wemos mini and allow me to use 4 output and also 4 input channels directly linked to the relays. This allows me to maintain a backup control line to manually debug the relay state.

In addition, I also use some of these inputs as state monitors to control whether external entities are active or not. For instance, I can read information from the thermal fireplace proprietary control unit.

Temperature sensors

Similarly, I used the DS18B20 digital temperature sensors. It is a digital sensor based on the 1-wire protocol. It allows me to put several sensors together on the same physical line, connected with a self-made RJ45 connector, using a single channel with a single pull-up resistor. Moreover, it also has a pretty linear response in the range of temperature of interest (more or less between 10 and 90 °C).

DS18B20 schema
DS18B20 typical error curve

Well I use this sensor to monitor several entities, the main ones are:

  • Boiler outlet
  • Radiators main lines (inlet/return) for each floor
  • Puffer state and inlet/return
  • Thermal fireplace inlet/outlet, internal puffer and case
  • Indoor/outdoor enviroment
  • Main water inlet
  • Recirculation water temperature
Each pipe (as normally should be) has been covered with foam insulation to minimize the heat dispersion and maximize the temperature sensor reading.

Flow sensor

Another very interesting sensor is the Hall Effect Water Sensor. Avoiding too many details, it contains a Hall component that starts rotating due to the water flow. It returns a signal with a variable frequency proportional to the water flow. By reding it it is possible to detect the current flow as well as post-processing several quantities, like water consumption or device states.

There isn’t a direct compatibility with the Tasmota firmware but I adapted this code to work with my BF-Y5 water sensor. The code runs on a Wemos D1 min in a custom 3D printed enclosure to separate the electrical sensor from water presence.

Tasmota Scripts

As you may know, we can compute the volume as the time integral of the flow, or due to the discrete data, with a right sum of the flow multiplied by the sample duration:

V_W=\int_{t_0}^t\phi_w(t) \Longrightarrow V_W=\sum_n (t_n-t_{n-1})\phi(t_n)

I’m using the right sum because HA doesn’t update the sensor state if it doesn’t change. So using a non-constant time delta allows for more accurate results.

Tap water flow in more or less 10 minutes. The graph shows the flow signal (blue) with its smoothing computed with a moving average and the volume (green) computed as the flow integral.

This is only a 10-minute signal but all HA sensors work 24/7 such to continuously collect data. In the end, we can summarize this information for each day, week or month.

1" Hall flow sensor.
Radar chart for hot/cold water consumption [kL] across several months. There is a slight anomaly in July due to renovation works.
Averaged daily water consumption [L].

Pump monitor

As mentioned in a previous article, I built my own 220V ac triac detector to measure the percentage of activity for triac-modulate motors. It is based on the detection of the phase-cut to reconstruct the ratio between on-time and off-time and compute the current power. This also allows for the intersection of the variable pump curve with the system curve such to detect the current flow for all the cases we can't use the flow sensor. For instance, for very hot water that would require a non-plastic sensor which is not easy to find.

Isolation transformer, diodes bridge and signal reading with WemosD1 mini
Custom 3D printed support for the integration with the main control unit

Solar system pump modulated by a triac controller.

Home Assistant

Once we built all the sensors we need it is possible to collect all data inside the Home Assistant server. In particular, it allows creating dashboards to visualize, manage and interact with all the entities. Here, we talk about entities from a more general point of view by extending the definition to a general virtual device. In fact, it can represent not only a sensor but also a combination of sensors, a post-processing quantity, an automation or more complex combination of them.

I described the general principles behind it in a previous article. Besides creating a very nice representation, it is more important the coding aspect behind it. In fact, it is possible to use the HA core to run code, from very simple logic to more complex interactions between devices, states, and computation.

General overview of the house


I'm going to show some logic that I implemented in HA but they are easily implementable in any other software/language. Automation plays a crucial role in optimizing control units for thermal systems due to several key reasons. Firstly, automation enables precise and timely adjustments in response to fluctuating environmental conditions, ensuring efficient energy utilization and maintaining desired temperatures within the system. Secondly, they enhance operational reliability by reducing human error and ensuring consistent performance, thereby extending the lifespan of equipment and minimizing downtime. Additionally, automation facilitates real-time monitoring and data analysis, allowing for predictive maintenance and proactive intervention to prevent potential issues before they escalate. Overall, setting up several automations is indispensable for achieving optimal performance, energy efficiency, and reliability in thermal system control units.


The first, very basic and far from the definition of "logic", is the implementation of a thermostat. It basically turn on the output when the measured temperature go behind a threshold. Then, it turn off the output when the temperature goes below the target. One could use an If/Else logic in the Automation tab but it easier to build a custom generic-thermostat card.

And here comes the first help of HA. By using a user-friendly language, named as YAML, it is possibile to built all the thermostat logic by adding the following lines:

  - platform: generic_thermostat
    name: Name
    heater: switch.study_heater
    target_sensor: sensor.study_temperature

You only need to markup the heater and the target_sensor with the corresponding entities. If you want to be cool, you can specify also maximum and minimum temperature limits, tolerances, add different heaters/coolers/fan, set preset for comfort-cold-hot temperatures and precisions.

It is easy to understand how this is not only important for indoor comfort but can also be used for the management of the technical system.


For instance, let's pick a classic puffer. They are very common in a thermal system since they are used to store hot water in order to store thermal energy. Then, different devices can require this hot water to use this energy. For instance to heat other environments (like radiators) or other water (like sanitary hot water). Of course, it needs other players to heat the water using energy from other sources like gas, current or sun.

To control the water temperature a basic thermostat logic works fine, by relating the output with a command able to turn on the source. To be more practical with an example, we only need a smart relay linked to the HA thermostat heater field such to close the gas boiler switch and activate it.

Starting from this simple logic we can build several automation to perfectly integrate different sources. Moreover, we can add external control to adapt the system toward the future wheater changes or to what people, inside the house, use to do. For instance, we can adapt the puffer heating to the water consumption such as to estimate if they need or not hot water for showers.

Solar heating

The most important player for the puffer heating in this particular system is the sun. It is the most powerful source and it is virtually free. However, it may not be always available. So during the night or on cloudy day we may need to switch to other sources.

flowchart LR
id0[Puffer] -->id1{DT solar panel>th} -->id2((Pump on))
id0 --> id3{ T below th }-->id4((Thermostat active))-->id5{Fireplace on?}-->|yes|id6((Inibith boiler))-->id7
id5-->|no|id7((Pump on))-->id8[Boiler on]

However, this simple control logic requires integration with the other players like the floor/room thermostats for environment comfort or physical actuators able to move the hot water from one path to another, like the electronic valves. So you can imagine this system as boiler-centric where all the involved states decide if we need or not to turn on the gas boiler.

flowchart LR
id1[HEAT]-.->id2{Fireplace on?}-->|yes|id3[Inibith boiler]-.->id4([Pump on])
id2-->|no|id5([Boiler on])-->id4
id6{Radiators need?}-->|yes|id8[EV1 ON]-->id10[EV1]
id7{Puffer needs?}-->|yes|id9[EV1 OFF]-->id10[EV1] 
id10-->id11{EV1 on?}-->id1
id17[(Puffer)] --> id14{DT solar panel>th} -->id7
id17 --> id15{T below th?}-->id16((Thermostat active))-->id7

Digital twin

In order to understand how to interact with this system you need to think that not only does the state of the puffer/floor/room affect the gas boiler or the pump, but it leads to changes to the state itself. Once the pump is on, the hot water starts to flow inside the radiators and this will affect the original state.

flowchart LR
id1[HEAT]-.->id2{Fireplace on?}-->|yes|id3[Inibith boiler]-.->id4([Pump on])
id2-->|no|id5([Boiler on])-->id4
id6{Radiators need?}-->|yes|id8[EV1 ON]-->id10[EV1]
id7{Puffer needs?}-->|yes|id9[EV1 OFF]-->id10[EV1] 
id10-->id11{EV1 on?}-->id1
id17[(Puffer)] --> id14{DT solar panel>th} -->id7
id17 --> id15{T below th?}-->id16((Thermostat active))-->id7
id20((smart extra control))-->id6

By accounting for outdoor temperature, original temperature, water inlet and return temperature, people inside the room and other players we can build a smart model able to predict the optimal heating temperature and the ideal pump on duration. So we can maximize comfort while still maintaining the optimal energy saving. Therefore HA represents a digital twin of the house and the thermal system. You can read more on the digital twin here.

Mobile HA client to visualize the thermal system state

It is possible to set a temperature threshold sufficiently high to satisfy needs for each season. In this case, the puffer needs to store hot water only to heat sanitary water flowing into the heat exchanger. Assuming a good efficiency of the heat exchanger, the always-good threshold is around 65-70°C.

Weather integration

Using this pre-defined threshold, despite being very smart from the point of view of the technician who installs the system by modifying a single parameter, is absolutely not optimal for energy saving. Basically during the summer time you can set a lower threshold because you need less hot water than during the winter for several reasons. The usage of hot water is clearly reduced as well as the thermal dispersion across the whole plant. In the end, also with a lower threshold, there is the same thermal comfort when you use hot water from the tap/shower.

Well, and during the winter? You need a threshold near the 65°C at least, however, the lower you stay the better it is. A lower threshold is better not only for the gas boiler that needs less energy, but reduces the thermal dispersion also. In fact, since the puffer contains water hotter than the enviroment this heat is mainly lost if you don't use it. The thermal balance tells us the thermal power:


It depends on the convection coefficient c that is related to the exchange surface and involved material that you can imagine to be limited to the non-insulated pipe, and on the temperature difference. Since the environment temperature Te is fixed, you can only limit the dispersion by reducing the puffer temperature Thot.

Data analysis

By observing the following chart, obtained from real monitored temperature, you can see how the dispersion is mainly related to the nighttime for two reasons: the usage of hot sanitary water is limited and there isn't the sun which generally provides extra heat during the day, thanks to the thermal power.

Puffer temperature and threshold in three days. It is possible to note the decrease during the night or the usage of water (Water ON). The temperature increases if the boiler is used (Boiler ON) or during the day due to sun heat (Pump ON).

In fact, to minimize the loss I reduce the threshold during the night. This allows me to heat the whole puffer only if someone really needs hot water. However, there is also a lower limit to that action. You need to avoid leaving it cooling to much, otherwise, it would be self-defeating since the boiler needs to heat water from a very low temperature, requiring a lot of energy.

To find the optimal value I also introduced the forecast. Then I can set different night thresholds based on the expected sun of the following day. In fact, by 9 AM the sun starts to strongly interact with the thermal solar panel to heat the puffer. In addition to that, all these variations are modulated by the season since the outdoor temperature changes.

Energy consumption for hot water production from different thermal sources from July to February.

Data analysis

Store and analyze data is paramount for optimizing control in systems equipped with multiple sensors. By harnessing data from diverse sensors, analysis enables a comprehensive understanding of the system's dynamics and operational parameters. Through sophisticated algorithms and statistical techniques, data analysis uncovers patterns, trends, and anomalies, empowering controllers to make informed decisions in real time.

Furthermore, data analysis facilitates predictive modeling and condition monitoring, allowing preemptive adjustments to prevent failures or inefficiencies. Ultimately, data analysis not only enhances system performance and efficiency but also lays the foundation for continuous improvement and adaptation to changing environmental conditions or user requirements.

This HA server manages more than 1500 virtual sensors to supervise not only the thermal system but also the energy consumption, lights and home appliances, computers and printers and much more. Due to HA limitations, it only stores data for 2 weeks. However, I added an external database to store data forever without limitation and other software for graphics visualization with a custom dashboard. In particular, Grafana and InfluxDB provide powerful functionalities to Home Assistant, enhancing its capabilities for data visualization and time-series database management.

Grafana and InfluxDB

InfluxDB serves as a robust storage solution, efficiently managing sensor data and other time-stamped information generated within Home Assistant. Meanwhile, Grafana offers a user-friendly interface for creating customizable dashboards, enabling users to visualize and analyze data from InfluxDB in real-time. Together, they empower users to gain deeper insights into their home automation system's performance, trends, and patterns, facilitating informed decision-making and optimization of smart home functionalities.

InfluxDB uses a query language called InfluxQL or Flux (depending on the version) for retrieving and manipulating data. Users can write queries to select specific data points, filter based on tags or time ranges, aggregate data, perform mathematical calculations, and more. Queries typically involve specifying the measurement, fields, tags, time range, and any additional conditions or functions required. InfluxDB processes these queries against its time-series database and returns the results based on the specified criteria.

from(bucket: "smart_home")
  |> range(start: v.timeRangeStart, stop: v.timeRangeStop)
  |> filter(fn: (r) => r["entity_id"] == "temperature_puffer_up" or r["entity_id"] == "soglia_t_desiderata_boiler")
  |> filter(fn: (r) => r["_field"] == "value")
  |> aggregateWindow(every: v.windowPeriod, fn: mean, createEmpty: false)
  |> yield(name: "mean")

The integration between InfluxDB and Grafana enables seamless communication between the time-series database and the visualization platform. Grafana connects to InfluxDB as a data source, allowing users to pull data from InfluxDB and create dynamic, interactive dashboards for visualization and analysis.

With this integration, users can query data stored in InfluxDB directly from Grafana. This allows for creating custom dashboards with various visualization options like graphs, gauges, and tables. In addition, it is possible to utilize advanced features of Grafana, such as annotations, alerts, and templating, to enhance dashboard functionality.

Typical Graphana dashboards collection

Overall, the integration between InfluxDB and Grafana provides a powerful toolset for visualizing and analyzing time-series data, enabling users to effectively monitor and manage their systems.

Energy managment

In conclusion, the investigated heating system presents a comprehensive approach to energy management, utilizing multiple sources to efficiently cater to the diverse heating needs of a multi-level space. By integrating solar power, gas, and soon a thermal fireplace, the system demonstrates adaptability and resilience in meeting heating demands.

The implementation of a front-end dashboard using Home Assistant not only facilitates real-time monitoring but also enhances user interaction and control over the system. This integration with IoT devices streamlines operations and provides a seamless experience for homeowners.

Furthermore, the flexibility offered by Home Assistant, with its open-source nature and customizable features, significantly reduces development time and effort, allowing focus to remain on refining control logic rather than tedious coding tasks.

As advancements continue, with plans for updates to the proprietary control unit and the addition of a thermal fireplace, the system is poised to further optimize energy efficiency and user comfort. Overall, this investigation underscores the importance of integrated approaches in modern heating systems, emphasizing efficiency, adaptability, and user-centric design.