Posted on 8 Comments

#24: Home automation system architecture

I’ve been lucky enough to have worked with an electrician to totally rewire my house for home automation, so it works in a very different way to a normal house. This episode traces through how power arrives at my house, is distributed to a pair of sub-switchboards, and from there goes out to loads such as lights. It also covers the important pieces of the system including MQTT and OpenHAB.

General information about MQTT is available at the official MQTT site. The site doesn’t get many updates because the protocol standard itself is fairly stable and well established, but it’s a good reference site with links to many MQTT-related projects. See

There are many MQTT broker implementations available, written in various programming languages and with different features and levels of performance. I use Mosquitto, which has been around for many years and has never let me down. Note that your MQTT clients won’t care what broker you use or what language it’s written in, provided it supports the features they need. Mosquitto is written in Java, but I typically connect to it from Arduino-based devices. See

OpenHAB is currently the main rules engine that I use, which also takes care of state management and provides an app for iOS and Android. I’m still running the v1.x release series, but v2 is out now which is a major rewrite. See

For a general purpose rules engine that communicates using MQTT, check out Node-RED. With a drag-and-drop editor based on Node.js, you can create rules right in your browser. I don’t currently use this, but I’ll probably replace my current home-brew rules engine with Node-RED some time in the future. See


8 thoughts on “#24: Home automation system architecture

  1. Thank you for a series of completely inspirational videos. They have really cleared up the way forward for me. I’ve been dabbling with all sorts of off the shelf items for a few years, but this is the way to go. I have have poked a bony finger at Raspberry PI and Arduino for years but never managed to actually do something useful with them. I do run Openhab (fairly recently).
    Now, I have two questions:
    1) How do you do the MQTT stuff on the Arduino? I see it in the video, but I can’t see anything on the site, ie links to code or explanation of how it connects together. I get how it works in theory, just seem to have a mental jam on putting it into practise.
    2) Why do you need your custom rules engine or NodeRed AND Openhab? Could it not all be done in OpenHab?
    thanks again for being inspiring. (Looking forward to the updated workshop tour).

  2. I have figured out the Switch Controller end of the MQTT stuff. Man, these videos are inspiring!

  3. I’ve been thinking about your setup. I really love it but most people cannot or will not want to rewire their entire house in order to do home automation. Also if I wanted to sell the house in the future it would complicate things or more than likely I’d just have to rewire the house back to normal. So I figure there could be some compromises that can be made to get close to your setup. One of the first things that came to mind was the ability to move from a central relay system to a distributed relay configuration. So if you take your light switch and short the two cables together in the light switch box then it essentially forces the light to be powered all the time. Then use light bulbs that are intelligent (and will work when the internet is out) such as hue or lifx. From that point the rest of your configuration will work like you have it configured. I know you have an aversion to wireless so you may prefer smart switches like Insteon or zwave. I have just been finding them more of a pain than its worth lately as most require the 3rd common wire which many houses don’t have. I’m interested in your thoughts on the matter.

  4. Hi Jon,

    I’ve been wathcing a number of your episdoes on your site. I’m completing a whole house renovations and am keen to follow your HA example.
    Quick question on this video: Would/could you replace the S4190D relays with Sonoff Basic relays? (with provision of external switching from GPIO14 as explained in episode #21 Sonoff Secrets)?

    1. Thanks for the series. What relays did you use in your power sub-panels (the link is broken)?

  5. Hi there.
    I stumble on your videos and have been stuck watching them since, I´m rebuilding my house and small electric and programming have been my interest for a while. But I´m mechanic for a living.
    One question from this video? What if the thief turns off the main switch.
    In my country the cable comes up inside the house and into the main table.

    I wanna thank you for your effort on those videos. They are really helpful. I´ll probably go all the way and create my own simple board when I have the knowledge to do so.

    Sincerly Eirikur

  6. Awesome Jonathan! Thanks for pointing me to this video. I learned so much from it.

    I already have a Pi Zero that I bought when I first thought of doing this stuff. I figured it was enough to be the central element for my home smarts, but knew roughly a fifth of fuggall what to do with it. Now I know exactly what to do with it, & also have much clearer ideas for the architecture of my systems.

  7. Ho Jon,

    Can you please share your latest software which you are running on your relay controller, you have the old one on github (, but it is configured with WEB interface. Or maybe it’s a good Idea for one of your next videos.

    Thank you.

Leave a Reply

Your email address will not be published. Required fields are marked *