Book Image

Building Smart Home Automation Solutions with Home Assistant

By : Marco Carvalho
5 (1)
Book Image

Building Smart Home Automation Solutions with Home Assistant

5 (1)
By: Marco Carvalho

Overview of this book

Picture a home where you can adjust the lighting based on the time of day or when movement is detected. In this same home, you can also detect when a door is unexpectedly opened or an alarm is triggered in response to any suspicious activity. Such automated devices form part of a smart home, and the exciting part is that this book teaches you how to create and manage these devices all by yourself. This book helps you create your own ecosystem to automate your home using Home Assistant software. You’ll begin by understanding the components of a home automation system and learn how to create, hack, and configure them to operate seamlessly. Then, you'll set up Home Assistant on a Raspberry Pi to work as a home automation server, build your own IoT sensors based on ESP32/ESP8266, and set up real-life automation use cases using hands-on examples and projects. The chapters will also guide you in using software tools such as Node-RED, InfluxDB, and Grafana to manage, present, and use data collected from your Home Automation devices. Finally, you’ll gain insights into new technologies and trends in the home automation space to help you continue with your learning journey. By the end of this book, you’ll be able to build your own creative, IoT-based home automation system using different hardware and software technologies.
Table of Contents (19 chapters)
1
Part 1: Introduction to Home Assistant – Installation and Configuration
4
Part 2: Install, Create, and Hack Sensors and Actuators
7
Part 3: Automations, Customizations, and Integrations Using Home Assistant
10
Part 4: Expanding Home Assistant’s Capabilities
13
Part 5: Learn by Doing and Future Trends

Example of a real home automation system

In this section, the idea is to give you an overview of what a real home automation system looks like. I will do this by providing details about my own system.

History

I started to build my current system in 2017 when I first purchased my first four Wi-Fi actuator plugs. At that time, I didn’t have any idea how the system evolve. I just wanted to try to control them remotely and use the phone application to be able to turn them on or off remotely or program them to turn on or off based on a schedule. In 2019, I purchased the Raspberry Pi 4, again, with no idea of how to install any specific software to it, only a regular Linux distribution. I was living in a small, rented apartment with my family and had no plans to implement any automation.

In 2020, I finally decided to invest time in learning about Home Assistant and the ecosystem related to it. I installed Home Assistant on Raspberry Pi, and then I hacked the four actuator plugs by installing Tasmota on them. In the same year, I also purchased my first ESP8266 module and BME280 temperature sensor. I was able to create my own temperature sensor and integrate it into Home Assistant.

We purchased a house in 2021, and I became motivated to really automate it. In less than 1 year, I was able to grow the number of devices from 4 actuator plugs to 23 different devices, including commercial and homemade sensors and actuators.

Note

