Dumb home automation

The internet of things is becoming common place, with a lot of people putting “smart” devices from google or apple in their homes to allow voice control of media systems, heating and lighting. Most of them also allow you to control these devices from a phone app when you are away from home.However there are a growing number of concerns with these devices:

  • Are they secure?
  • What are they doing with my personal information?
  • What happens if the company providing them goes out of business or decides to stop supporting them?

In this post, I’m going to go into some details about my own dumb home projects which avoid using the most popular products on the market and instead opt for less well known devices to try and solve the concerns above.

The basics

When I started planning my home automation project, I did quite a bit of research into what was available on the market, I wanted something like a nest thermostat but which was more open so that it could be easily combined with other products from different companies as I expanded the automation system. I also wanted to avoid vendor lock in and dependence on someone else’s systems, this was quite important - I didn’t want to get into a situation that I couldn’t turn my heating on if the internet connection was down.

There are a couple of competing standards for open home automation protocols the main three that I looked at when starting out were Smart Things, Zigbee and Z-Wave, all of them had in common the fact that each device you installed would communicate back to a base station and only the base station itself would need to be connected to your network. This helps to check off one box: security; with only the controller directly accessible, you reduce the attack surface for anyone who is up to no good.

I fairly quickly eliminated Smart Things from consideration; it seemed to be the least open of the standards and had fewer devices available and although it had a fairly slick and polished interface the killer issue was the fact that each device in a Smart Things network requires a direct connection to the hub, in my quite large house this would limit where I could place the hub and devices it would alsoreduce battery life on the devices which were in range as they’d have to transmit at a higher power.

Both Zigbee and Z-Wave solve this problem by forming a mesh network: devices on the edges of the network can send and receive packets via a link to another device. This means that the more devices you have, the more relyable the network becomes. For this reason, although there were controllers which could support both, it seemed sensible to stick with a single technology. In the end Z-Wave won out due to the fact that at the time it was the only one of the three which supported encrypted links between the devices.

Having made the choice, I went and bought a raspberry pi, a GPIO addon to communicate with a Z-Wave network and a couple of multi function sensors which would feedback once an hour to the controller, reporting temperature, light levels, humidity and motion (This is next to useless when it only reports once an hour, but if wired in it reports in realtime). The devices were also capable of reporting UV and vibrations, but I had no need for these so disabled them.

The system was later augmented with some radiator valves, light switches and AC remotes along with additional sensors to allow some limited control in some rooms in the house. At the moment, I’ve mostly used this system to time turning things on and off and haven’t really realised it’s full potential. Once I have installed the remaining devices and wired in the existing ones (Although most of the devices are battery powered, most of them limit their functionallity to conserve battery power or as in the case of the AC remote just eat batteries) I have a few plans beyond the “switch lights on when someone enters the room” concept.

With these basic components in place I now have the equivalent to the other products on the market; the raspberry pi hosts a web UI from which I can control heating and lights. Coupled with a VPN connection into my home network I can also do this remotely. The main advantage this system has is the single interface to control everything from which supports a huge range of devices from lots of different manufacturers.


With a Z-Wave radiator valve and temperature sensor in most rooms and a Z-Wave boiler switch I will be able to build a far higher functioning smart heating system than the current ones on the market such as the nest. Each room essentially becomes it’s own zone within the system and can be individually controlled.

The basic algorithm used by learning thermostats such as the nest is well known and predates computer systems. A naive implementation of a smart heating system might opt to have code which says:

if ($currentTemp < $desiredTemp) {       
} else {

This works reasonably well and is actually all you need if you have a direct heating system such as an AC unit. However, with more common central heating systems which circulate water you can’t just turn it off; even when off the radiator will remain hot for a while and continue to heat the room. Further more when the temperature drops again, it will take some time for the radiator to warm up and start supplying heat.

The effect of this lag is that instead of your heating system maintaining a nice steady comfortable temperature, the temperature in the room will fluctuate between a little over the desired temperature and a little below it. This is less energy efficient as you’ve effectively wasted the energy heating the room to too hot and will require more energy to heat it back up once it’s gotten too cold.

This is where the learning part comes in.

We start by taking a measurement of the current temperature and comparing to the desired temperature. Any difference between the two is recorded as an error value at the current point in time. We then take the differential and the integral of the error value with respect to time. (this essentially incorporates the temperature history into our algorithm) We then multiply each of the three terms (current error, differential + integral) by a set of constants (one for each term) and then sum the results. This result would be fed into the control for the heating system; in this case we have two options on or off, so we convert this value into a binary decision.

$errorHistory = [...];
$error = $desiredTemp - $currentTemp;
$errorHistory[] = $error;

$result = ($a * $error) + ($b * differential($errorHistory)) + ($c * integral($errorHistory))

if ($result > 0.5) {       
} else {

In this example you would need to choose values for a,b and c to optimise the learning behaviour of the system. The learning part comes from maintaining the history of values and using them to predict future system responses, but you could also have the system learn optimal values for a,b and c to produce a desired responsiveness to changes in the environment. This algorithm is known as a PID controller, for anyone wanting to learn more about it.

As this is a multi zoned system, each room will separately decide if it needs heat or not. This will feed into the controller which will have to decide to switch the boiler on or not (or switch on the AC in rooms that have it) Initially I’ll probably go with a basic condition of waiting for a threshold of rooms to call for heat before switching on the boiler. However this could also be subject to a learning algorithm feeding in the raw room temperatures or their call for heat and calculating a bias for each room to determine if the boiler should be switched on or not.

Further enhancements to this system are also possible - sensors on windows and doors (internal and external) could feed into the system to automatically switch off the heating in a room or the whole house if a window is left open. The heating properties of a room will change if the door to the room is closed, this information could be fed into the learning algorithms to improve their accuracy.


Another area of home automation which I’m keen to explore is that of security. Right now a bugler alarm is a fairly dumb device it has motion sensors and door sensors in your rooms, when turned on it sets off an alarm if a motion sensor or door sensor is tripped. Turning it off requires entering a code into a control panel. My home automation system will eventually contain a greater number of sensors most of which are more accurate than standard bugler alarm sensors so it would make sense to co-opt them into improving the system.

Why stop with just the using the sensors though? With so many of them, it becomes possible to do some more interesting things. For example, you can fairly accuratly keep track of where people are in the house, add in a bit of configuration for which rooms are connected to which other rooms and you can figure out expected movements through out the house. If you’ve tracked all the occupants to being in the lounge and a sensor is tripped in the kitchen without the hall sensor being tripped first - that’s anomalous and you could alert on it.

This increase perception gained by tracking the legitimate occupants within the house gives you the ability to have an alarm system which is always on and doesn’t need setting and could instead use the presence of someone’s phone or a tag attached to their house/ car keys to know if a new arrival was legitimate or not. Further you can solve the issue of a half asleep child setting off the alarm while going downstairs for a glass of water at night, you’ve tracked all occupants to the bedrooms; if one gets up, you can track their movement through the house and not set off the alarm instantly if they trip a sensor.

Obviously such a system produces privacy risks which is where the choice of Z-Wave for it really comes into it’s own. Not only is the data encrypted between devices as it gets sent around the network, but all the logic for running the system is on the controller in your house meaning the tracking information never leaves your own network.


I’m still a long way from having a perfect system setup, but what I’ve got so far has provided a good solid foundation on which to build. Eventually more commercial systems may catch up with the fully integrated approach I am aiming for and be able to provide greater security and privacy protections, but at the current time, there doesn’t seem to be a system out there which can provide all of this.