HomeHome AutomationRetrofitting smart heating with Google Assistant & Alexa

Retrofitting smart heating with Google Assistant & Alexa

A year later the project finally comes with Google Home integration

The temperature dropped below 0°C for the first time today, so it is time to revisit my $5 Nest alike thermostat. For some time, I have been looking into integrating Google Assistant into the mix. After discovering gBridge, I can do it properly! Oh, Alexa users read on, as if you used my older project, this one has been redesigned.

Feel free to read on, but I have redesigned this project and an updated tutorial is available here: DIY Smart Heating.

EDIT 07/02/2020: gBridge is shutting down on 15th March, so please check this post for possible alternatives for Google Home.

Smart heating on the budget, a very tight budget

Not So Smart!

This project originally worked with Amazon Echo devices and NodeRED so I have not shared it with any Google communities. Let’s start with a short recap.

Features

  • Complete Google Home integration
  • Google Assistant integration
  • Web UI with Nest alike interface
  • Amazon Alexa compatible
  • Google Calendar support (coming soon)
  • Android Notification support (coming soon)
  • Tasker integration (coming soon)
  • A new thermostat box (coming soon)

My thermostat is 30 years old and comes without any features, the goal was to keep the thermostat operational and add the smart controls on the cheap. At the heart of the system, I have a sonoff basic ($4.99), flashed with Tasmota firmware, which has been coupled with DHT11 Temp & Humidity sensor ($1).

The details of how to wire it has been explained in the main post. So if you want to know the details, read the hardware section of that post. The sonoff works in parallel with thermostat, so you can actually use both at the same time should you encounter any issues.

