HomeHome AutomationDIY Smart Heating v3.0

DIY Smart Heating v3.0

The third-year in service, the third time the charm?

Anyone looking for Smart Heating in 2021 is spoiled for choice, providing money isn’t an issue. My home has 30-year-old heating installed, but that didn’t stop me from adding “smart” component to it for less than $5. In 3 years time, I had a single instance of downtime (Raspberry Pi failure, fixed remotely within hours) and I couldn’t be happier! DIY Smart Heating enters 3rd year, it’s time to bring much-needed improvements.

From v1 to v3.0

Rome hasn’t been built in a day either. The basic idea of attaching a Sonoff Basic (oh, the pun) to a thermostat and making a $5 DIY Smart Heating system has expanded a lot since day one. I’ll be first to admit, that Sonoff Basic glued to a thermostat looks like IED or a tragedy waiting to happen. I will go around prettifying it soon, as my focus was fixed elsewhere. This is a software upgrade, so if you want to know how to wire your thermostat, please read the original article explaining in detail how I tackled the issue.

Due to the complexity of DIY Smart Heating 3.0, the entire project will be split into 3 parts. Don’t worry, following each part will result with a working heating system so you don’t have to stick around for the entire series or freeze your ass waiting for the next part to happen. As this is not a commercial project, I purge myself from whatever misdoings you may encounter. Be warned, or go to your local retailer to get a NEST or something if you don’t feel like my $5 contraption can do your thermostat the justice! 😁

The roadmap for DIY Smart Heating 3.0 includes:

  • New Dashboard
  • Redesigned underlying code
  • support for an unlimited number of rooms
  • dynamic display features
  • Alexa monitors the room that you are in
  • Alexa integration
  • Google Home integration
  • Tasker Integration ***
  • 1/12/24 today/yesterday filters
  • Extensive data collection (temperature, humidity, pressure, thermostat values, the weather outside)
  • historical data
  • InfluxDB integration
  • Grafana integration
  • PIR support with room scores **
  • Score-driven heating policies **
  • Slider based timers for each day of the week with individual temperature controls ***
  • Controls for individual radiators****
  • Possible Machine Learning based on room scores and historical data ****

** part 2
*** part 3
**** to do over the summer

As you can see the list of features is long, some are more challenging than others, but it was worth the work.

DIY Smart Heating 3.0

By far the biggest change in the system is the support for multiple temperature sensors. To manage the household effectively, Sonoff sent me 7 Temperature & Humidity sensors, which I connected to a Raspberry Pi 4 running NodeRED server with CC2531 ZigBee Coordinator. I also got 7 PIR sensors to manage the room occupancy score. I picked these in particular for a couple of reasons:

ZigBee protocol – Mesh connectivity and great battery performance of the protocol assures accurate data delivery and longevity of the individual nodes. Sensors are compatible with CC2531 coordinator, so I can retrieve the data to my NodeRED Server thanks to Zigbee2MQTT.

Battery – unlike other sensors I own, Sonoff ZB Temperature and Humidity sensor comes with CR2450 battery which comes with 620mAh capacity which is almost 3 times more than 210mAh of the CR2032. They should last much longer.

Price – for my system to work well, each room should be equipped with one sensor. Even for a 2 bedroom apartment, this adds up a significant cost. Sonoff sensors are one of the most budget-friendly.

Buy Sonoff Zigbee Sensors

Buy it using these links to support NotEnoughTech.

As the original design only featured one sensor (DHT11) attached to Sonoff Basic flashed with Tasmota, new sensors are connected to my ZigBee coordinator CC2531 – an inexpensive USB stick that plugs into your Raspberry Pi and reads the information over MQTT. If you want to know more about using ZigBee2MQTT I have you covered as well. This article explains how to add Sonoff sensors and manage your mesh, while this article deals with ZigBee2MQTT setup in general. I also have a project that manages battery levels in all ZigBee devices – you might find this useful.

Sonoff sensors don’t coms with a pressure sensor, but that’s not a big issue. I will show you how to use Weather API to pull environmental data and pitch it against the data from the sensors. Having a pressure sensor is mostly beneficial if your apartment is located on a high floor and API reads won’t be as accurate.

