Table of Contents

Home Assistant Server

By: Anastasiia Zatsepina (32265) & Ekaterina Zakharova (30909)

1. Introduction

In this project, our group explored the creation and implementation of a home automation system using a Raspberry Pi and the Home Assistant platform. The system integrates various smart devices and sensors to automate and enhance everyday home activities, focusing on practicality and ease of use.

Key components of the system include a Raspberry Pi, which serves as the central hub, and a range of smart devices such as Zigbee-based sensors, Tuya-controlled pet feeder, and lamp. These devices work together seamlessly to provide a connected and intelligent home environment.The project covers the setup and configuration of Home Assistant on the Raspberry Pi, offering a short guide to integrating and controlling various smart devices.

By using Zigbee technology, we combine motion and temperature sensors to monitor and automate home conditions. Additionally, Node-RED is utilized to create automation workflows, such as automating the pet feeder and responding to motion sensor triggers. Furthermore, the system includes the configuration of the E-mail Node in Node-RED to enable email notifications for specific events.

InfluxDB is employed for data storage and graphical representation, allowing for the visualization of sensor data and system performance over time. Overall, this project demonstrates the potential of home automation to simplify daily tasks, improve home security, and enhance the quality of life through the integration of smart technologies.


2. Materials

Raspberry Pi

The Raspberry Pi is a small, affordable, and versatile single-board computer that serves as the central hub for our home automation system (Figure 2.1). Its compact size, low power consumption, and robust performance make it an ideal choice for running Home Assistant and managing various smart devices. The Raspberry Pi supports a variety of operating systems and comes with multiple interfaces, including GPIO pins, USB ports, and HDMI, making it a highly adaptable tool for numerous applications[1].

Home Assistant

Home Assistant is an open-source home automation platform that enables users to control and automate a wide range of smart devices[2]. It offers a user-friendly interface, extensive device compatibility, and powerful automation capabilities. Home Assistant can run on various hardware, including the Raspberry Pi, and supports integration with numerous smart home products and services, providing a centralized system for monitoring and controlling home environments.

| Figure 2.1 - Raspberry Pi 5 Product page | Figure 2.2 - Home assistant Installation guideline by Taycan |


Home Assistant's core components provide the foundation for integrating, controlling, and automating smart devices:

Figure 2.3 - Zigbee device: area, manufacturer and model & entities
Figure 2.4 - Zigbee device: state

Zigbee

Zigbee is a wireless communication protocol designed for low-power, low-data-rate, and close-proximity applications (Figure 2.5). It is widely used in home automation, smart lighting, and other IoT (Internet of Things) applications[3]. Using Zigbee with a Raspberry Pi for Home Assistant involves setting up a Zigbee gateway (or hub) that connects to Raspberry Pi, allowing Home Assistant to communicate with Zigbee devices.The first step is setting up the necessary integration for zigbee.

Figure 2.5 - Zigbee

3. Set up

  1. Home assistant
  2. Integrate own Wifi AP/Router
  3. Setup MQTT
  4. Setup Node-RED
  5. Setup INfluxDB
  6. Setup local Tuya extension

(with Pet Feeder(Tuya), Tuya lamp, Zigbee Motion + Temperature sensors as components of the system)

1)Installation of Home Assistant on Raspberry Pi

2)Wifi AP integration

  1. In HA settings, select “Automatic” on both IPv4 & IPv6
  2. Connect to your Wifi Access point

Network configurationFig. 1: Network configuration

3)MQTT setup

  1. Go to “Settings”→Add-ons→Add-on store→Find the “Mosquito broker” add-on and click it→Click “Install”
  2. Fig. 1: Mosquitto Add-on

To get the add-on running:

  1. Start the add-on.
  2. Have some patience and wait a couple of minutes.
  3. Check the add-on log output to see the result.

Create a new user for MQTT via your Home Assistant's frontend Settings → People → Users, (i.e. not on Mosquitto's Configuration tab).

Notes:

  1. This name cannot be homeassistant or addons, those are reserved usernames.
  2. If you do not see the option to create a new user, ensure that Advanced Mode is enabled in your Home Assistant profile.

Node-RED & INfluxDB & Local Tuya are installed in a similar to MQTT fashion


4. Tuya devices: pet feeder, lamp

Tuya is a global IoT platform that provides smart device solutions, enabling easy integration and control of various smart products. In this project, we use Tuya-controlled pet feeder and lamp, which can be managed through the Home Assistant platform. Finally, two tuya devices were added: pet feeder and LDV_Lamp, which we can switch on/off using “controls” and check any state changes in “logbook” (Figure 4.1).

Figure 4.1 - Tuya devices: Pet Feeder and lamp

Pet Feeder: The smart pet feeder allows for scheduled feeding times and portion control, ensuring that pets are fed on time, even when the owner is not home. It can be controlled remotely through Home Assistant, providing convenience and peace of mind. Number of portions can be changed by using the control buttom (Figure 4.2).

Figure 4.2 - Pet Feeder control

Adding a Tuya Pet Feeder to Home Assistant (made by Taycan): https://student-wiki.eolab.de/doku.php?id=amc:ss2024:bird_feeder:ha_installation

