Are you secure? Are your loved ones secure? Is your home secure? Are your loved ones secure at home? Is your dog secure? Are your accumulated mounds of jewellery secure? Are you secure in the knowledge that things are secure? Are you secure in yourself? Have you secured your potential? These are all questions that we must ask.
I’ve never done home security before. Never had an alarm or sensors or anything technological like that. I did have a Staffordshire Bull Terrier cross called Daisy who used to go mental if someone parked in front of my old UK house. But given that she’d roll over for anyone who actually entered the property, she was of little security use.

Given that I’m currently lacking a sappy Bull Terrier, what security options do I have in my new apartment revamp?
The normal path
Traditionally you’d have a commercial security system in a property which you want to protect from evil outside threats. This is a box containing a custom electronics board, with hardwired links snaking out to motion sensors, door contacts, and window break sensors. If one of those sensors was triggered then BEEP BEEP BEEP an alarm goes off, and perhaps even an emergency call gets sent to the local police. In return for all this insurance companies will give you some discounts and deem you to be Protected.
The abnormal path
That path has become rather passé of late. Who wants to put cables everywhere when you can have fancy wireless sensors? Nowadays it’s all about wireless this and wireless that. Even discounting the off-the-shelf Zigbee, Z-Wave and Wi-Fi products, commercial systems themselves have turned to using radio for their sensors. And you know what? Fuck that rudely. There is absolutely no way I want to have a security system that involves me having to change batteries. Christ, the whole reason I’m hard-wiring everything that I can is because I forget to change batteries.
No, no, no, no, no and no again. If I’m installing an alarm system then it’s going to be hard-wired.
The normal path, with a nerd twist
So back to the normal path. But just because I want things hard-wired doesn’t mean that I have to do things the commercial route.
NOTE TO PEDANTS AND OTHER FREAKS: Before you start frothing, yes I know that a commercial system offers the benefit of your insurance company offering you reduced premiums. To be clear, what I’m proposing here isn’t a commercial system, and I have no intention of claiming that it is one to my insurance company.
This is what I’m thinking about:
- Lots of sensors, all hard-wired - no reliance on wireless tech.
- Each window frame and door should have sensors that indicate if it is open or closed.
- There should be dedicated motion sensor for each room.
- A central control unit - not tied to Home Assistant, but able to communicate with it - that can support various “states”, and that can receive inputs from the wired sensors.
- An audible alarm that can be set off if need be.
- The ability to communicate with me even if Home Assistant goes down and the connection to the wider internet is out.
- Dedicated battery backup so that it can run for a few hours, if not a day, without mains AC power.
Going back to my rough Principles, this is would be part of the “Critical” layer of home automation - i.e. if that this doesn’t work, it could allow intruders to maraud - probably naked - through my place, stealing my guinea pigs.
I consider this to be “basic” security. It’s enough to alert me if we accidentally leave windows or doors open when we’ve left home, to alert me if there’s something happening when wifey and I are not there, and to maybe attract neighbours if someone enters though forced entry or an unlocked door.
Give me MORE security
Of course, I don’t have (and won’t) to stop there - security isn’t just about doors and windows. I’ve got plans for how to integrate smoke sensors into this, how to handle front door entry without keys, more advanced presence detection, and even water leak detection. 1
But I’ll cover those exciting additions in separate posts. For now I just want to focus on the basic setup.
Sensors
The sensors I plan to be using are basic - all they do is allow a HIGH or LOW logical voltage signal to be transmitted along the wiring. Some of them are passive, in that they don’t require any additional power to the their thing. The door and window sensors, for example, just operate by a reed switch being opened or closed via a magnet, allowing the voltage to propagate.
But others require their own power. For example the PIR motion detectors have active circuitry that is necessary for the sensor itself to operate, and open/close the logical state on the wiring.

For these I’ll have to supply power to the sensor.
Wiring
That combined power and data requirement is why I’m taking the chance to lay down four-core “bus” cables wherever I can. This stuff is popular amongst the German KNX weirdos, and is cheap and easy to obtain at hardware stores. Each of the four wires in the cable is 0.8mm2, and easily capable of handling 12/24V at low-amperage on one pair, as well as transmitting either logical voltage states or more complex Modbus-type protocols on the other pair.

I am of course suspicious that the German flag colours dominate this most jingoistic of cables.
Laying in wiring and sensors
This is a saga in itself, and is taking a good amount of time to bring to reality. Firstly, planning what cables were needed for each room was a mindfuck. Remember, I’m doing this from scratch, with no knowledge. It might look like I know what I’m doing as you read this, but I’m skipping the obsessive late nights reading of articles and suffering through Youtube videos hosted by aggressively nerdy American men.
As an example: after deciding “oh I need window sensors” I might plan for just one sensor per window.