While on the subject of sensors, Sonoff PIR were picked for the same reasons. I’m also aware that despite the bigger battery than most of the competitors, the polling rate will be significant. I have a plan to address that. You should see it linked here (*when ready) as I will cover this in a separate article.

Room orientated controls

I shifted the focus from the dashboard to Alexa. Thanks to AlexaRemote v2 and the array of sensors I’m able to turn each room into a smart thermostat. Setting the heating with a voice command Alexa, set the heating to 19℃ automatically picks the sensor associated with the room you have issued the command in.

While I don’t have individual radiator valves yet, it brings a degree of controls that save money. DIY Smart Heating heats up the room that matters. It’s especially beneficial if the room that you are in, heats up the quickest.

Unfortunately, this is only supported via Alexa devices, and Google Home users have to refer to the improved dashboard where individual rooms can be selected with a single tap. It’s a problem I will try to resolve later with PIR sensors and some clever maths.

Data, data and more data

I really wanted to capture more data this year. I’m not doing this purely for the sake of charts that look nice to look at, but I’d like to feed this at some point to Machine Learning. Until then, there is nothing wrong with having a couple of charts stacking the most important values. To achieve this I used Grafana and InfluxDB as they work nicely together. I have a full write up on how to get it started with Grafana and InfluxDB – you should check it out.

Data is harvested by room and stored in the database. Recorded every minute, it provides a very granular look into how I use heating throughout the season. Apart from the room’s analytics, I store information about environmental changes and changes in my thermostat.

Responsive Dashboard

Changes also came to the dashboard. The main thermostat widget is the same, but it’s surrounded now with dynamic buttons that change the colour according to the room’s temperature. This is the groundwork for the control for individual rooms. Buttons contain the current temperature of the room and use the following colour scheme:

  • Red – room’s sensor is set as SetPoint target
  • Orange – room’s temperature is higher than SetPoint
  • Grey – room’s temperature is lower than SetPoint

Implementing this helps me a great deal. I can’t add the smart thermostatic valves just yet as the radiators need their valves replaces (and get drained in the process). It’s not an upgrade I’d like to perform in the winter. Once changed, I will add ZigBee controlled thermostat valves.

Moving on, we have standard controls for the thermostat with AWAY option and information pulled from Grafana. I really wanted to keep all my heating information on a single dashboard, so I embedded the graphs instead of launching Grafana dashboard.


Each room contains a history chart that is available in 3 variants: temperature, humidity and pressure. On top of that, you can change the time ranges: 12h, 24h, yesterday. today. It’s a quick way of checking on the rooms to make sure there are no issues with lingering humidity or opened windows.

There will be one more section of the dashboard that will add a weekly schedule for heating using cool sliders. It’s a WIP, but it will look cool when I’m done.

How to use DIY Smart Heating

I’ve done as much as I can to streamline the deployment process. You will need to change stuff here and there to make it work. There is no doubt, that with each iteration the code will change, but I will publish it all on GitHub so I can track my progress and try to address issues.


Please see the Setup tab in the function node. I would strongly recommend setting a default value to sampleLead = "Hall" this will be the name of the room you want to fall back to if something goes wrong.

Weather API

I poll my weather every 10 min. You will need an API from (a free account is enough) to get the information for your region. Note that my location coordinates and API key are set as a global variable. You can uncomment (uncomment it and fill in) the code in the setup tab of the Configure API URL node.


Each room should have a sensors mapped in your DIY Smart Heating. Sensors usually report every 30 sec and some of them send multiple messages so a limit node is added. For each temperature sensor create the switch node.

  • msg.room – name of the room
  • msg.temp – path of the temp readout
  • msg.humid – path of the humidity readout
  • msg.pressure – path of the pressure if supported (otherwise set to false)
  • msg.battery – battery info if supported
  • msg.link – range quality if supported
  • msg.grafana – url for an embedded public chart for your room (3 charts as JSON for H, P, T)

The code will handle everything and each room added to the flow later will get updated and posted to “rooms” flow variable.

Buttons Rooms

Each room added to the flow should have a button which takes {{room}} {{temp}}℃ as Label and {{background}} as background. Room sends true bool when pressed and the name of the room is set as Topic.