Lamp: The Tuya smart lamp offers remote control and automation capabilities, allowing users to adjust lighting conditions based on time of day, occupancy, or other triggers. It enhances home comfort and energy efficiency. Controll buttom allows to turn on/off the lamp (Figure 4.3).

Figure 4.3 - Lamp control

Adding a Tuya Lamp to Home Assistant

To add a Tuya lamp to Home Assistant, start by setting up a Tuya account and app. Download the Tuya Smart or Smart Life app from the App Store or Google Play, and create an account or log in if you already have one. Add the lamp to the app by putting it in pairing mode ( by turning it on and off a few times or holding a button) and following the in-app instructions.

Next, configure Home Assistant by accessing it via a web browser. Navigate to the Integrations section under Configuration and click the “+ Add Integration” button. Search for and select Tuya from the list. Enter your Tuya app credentials (email and password), select the appropriate Tuya region, and input the API key and secret from the Tuya IoT Platform.

The most challenging point in the configuration of devices is to find a local key, usually most necessary data is filled in automatically. To find the local key follow through these steps: developer tuya platform/cloud/Api explorer/device management/ query devices in project.

Home Assistant will then connect to your Tuya account and sync your devices. Ensure the Tuya lamp appears in Home Assistant by checking the Entities section under Configuration.


5. Zigbee devices: motion and temperature sensors.

This setup integrates a Zigbee motion sensor (Figure 5.1) and a temperature/humidity sensor (Figure 5.2) for smart home automation. The motion sensor is used to create scenes, such as activating a pet feeder, while the temperature/humidity sensor helps practice data collection with InfluxDB and Home Assistant (HA).

Figure 5.1 - Motion sensor
Figure 5.2 - Temperature/humidity sensor

Two devices are listed: _TZ1800_fcdjzz3s TY0202, located in the living room, with 96% battery, and _TZ3000_xr3htd96 TS0201, with 100% battery (Figure 5.3). Both are integrated with Zigbee Home Automation.

Figure 5.3 - Zigbee devices

The dashboard displays sensor data, including motion detection (Figure 5.4), humidity at 61.6%, and temperature at 23.9°C (Figure 5.5). Configuration settings and firmware updates are available, and the logbook records motion events and button presses.

Figure 5.4 - Motion sensor state
Figure 5.5 - Temperature and humidity data

6. Node-red: main nodes. Automatisation: pet feeder and motion sensor. E-mail Node Configuration.

Node-RED is a powerful, flow-based development tool for visual programming. Node-RED uses a visual editor to create “flows” by connecting nodes.

Node-RED excels in home automation by enabling complex workflows:

Pet feeder and motion sensor configuration

Task: to trigger the pet feeder when motion is detected. Firstly, node-red was installed.

This Node-RED flow diagram shows a simple setup for a pet feeder system using a state node, a debug node, and a call service node (Figure 6.1).

Figure 6.1 - Pet feeder and motion sensor flow
  1. MotionSensor (state node): This node represents a motion sensor that detects movement. It is currently off (as indicated by the red circle and the text “off at: Jul 2, 13:51”) (Figure 6.2).
Figure 6.2 - Configuration of state node
  1. debug 2: This node is connected to the MotionSensor node and is likely used to output debug information to the debug pane in Node-RED. It helps in monitoring the data being passed from the motion sensor.
  2. feed (call service node): This node is connected to the MotionSensor node as well and represents the pet feeder mechanism. When the motion sensor detects movement, it triggers this node to activate the feeder (Figure 6.3).
Figure 6.3 - Configuration of call service node

The flow works as follows:

Test video with cat: https://youtube.com/shorts/Tk14my7ZAQo?feature=share

Lamp and motion sensor

The next Node-RED flow diagram (Figure 6.4) is designed to control a light based on motion detection and inactivity. The components are as follows:

Figure 6.4 - Lamp and motion sensor

Test video with cat:

Email Node Configuration

This Node-RED flow is set up to send an email notification when the state of a device changes (e.g., a lamp or pet feeder) (Figure 6.5).

Figure 6.5 - Email Node Configuration flow
  1. State Change Node: add a state_changed node to detect changes in a device (e.g., a lamp).
  1. Email Node Configuration (Figure 6.6):
Figure 6.6 - Email Node Configuration

ATTENTION: if it doesn’t work, check google account security settings!

Figure 6.7 - Email is sent

Test video with cat: https://youtube.com/shorts/93OIb3B-sbU?feature=share


7. InfluxDB: database. Graphics

InfluxDB is a special type of database designed to handle and store data that changes over time, known as time-series data.

Steps to Connect InfluxDB to Home Assistant

Figure 7.1 - InfluxDB: open WEB UI
Figure 7.2 - Configuration code for database InfluxDB

For example, we can observe temperature and humidity (Figure 7.3) (data from the sensor) changing through the day and plot the diagram (Figure 7.4).

Figure 7.3 - InfluxDB: choosing values
Figure 7.4 - InfluxDB: humidity diagram

Reference