Awesome Open Source
Awesome Open Source

Control Your Home with Raspberry Pi

This repository contains the code discussed in the book Control Your Home with Raspberry Pi: Secure, Modular, Open-Source and Self-sufficient, published by Elektor International Media, as well as a list of errors and their corrections and some additional tips and references.

About the book

Ever since the Raspberry Pi was introduced, it has been used by enthusiasts to automate their homes. The Raspberry Pi is a powerful computer in a small package, with lots of interfacing options to control various devices.

This book shows you how you can automate your home with a Raspberry Pi. You'll learn how to use various wireless protocols for home automation, such as Bluetooth, 433.92 MHz radio waves, Z-Wave, and Zigbee. Soon you'll automate your home with Python, Node-RED, and Home Assistant, and you'll even be able to speak to your home automation system.

All this is done securely, with a modular system, completely open-source, without relying on third-party services. You're in control of your home, and no one else.

At the end of this book, you can install and configure your Raspberry Pi as a highly flexible home automation gateway for protocols of your choice, and link various services with MQTT to make it your own system. This DIY (do it yourself) approach is a bit more laborious than just installing an off-the-shelf home automation system, but in the process, you can learn a lot, and in the end, you know exactly what's running your house and how to tweak it. This is why you were interested in the Raspberry Pi in the first place, right?

  • Turn your Raspberry Pi into a reliable gateway for various home automation protocols.
  • Make your home automation setup reproducible with Docker Compose.
  • Secure all your network communication with TLS.
  • Create a video surveillance system for your home.
  • Automate your home with Python, Node-RED, Home Assistant and AppDaemon.
  • Securely access your home automation dashboard from remote locations.
  • Use fully offline voice commands in your own language.

Included code

This code, organized by chapter, includes:

  • Docker Compose files to start the discussed services as Docker containers. Note that in most of these Docker Compose files you have to add the mosquitto service. In practice you copy the services from various Docker Compose files and add them to one Docker Compose file to run your whole home automation stack.
  • Configuration files for various services. Some of these are fragments of configuration files. Read the relevant chapter for an explanation of these configuration fragments.
  • Python scripts, some of them meant to be run in AppDaemon.

Download the code

You can download the code on your Raspberry Pi all at once with:

git clone

You may need to install git first:

sudo apt install git

The code is then downloaded into the directory raspberry-pi-home-automation, organized by chapter.

If you prefer to download only a specific file, navigate to the file in GitHub's web interface and then click on Raw at the right. Then copy the URL from your web browser's URL bar and paste it after the wget command, for instance:


Make sure that you're in the right directory first, or move the file to the correct location afterwards.

Just selecting and copying the code from the web interface and pasting it in an editor may also work, but is not recommended. Especially with Python code the whitespace can become mixed up, which results in invalid code.


See the ERRATA document for the list of errors in the book and their corrections.


See the ADDITIONS document for some additional tips and references to interesting projects not mentioned in the book.


All code is provided by Koen Vervloesem as open source software with the MIT license. See the LICENSE for more information.

Alternatives To Raspberry Pi Home Automation
Select To Compare

Alternative Project Comparisons
Related Awesome Lists
Top Programming Languages
Top Projects

Get A Weekly Email With Trending Projects For These Topics
No Spam. Unsubscribe easily at any time.
Python (795,011
Raspberry Pi (22,243
Raspberry (22,237
Book (20,259
Mqtt (7,855
Bluetooth (6,741
Home Assistant (3,658
Automate (3,530
Home Automation (2,191
Node Red (751
Bluetooth Low Energy (727
Zigbee (621
Voice Assistant (494
Zwave (280
Appdaemon (69
Zigbee2mqtt (41
Raspberry Pi Os (30
Zigbee Gateway (15
Rhasspy (11
Zwave Controller (4
Zwave2mqtt (4