Wired DIY home automation system

While building our new house, I did spend a lot of time on designing and later building a home automation system, with home assistant + MQTT at its core.

Today, I did post the first of a series of blog posts on this topic: Why

The first post is mostly about explaining the rationale behind it as well as the series of posts I have actually planned over the course of the following weeks.

Hope you might enjoy it!


Nice post :+1:t2:

1 Like

I am very interested in the following posts because I did something similar.
Unfortunately I don’t find the time to document everything properly.

1 Like

I can confirm it has been really time consuming for me to just prepare the set of posts. The issue I did find is that while writing down, in order to tell a story, you first need to elaborate on a lot of different things first. Consequently, my initial post was huge and tried to cover too many things. This is why I did turn it into a series in the end.

nice post, If you have hardware ideas share more to us

Update: here’s the second post in the series: Architecture

It is again a bit more of a theoretical post in that it outlines the architecture and the framework I did use for reasoning about the overall setup.

Some first concrete details about the hardware / software used are given.

1 Like

Great posts… I am really looking forward for wiring and schematics part. Although Star topology looks suitable in your case; running new future wires might create some trouble for most people.

A friend of mine went the same wired solution; but since his budget was extremely tight, he went with arduino based relay and input solutions in his electric cabinet. So, (as i see unipi looks costly but it is exteremely professional) both input and outputs in his installation were connected to 3 Arduino Megas since it has the maximum number of pins. It is again Star Topology but he was redesigning the whole house, so it was easy to lay out brand new Cat6 cables from the electric cabinet to everywhere. In my case, this is simply not possible…

But to tell the truth his solution is a hundred times more stable than my zigbee, zwave, wifi hybrid solutions…

1 Like

Do you have an idea of the voltage levels used e.g. for reading the input buttons? The arduino typically works with 5V, which is rather low for longer wire runs. The unipi units use 24V, which is quite common for home automation.

I do indeed plan to cover more of that in the upcoming wiring post :slight_smile:

The fluctuations on longer cable runs were indeed problematic with 5 V.

What he did was, when the switch is turned on, he send the closed circuit 220V to near the arduino which is in the electric cabinet; use an adapter to make it 5V and send the signal to arduino pin following an optocoupler. At least that’s how i remember it :slight_smile:

And the cabinet turned out to be like this:

Wow, nice! I think the advantage of a platform like arduino is that it’s simpler and probably also less power-hungry.

I didn’t really feel like doing the 220V / 5V interfacing myself though (for signaling applications like push buttons, 220V seems even dangerous tbh). Also, the advantage of a raspberry pi-based platform is that it’s a bit easier to put custom code on it (I use python for example).

Maybe at some point I will reconsider the hardware though, make something dedicated an actually do my own interfacing.

Let me chime in ahahah

While a wired system is a cool idea and you don’t have issues with wireless links, you certainly will have with induced current by lightning.
Especially in areas where storms and such are common or occurr often, one nearby lightning strike is sufficient to fry all long-cabled devices, such as LAN cables and stuff: The longer they are, the more prone they are to this.
The 230VAC input generally is more robust against sudden spikes in power, but the 5V-10V on a wired system mostly isn’t.

I did use WiFi on all my devices and put one router per floor.
The routers are simple one-antennae TPLink routers and all of them are in the same IP range and get the DHCP from the main home router. Also the APs are on a different WiFi channel than the main router and the SSID is hidden.
I have no link issues. All devices are just there and rarely give me headaches.

In an event on a lightning strike, the worst that should happen is frying all the APs (because they are wired over a longer distance), but the Sonoff’s itself should survive.
I say should, because you never know until it really happens :stuck_out_tongue:

induced current by lightning.

Never really considered that to be honest, in theory it could be an issue, I suppose?

For the (analog) signalling (e.g. push buttons), I actually do not use LAN cable, but rather a higher wire gauge multi-wire cable, i.e. 16x0.8mm2 wire cable (here, it’s called SVV-type cable, not sure about the international naming). I’m not sure about the max current it can handle …

The push buttons themselves are just plain mechanical toggles, so when there’s an overcurrent event, these should be fine.

Ah yes.

But even 0.8mm cables can carry enough to kill your devices if the wire is long enough. It’s not even so much the current, but the voltage. An EMP can carry thousand volts with a very low amperage for a fraction of a second and toast all of your devices at once.
Technically a filter cap (10nF) on either end of the switches could maybe help to ‘dissipate’ some of that energy, but I’m not entirely sure.
At the end, it’s all about luck.

Another post today! This time, it’s about the lowest level in the stack, Wiring


Really great to read this. My house also uses a relay system and svv cable setup with 24v. Sadly my modules aren’t smart connected (a brand called conson). Really curious how you setup up those unipi’s and how many you’ve installed,…

In total I would need around 64 digital input and outputs. So I’m really following your blog

1 Like

Thanks, that’s really to nice to hear!

The overview post lists all of the current and future topics, so I do indeed plan on writing some more details about how I employ the unipi systems in the overall system.

The unipi units themselves aren’t directly connected. The built-in software has some way of linking inputs and outputs on the unit itself. Additionally, I think unipi also offers their own software for programming; Mervis | Unipi but I haven’t looked into that tbh, since I was mostly interested in using home assistant.

The upcoming (currently 7th) post on programming intends to show the software I put on the unipi unit such that it provides an MQTT event-based interface for home assistant to integrate with it. The specific software can be summarized as follows:

(tbh, I would prefer to replace the latter 2 by something that interfaces directly with the kernel, but haven’t gotten around to that yet).

As for the unipi units, I have:

Apart from these, I have a couple of other unipi units for e.g. an alarm system, shades control and a DALI bus controller.


Thanks for the information. Isn’t a modbus connection a solution?

About modbus: unipi indeed also offers a modbus integration (you can even plug in an RS-485 cable). From what I understood, internally they also use the modbus protocol for having the main raspberry pi board talk to the IO controllers (via SPI).

For me, directly interfacing with the modbus TCP interface worked OK in case of pushing out updates (writes). For polling the status of push buttons, the polling speed was too slow.

1 Like

Another post in the series on Schematics : one-wire diagram and floor plan.

Small post this time, but an important one to do the mains voltage wiring properly.

1 Like

Bump, another post: Electrical cabinet

I think this one might be particularly interesting as it is a bit more hands on: it shows the insides of my centralized electrical cabinet.

1 Like