Tasmota (https://tasmota.github.io/) is the software system that will be installed on the sensors and actuators to work with the home automation system. It will be explained in Chapter 3.

Current configuration

The following tables list all devices I have at home, separated by device type. At the time of writing, besides the home automation server, there are 11 sensors and 11 actuators.

Home automation server

The home automation server is just one device, and Table 1.3 provide more details about it:

ID

Device name

Location

System installed

Specifications

Function

1

HomeCamino

Office

Home Assistant

Raspberry Pi 4

Home Automation Server

Table 1.3: Details about the home automation server

As mentioned previously, the home automation server I have at home is shown in Figure 1.8, and its creation and configuration will be covered in the next chapter.

Sensors

Table 1.4 presents the current sensors I have in my home automation system:

ID

Device name

Location

System installed

Specifications

Function

2

MB_Thermo

Master bedroom

ATC_MiThermometer

Xiaomi Mi thermometer

Measure the master bedroom temperature

3

MB_backyard_door

Master bedroom

Tuya

Door sensor

Detect the master bedroom to backyard door open

4

Front_door

Dining room

Tuya

Door sensor

Detect the front door open

5

LivingRoom_Thermo

Living room

ATC_MiThermometer

Xiaomi Mi thermometer

Measure the living room temperature

6

Kitchen_backyard _door

Kitchen

Tuya

Door sensor

Detect the kitchen to backyard door open

7

Backyard_Thermo

Backyard

ATC_MiThermometer

Xiaomi Mi thermometer

Measure the backyard temperature

8

Kid1_Thermo

Kid1 bedroom

ATC_MiThermometer

Xiaomi Mi thermometer

Measure kid1 bedroom temperature

9

Kid2_Thermo

Kid2 bedroom

ATC_MiThermometer

Xiaomi Mi thermometer

Measure kid2 bedroom temperature

10

Garage_door

Laundry

Tuya

Door sensor

Detect the laundry to garage door open

11

Garage_Thermo_Motion

Garage

Tasmota

ESP8266 own sensor

Measure the temperature and detect motion in the garage

12

ESP32_Thermo

Office

Tasmota

ESP32 own sensor

Five-zone BlueTooth temperature Hub

Table 1.4: Sensors in my home automation system

In regards to the sensors, it is worth commenting on the IDs 11 and 12, which are homemade sensors. In this book, we will cover them using hands-on projects in Chapter 3 and Chapter 10, respectively. In Chapter 10, the process of hacking the thermometer IDs 3, 5, 7, 8, and 9 will also be explained.

Actuators

Table 1.5 presents the current actuators in my home automation system:

ID

Device name

Location

System installed

Specifications

Function

13

MB_TV

Master bedroom

Tasmota

CT-065W plug

Turn on/off the master bedroom TV

14

MB_Fan

Master bedroom

Tasmota

SONOFF Basic R2 r

Turn on/off the master bedroom fan

15

DiningRoomLamp1

Dining room

Tasmota

CT-065W plug

Turn on/off one of the dining room lamps

16

Front Lights

Dining room

Tasmota

SONOFF Basic R2

Turn on/off master front lights

17

Kid1_Fan

Kid1 bedroom

Tasmota

SONOFF Basic R2 Mini

Turn on/off the master bedroom fan

18

Corridor_Lights

Corridor

Tasmota

SONOFF Basic R2 Mini

Turn on/off corridor lights

19

Laundry Lights

Laundry

Tasmota

SONOFF Basic R2 Mini

Turn on/off laundry lights

20

WLed_SW

Garage

Tasmota

CT-065W plug

Turn on/off front yard decoration lights

21

Coffeemaker

Anywhere

Tasmota

CT-065W plug

Turn on/off different lights at home

22

Wled

Front yard

WLED

WS2812 strip Light Emitting Diode (LED) lights

Control front yard decoration lights

23

Wled_tree

Dining room

WLED

WS2811 LED lights

Control Christmas tree LED lights

Table 1.5: Actuators in my home automation system

Most of my actuators are commercial based. Most of them are from SONOFF, which is known to be based on the ESP8265/8266 chip from Espressif Systems. In Chapter 4, I will tell you how I hacked two actuator models used at my home. Chapter 9 in this book will be another hands-on project to explain how actuators 22 and 23 were created.

Bill of materials and costs

I captured in Table 1.6 all the information you need to know about the cost and material used in my home automation system. Some items I purchased as kits with more than one unit, so I’m just including the items I need. I’m also including some tools and accessories I purchased for the installation. All costs are final costs after taxes.

More information and details about specific parts will be provided later in each of the hands-on project chapters:

Item

Function

Unit Cost (USD)

Qty

Total (USD)

Raspberry Pi 4 + power supply + case + 32 GB SD card

Home automation server

86

1

86

ESP32 module

Five-zone BT temperature collector

9

1

9

ESP8266 + BME280 (temperature sensor)

Part of a homemade temperature sensor

14

1

14

WS2811 LED lights

Christmas tree lights

15.50

1

15.50

ESP8266

Christmas light and front yard lights controller

3

2

6

Power Supply + WS2812 LED strip lights

Front yard LED strip lights

50

1

50

SONOFF basic R2

Various actuators

6.60

4

26.41

HC-SR501 PIR sensor

Part of a homemade motion sensor

2.50

1

2.50

Crimping tool + wire connector

Actuators installation

34

1

34

Universal Serial Bus (USB) wall charger

Homemade sensor

2.50

1

2.50

USB to Serial converter

Hack commercial sensors

6.50

1

6.50

SONOFF Mini R2 Basic

Various actuators

6.84

3

20.54

Tuya Smart Wi-Fi door sensor

Door sensors

5.80

4

23.2

Bluetooth Xiaomi thermometer

Five-zone Bluetooth temperature sensor

4.42

5

22.12

Total Cost

318.27

Table 1.6: Bill of materials and cost of my home automation system

I hope this section inspires and supports you to see how your home automation system could be if you don’t have one yet. If you do have one, I still believe it could inspire you to include new and different devices in your home. You will see that it is not difficult to create your home automation system. We will start to do this in the next chapter. Therefore we can conclude this section and this chapter with the following summary.