Chapter 17. Home Automation
17.0 Introduction
As a low-cost and low-power device, a Raspberry Pi makes a great home automation hub that you can leave running without fear of huge electricity bills. For the recipes described in this chapter, you don’t need the power of a Raspberry Pi 4. In fact, a Raspberry Pi 2 or 3 will be plenty fast enough and will run cooler and use less electricity than a Raspberry Pi 4.
We start with Message Queuing Telemetry Transport (MQTT), the basic communication mechanism for most home automation systems, and then move on to look at using Node-RED (which you first met in Chapter 16) as a basis for home automation.
Strictly speaking, home automation is all about making your home smarter and more able to do things for itself—for example, to turn on a light for a set amount of time when movement is detected, or to automatically turn everything off at bedtime. But most people who are interested in home automation are also interested in remote control of the parts of their home that have been automated. We also look at remote control by smartphone in this chapter.
17.1 Making a Raspberry Pi into a Message Broker with Mosquitto
Problem
You want to make your Raspberry Pi a hub for your home automation system.
Solution
Install the Mosquitto software so that your Raspberry Pi can act as an MQTT broker.
Run the following commands to install Mosquitto and start it as a service so that it automatically starts when your Raspberry Pi reboots:
$ sudo apt-get ...
Get Raspberry Pi Cookbook, 3rd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.