I’m running a NodeRED server (You can run it on Raspberry Pi Zero ($5) which is responsible for processing all the data. As you can see you could put it all together for about $11!

What do you need?

To “smart-up” your old thermostat, you will need a couple of things:

In this write-up, I used the flow which enables Alexa and Google Assistant, but in the download section below, you will find versions for Alexa and Google Assistant only. Just pick the file you want to use in your setup.

Buy Sonoff Basic R3

Buy it using these links to support NotEnoughTech.

What has changed?

If you an Alexa user, you should update your flow too. Especially this one has been simplified, updated to NodeRED 1.0 and ready for future updates. It’s worth paying attention to this part so you would know what’s what.

NEST dashboard

Updating the original widget, needed 5 payloads. I have modified the template, so I can feed this just once. It will reduce the number of cycles needed, free the CPU a little and makes it easy to update.

The modified update node gathers all information and pushes it to the dashboard as one payload:

Function Node: Update
var targetTemp  = flow.get('TempTarget');
var ambientTemp = flow.get('TempAmbient');
var state = flow.get('heatingState');
var leaf = flow.get('leaf');
var hvac = flow.get('hvac');
var away = flow.get('away');
var heatswitch = flow.get('heatingSwitch');
var ecoLOW = flow.get('ecoLOW');
var ecoHIGH = flow.get('ecoHIGH');

// update the heating state

if(msg.topic === "update"){
if (ambientTemp < targetTemp){ flow.set('heatingState', "heating"); flow.set('heatingSwitch', "ON"); } if (ambientTemp >= targetTemp){
flow.set('heatingState', "off");
flow.set('heatingSwitch', "OFF");
}

// display the leaf
if (ambientTemp > ecoLOW && ambientTemp < ecoHIGH){ flow.set('leaf', true); } //away if (away === true){ flow.set('hvac', "off"); flow.set('heatingSwitch', "OFF"); flow.set('heatingState', "off"); flow.set('TempTarget', 6); } } //Alexa if (msg.command === "SetTargetTemperatureRequest") { flow.set('away', false); flow.set('TempTarget', msg.payload); } if (msg.command === "GetTemperatureReadingRequest"){} //slider if (msg.topic === "slider") { flow.set('away', false); flow.set('TempTarget', msg.payload); msg.topic = "setValues"; msg.ambient = ambientTemp; msg.target = targetTemp; msg.hvac = state; msg.leaf = leaf; msg.away = away; return msg; } msg.topic = "setValues"; msg.ambient = ambientTemp; msg.target = targetTemp; msg.hvac = state; msg.leaf = leaf; msg.away = away; return msg;

You notice, that I push all my data to flow variables. I can update these from different sources and I'm able to access the latest data set this way. It should reduce any issues.

Google Home & Google Assistant support

You will notice more MQTT nodes in this flow. This is because gBridge uses MQTT to integrate your devices with Google Home and Google Assistant. You can register a free account (up to 4 devices) and create a virtual device that uses ON|OFF and Temp Control traits.

  1. Update the target temp set by Google Home or Google Assistant
  2. Update the status of the heating from Google Home widget
  3. Update the status of the heating from Google Assistant voice command
  4. Pass state of the heating to Google Home (On|OFF)
  5. Update Google with the ambient humidity
  6. Update Google with the ambient temperature

You should read this post if you want to understand how these work, as some editing (topics) needs to be done! Changes made in Google Home app, or via voice commands will sync with Alexa and the Web GUI and the other way around.

The only quirk, for now, is the voice commands:

Turn "Heating" on         has no effect
Set "Heating" on|off      works

The rest of the commands like Set "Heating" to 20°C works without any issues.

Changes in Temp and Humidity updates

Google requires you to pass data as a float with a single decimal value. I needed to hunt the values around and make sure it's not passed as a string. I also used a function node to convert the value:

var humid = msg.payload.DHT11.Humidity;
 var x = humid.toFixed(1);
 flow.set('HumidAmbient',x );
 msg.payload = x;
 msg.topic = "Humidity";
 return msg;

var temp = msg.payload.DHT11.Temperature;
 var x = temp.toFixed(1);
 flow.set('TempAmbient',x );
 msg.payload = x;
 msg.topic = "Temperature";
 return msg;

var target = msg.target;
 var x = target.toFixed(1);
 msg.payload = x;
 return msg;
Sonoff controls

Lastly, I have duplicated the sonoff controller, as the payloads delivered by Google via gBridge are different. It was easier to set an extra output and duplicate the node than try to combine this.

Function Node

var defaultTemp = flow.get("defaultTemp");
//msg1 = OFF|ON
//Mmsg2 = off|heat
//coming frrom alexa
if (msg.command === "TurnOffRequest"){
flow.set("heatingState", "off");
flow.set('away', true);
var msg1 = { payload:"OFF" };
var msg2 = { payload:"off" };
return [msg1, msg2];
}
if (msg.command === "TurnOnRequest"){
flow.set('TempTarget', defaultTemp);
flow.set("heatingState", "heating");
flow.set('away', false);
msg1 = { payload:"ON" };
msg2 = { payload:"heat" };
return [msg1, msg2];
}
//coming from an update node
if (msg.topic === "update"){
var z = flow.get('heatingState');
if(z === "heating"){
msg1 = { payload: "ON"};
msg2 = { payload:"heat" };
return [msg1, msg2];
}
if(z === "off"){
msg1 = { payload: "OFF"};
msg2 = { payload:"off" };
return [msg1, msg2];
}
}

var defaultTemp = flow.get("defaultTemp");
//msg1 = OFF|ON
//Mmsg2 = off|heat
if (msg.payload === "off" || msg.payload === "0"){
msg.payload = "off";
flow.set('away', true);
flow.set('hvac', "off");
var msg1 = { payload:"OFF" };
var msg2 = { payload:"off" };
return [msg1, msg2];
}
if (msg.payload === "heat" || msg.payload === "1"){
flow.set('TempTarget', defaultTemp);
flow.set('away', false);
flow.set('hvac', "on");
var msg1 = { payload:"ON" };
var msg2 = { payload:"heat" };
return [msg1, msg2];
}
return msg;

Settings in NodeRED 1.0

NodeRed 1.0 comes with new features, so I wanted to streamline the way you set the parameters. In this case, there are 3 values you need to set:

  • default temp - preset temp value to set your thermostat when you say set "heating" on without temperature specified
  • ecoLow - define the low end of the temp where the "eco" leaf shows up
  • ecoHigh - define the low end of the temp where the "eco" leaf shows up

GUI

For now, I'm keeping the existing dashboard. You can access it via any web browser providing you can open up the 1880 port. I have added a 72h chart, just in case, you would like to see the heating trends. You can also include the target temp (add a unique topic msg.topic = "Target";) to trace the heating behaviours.

Note about hysteresis

This is a less self-balancing system. The temperature updates are sent every 5 minutes with a mean value taken from 15 readings. This and the fact that the radiators keep warm for some time after being turned off seems to be balancing system well and I have not noticed any issues.

I actually added a function node so you could check how often the heating is on:

var state = msg.hvac;
 if(state == "heating"){
    var x = 5; 
 }
 if(state === "off"){
     var x = 0; 
 }
 msg.payload = x;
 msg.topic = "Hysteresis";
 return msg;

If the system is on, the graph will draw a green line at the 5th position otherwise 0.

Things to come

It's a great opportunity to follow me on social media, as I will be adding extra features (including a much more pleasing to eye thermostat). If you want to time your thermostat, use Google Home and Alexa Routines for now, but soon you should be able to set a Google Calendar to control the heating patterns.

Android device will get a designated app and persistent notification controls so you could control the heating from the notification shade as well as fancy WebUI.

Lastly, there will be a proper (probably ESP32) based box with per room controls! Yes, I'm planning valve controls and per room temperature setting. Try this with your NEST!

Conclusion

I'm ready for the winter ahead. I have used this system for a year now and it has been great. I had a single failure (self-inflicted, issues with another project) which was resolved by an automatic reboot policy at 4 am (just in case) so whether you are in the Alexa team or Google Home you have now access to cheap as chips NEST alike thermostat.

If you are like me, you will also like the fact that this flow simply lets you use all 3 systems *(Amazon Echo, Google Home and NodeRED) and they all integrate well! Finally! If you have any questions about the project, leave it in this Reddit thread.

Project Download

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

PayPal

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

Patreon

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

image/svg+xml

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

client-image
client-image
client-image
client-image
client-image
client-image
client-image
client-image
client-image

Learn NodeRED

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

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

Best Automation Projects

Tuya SDK for beginners: Intro to Tuya Cloud API

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

NEST your old thermostat under $5

0
Nest-ing up your older thermostat under $5

Nora – Google Assistant in NodeRED

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

Sonoff Zigbee Bridge – review

0
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!

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

Smart Home

We’ve seen this before: SwitchBot K10+ PRO

0
This is an odd one. Building on the success of SwitchBot K10+ they released SwitchBot K10+ PRO - but is the experience actually better?

Is this the smart panel we have waited for?

0
ITEAD has released a new smart panel: Sonoff NSPanel Pro 120 - have they learned the lesson from the terrible launch of the original Pro? Let's see what's new.

Aqara FP1E detects motionless humans

0
This isn't exactly a new device, it's an interaction of the original Aqara presence sensor. Aqara FP1E brings Matter, ZigBee and new triggers to your smart home

SwitchBot S10: cleaning re-imagined!

0
SwitchBot S10 promises unattended vacuuming and mopping so you can focus on things you love and care for. Does it deliver?

Sonoff for households and gardens

0
ITEAD released two ZigBee devices to manage water in your household and gardens. Now you can monitor the flow and dispense water with Sonoff SWV and prevent water damage using the Sonoff Water Leak sensor with a twist.