Function Lead Room Updates should have an equal number of outputs to the number of rooms and the outputs are assigned in order based on the order of the rooms in the "rooms" flow variable.

Room charts

Every room can display the chart for Temperature, Humidity and Pressure. These need to be manually composed. Charts are placed inside a table. To generate each chart you have to add a new cell and enter:

<iframe id="myFrame1" width="380px" height="300px" align="center"></iframe>        
		(function(scope) {            
			scope.$watch('msg', function(msg) {                
				var x = document.getElementById('myFrame1');
				x.setAttribute('src', msg.room2); 

Make sure that the values highlighted iterate. Modify the BuildTemplate adding try statement for each room:

try {
msg.room2 = data[1].payload;

} catch (error) {
  msg.room2 = null;

Repeat the process for each room and for each metrics.


You can set the default temp in the function Thermostat Defaults. Update the Build Template with URL for thermostat chart and inject nodes with URL from Grafana showing you hourly/daily and weekly use.

Alexa /Google Home

Yet again I’m entrusting my smart voice services to Alexa Home node, which deals with the thermostat is a very simple but efficient way. AlexaRemote v2 is here as well to intercept the device receiving the voice request and setting that room as one to track with my DIY Smart Heating. I’m using a regex match to capture set && heating commands, and Alexa Echo node to send an extra voice note back so Alexa notifies that it will keep the room that you are in warm.

Unfortunately, this behaviour isn’t exposed in Google Home, so there is only good old Nora integration for NodeRED. It works in cooperation with my system, displays the information from the lead room in the Google Home widget and you have the ability to adjust the settings.


Grafana charts can be composed to your satisfaction and embedded into Dashboard. The charts used in my heating are:

ThermostatSELECT mean(“targetTemp”) FROM “thermostat” WHERE (“location” = ‘thermostat’) AND $timeFilter GROUP BY time(1m) fill(previous)

SELECT mean(“ambientTemp”) FROM “thermostat” WHERE (“location” = ‘thermostat’) AND $timeFilter GROUP BY time(1m) fill(previous)
Weekly UseSELECT sum(“active”) FROM “autogen”.”thermostat” WHERE (“location” = ‘thermostat’) AND $timeFilter GROUP BY time(1h) fill(0)
Daily UseSELECT sum(“active”) FROM “autogen”.”thermostat” WHERE (“location” = ‘thermostat’) AND $timeFilter GROUP BY time(1h) fill(0)
Hourly useSELECT sum(“active”) FROM “autogen”.”thermostat” WHERE (“location” = ‘thermostat’) AND $timeFilter GROUP BY time(1h) fill(0)
Temperature per roomSELECT mean(“temp”) FROM “rooms” WHERE (“room” = ‘Office’) AND $timeFilter GROUP BY time(1m) fill(previous)

SELECT mean(“targetTemp”) FROM “thermostat” WHERE (“location” = ‘thermostat’) AND $timeFilter GROUP BY time(1m) fill(previous)

SELECT mean(“temp”) FROM “weather” WHERE (“location” = ‘outside’) AND $timeFilter GROUP BY time(5m) fill(previous)
Humidity per roomSELECT mean(“humidity”) FROM “rooms” WHERE (“room” = ‘Study’) AND $timeFilter GROUP BY time(1m) fill(previous)

SELECT mean(“humidity”) FROM “weather” WHERE (“location” = ‘outside’) AND $timeFilter GROUP BY time(1m) fill(previous)
Pressure per roomSELECT mean(“pressure”) FROM “rooms” WHERE (“room” = ‘Study’) AND $timeFilter GROUP BY time(1m) fill(previous)

Feel free to draw your own versions of each chart, customise the layout and colours. It’s your dashboard, make it personal. Just remember the quoted queries only work if you have the same data structure and names for your rooms.

Going further

It all works pretty well, especially if you are Alexa fan. Next up are PIR sensors. I want to use these to generate room scores (hourly) which will be used to offset temperature values or turn the heating on in the most appropriate rooms. It’s going to be challenging but, I can totally see this working alongside the current system until Machine Learning is deployed.

It’s not a secret that right now, the heating system doesn’t come with any timers. Ideally, you would never need these assuming my room score works, but I’m also working on a weekly schedule build with sliders. Netatmo has a very nice looking widget – to showcase what I’m going for. It’s going to be much simpler to use as my goal is to have it complimentary rather than mandatory.

Stage 4 or version 4.0 will become viable once the heating season is over. I need to drain the radiators, replace the old-fashioned valves with thermostatic ones, so I can add ZigBee based controls over individual radiators. Having the ability to pick the rooms you want to heat up, speeds up the process and keeps the heating costs lower. I have a detailed post about Moes ZigBee TRVs in here and how to auto-calibrate these.

Somewhere in between, I also need to invest in my ZigBee mesh a little more. I got 3 CC2530 ZigBee coordinators to build up the mesh, and handle the increasing number of devices. I have 11 radiators across the house – which would be paired with 11 PIR sensors and 11 temperature sensors. It’s a long way to go, but you can imagine how quickly the number of ZigBee clients would grow. CC2530 are more expensive than CC2531 but can handle more devices and have support for ZigBee 3.0. If you want to future-proof your mesh, you probably want to splash out and get something like CC2538 + CC2592 a workhorse capable of linking 100 devices.

At some point, I will also do something about the actual thermostat. It’s not presentable at all and it should have been done ages ago. I have no excuse especially since I do own a 3D printer and some fantastic looking terminals: M5Stack Core (review) and Wio Terminal (review) that could double as a thermostat and prettify the current device made of dreams, ideas and electrical tape.

Final thoughts

I had been running the current system for 3 weeks now. Other than small tweaks here and there it works pretty well as is. Even if you don’t want to add PIR sensors, or wait for the proper timers, the whole thing can be deployed right now and used as-is. If you want to take a look at Google Home integration – NORA works the best. You won’t have automatic room assignments like with Alexa devices, but you can always use custom commands to set these. If you have any questions feel free to ask them in this Reddit thread.

Project Download

Download project files here. Bear in mind that Patreon supporters have early access to project files and videos.


Nothing says "Thank you" better than keeping my coffee jar topped up!


Support me on Patreon and get an early access to tutorial files and videos.


Bitcoin (BTC)

Use this QR to keep me caffeinated with BTC: 1FwFqqh71mUTENcRe9q4s9AWFgoc8BA9ZU

Smart Ideas with

Automate your space in with these ecosystems and integrate it with other automation services


Learn NodeRED

NodeRED for beginners: 1. Why do you need a NodeRED server?

To server or not to server? That's a very silly question!

Best Automation Projects

Tuya SDK for beginners: Intro to Tuya Cloud API

Working with Tuya Cloud API. A guide to Cloud automation for beginners, get started with REST!

NEST your old thermostat under $5

Nest-ing up your older thermostat under $5

Nora – Google Assistant in NodeRED

Integrate Google Assistant with NodeRED thanks to Nora - NodeRED home automation

Sonoff Zigbee Bridge – review

Sonoff line up will soon include Sonoff Zigbee Bridge and more Zigbee sensors - here is the first look

DIY Smart Washing Machine – for about 15 bucks!

Learn how to add washing machine notifications to your Google Home on the cheap

Smart Home

I wish I had known about the SMLIGHT ZigBee/Thread Coordinators sooner!

SMLIGHT coordinators are the perfect choice for anyone just diving into ZigBee. SLZB-06 series is easy to use and comes with future-proofing Thread support.

Sonoff ZigBee Bridge U isn’t what you think!

I expected Sonoff ZB Bridge U to be a next gen ZigBee bridge with Matter support. Turns out, there is much more to talk about!

Aqara “Everything” M3 Hub

When I started my home automation adventure, the current problem was the number of ecosystems needed to outfit your smart home. Aqara M3 Hub has a long list of protocols to match that!

Sonoff ZB Micro did it! (and bonus ZigBee device)

A long time ago, I took an angle grinder to the humble Sonoff Micro, will I do this again? Meet Sonoff ZB Micro and Sonoff ZB Contact (SNZB-04P) - the latest devices from the ZigBee ecosystem.

This keyless entry is PRO: SwitchBot Lock Pro

SwitchBot Lock Pro offers comprehensive upgrades over the original, combining enhanced design, stronger performance, and a faster mechanism for keyless entry