Fine, right? Windows are open or closed? On, off. Yes, no.
Well no, because German windows aren’t just a boolean state. They’re actually ternary - they can be open, closed or fucking tilted.
Which means that I don’t just need one sensor per window, but two - one at the bottom, one at the top. If both sensors are HIGH then the window is closed. If both sensors are LOW then the window is swinging open. But if the top sensor is LOW and the bottom one is HIGH then the window is in that special third state that only Germans can make happen. 2 Which means already you’re into logic gates for a bloody window.
This is just one example of planning assumptions that were rudely refuted when I came to lay cables.
In truth I’ll probably have to write a dedicated post about the woes of laying cabling in a 150 year old solid brick apartment at some point. Even if it’s just for therapy reasons.
But suffice to say my current planning spreadsheet has 91 of these green cable bastards that I have to install throughout the apartment. Okay, not all of it is for the security stuff, and I’m laying in extra where I can. But still.
The brains of the operation
Anyway, lets talk about where all these green meanies terminate - the central control board.
If this was a post written by a USA citizen I’d be harping on about the area in the garage that they have reserved for it. But no, this post is written by a mangy British woman living in Germany, and all I’ve got is a cupboard.
Part of a cupboard at that.
But I’ll make do with what space I have. The green “core” cables will (if my plans meet with success) output from the utility cupboards ceiling and go into a little industrial control panel, high up on the cupboard wall.
Inside that control panel is an ESP32 based I/O board, which makes all of this possible.
I’m a big fan of Kincony gear. They’re based in China and specialise in control boards based on ESP32 chips. I’ve got one of their A16 boards for testing concepts out and, combined with ESPhome it’s a delight to use. Loads of logical inputs, and a bunch of basic MOSFET outputs, along with wired ethernet and Modbus.
That’s just a basic unit. They have things ranging from tiny dedicated alarm boxes to giant boards with 256 relay outputs.
All of these things are mountable on DIN rails, so they’ll fit nicely in a metal automation panel, along with all the other accessories.
I’m not quite sure which board I’m going to install yet, but given the choices, and the fact this company keeps releasing new boards and upgrades, I’m going to wait until I’m moved in before doing anything.
States
But to give you a preview of what I’ll be doing, it’ll be something like this…
Any alarm system is finite state machine. Typical states are armed
, alarm
and sleep
. Different actions move the state to other, predictable, states. e.g. When in the armed
state, a motion event will move the state to alarm
. But the same event won’t move the state from sleep
to alarm
.
Yes, terribly boring I know. But I need this to write a state machine in ESPhome. If there’s an input on one of the sensors then different things can happen as a result.
I’ll probably have a few more states than the above. For example, I might have an unoccupied
state when we go out that only responds to window sensors, so that Derek, our trusty robot vacuum, won’t set motion detectors off while blundering around our apartment.
Some other examples I can think of:
occupied
- someone is home.sleep
- someone is home, and it’s nighty night time.guest
- there are guests present, with or without the normal occupants.unoccupied
- there’s no one present, on a temporary basis.vacation
- there’s no one present for an extended duration.
By sharing these with HA, I could change automations based on the apartment’s state. e.g. In the sleep
state I’d want to have low-level lighting respond to movement outside the bedroom, so that a visit to the kitchen for a glass of water is accompanied by a night-vision friendly red light everywhere. In the vacation
state maybe a vibration sensor on the front door is incorporated so that it can sense someone messing with the lock, and the overall temperature of the apartment would be set lower. In the guest
state the lights might operate in a different way from if it’s just us two.
In any case, this is for the future. For now all I can do is get the hardware in place to support the future software potential.
On-board comms
To make sure that this is a truly independent unit I’ll want a way for it to communicate. Luckily ESPhome has a component for this. By connecting a tiny 4G modem over UART ESPhome can send and receive text messages. This makes it a very useful fallback for when HA goes down, or there’s no connection to the wider internet. Of course when those things are working I can receive messages via the HA app as normal.
Battery backup
The final piece of making this an independent system is having battery backup. Now I can do this easily via an off-the-shelf AC UPS. Just plug the panel into it and it’s a good ‘un.
But I want this to run independently for hours, if not days, without power. While it could share a UPS with the rack that I plan to locate nearby, that feels off. If I use a dedicated UPS I’d have to locate that on the floor, as the lead acid batteries can weigh a tonne.
But there’s a nice line of DC-only DIN rail UPS devices that I might look into. They’re based on LiFePO or super-capacitors, and are as such extremely light. Might be nice (but let’s get the apartment built first, eh Charlie?)
That iconic alarm keypad
Finally, a word on alarm keypads: no.
This isn’t the 90s and I don’t want some kind of frantic interaction with a cheap spudgy keypad whn coming in. All of the states mentioned above will be smart and coordinated with HA. So if HA senses that one of us gets home, it will automatically shift the state from “vacation” to “occupied”.