Home Assistant on A Raspberry Pi

Again, amazing China. This time, Nanjing. What a city!!!!!

Ancient Qinhuai @ Qinhuai River, Nanjing Ancient Qinhuai @ Qinhuai River, Nanjing
GuQinHuai 01 GuQinHuai 02
WanQingLou LiXiangJun
Lights 01 Lights 02
Lights BaiLuZhou QinHuaiRenJia 01
QinHuaiRenJia 02 QinHuaiRenJia 03
NanjingSouth High Speed Train Railway Station Exterior NanjingSouth High Speed Train Railway Station Inside
Nanjing Old Station Renovated ChangYu Noodle

Raspberry Pi has already well-established a comprehensive community support world wide. Among ALL the operating systems supporting Raspberry Pi, Home Assistant stands out, shining brightly as an open-source home automation operating system in the field of IoT.

1. Overview

1.1 What is Home Assistant?

Home Assistant is the ``open source home automation that puts local control and privacy first. Powered by a worldwide community of tinkerers and DIY enthusiasts. Perfect to run on a Raspberry Pi or a local server.'' (cited from first page of the official website of Home Assistant.)

Home Assistant OS is a minimal operating system optimized for running Home Assistant, and it does not use traditional package management systems like apt. Instead, it relies on Docker containers to manage and run services, including Home Assistant and its add-ons.

1.2 Web UI

After simply flashed Home Assistant OS 12.3 onto a 16GB TF card and insert it into my old Raspberry Pi 3B V1.2, we can now take a brief look at Home Assistant web UI at http://homeassistant.local:8123/.

Home Assistant Overview Home Assistant Dashboard
Home Assistant Overview Home Assistant Dashboard
Home Assistant Terminal SSH Home Assistant Run Terminal SSH

2. ssh Into Home Assistant OS

2.1 Configuration

2.1.1 Installation of Home Assistant Add-on Terminal & SSH

Please have the add-on Home Assistant Add-on Terminal & SSH installed from Home Assistant -> Settings -> Add-ons.

2.1.2 Edit in YAML

Please do remember to add these 2 lines:

1
2
3
ssh:
enable: true
port: 22

at the end of the YAML configuration:

1
2
3
4
5
6
7
8
authorized_keys: []
password: []
apks: []
server:
tcp_forwarding: false
ssh:
enable: true
port: 22

2.2 ssh Into Home Assistant OS From Remote Desktop

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
➜  ~ ssh root@192.168.1.83
The authenticity of host '192.168.1.83 (192.168.1.83)' can't be established.
ED25519 key fingerprint is SHA256:MZDkXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXJmxE.
This key is not known by any other names.
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added '192.168.1.83' (ED25519) to the list of known hosts.

▄██▄ _ _
▄██████▄ | | | | ___ _ __ ___ ___
▄████▀▀████▄ | |_| |/ _ \| '_ ` _ \ / _ \
▄█████ █████▄ | _ | (_) | | | | | | __/
▄██████▄ ▄██████▄ |_| |_|\___/|_| |_| |_|\___| _
████████ ██▀ ▀██ / \ ___ ___(_)___| |_ __ _ _ __ | |_
███▀▀███ ██ ▄██ / _ \ / __/ __| / __| __/ _` | '_ \| __|
██ ██ ▀ ▄█████ / ___ \\__ \__ \ \__ \ || (_| | | | | |_
███▄▄ ▀█ ▄███████ /_/ \_\___/___/_|___/\__\__,_|_| |_|\__|
▀█████▄ ███████▀

Welcome to the Home Assistant command line.

System information
IPv4 addresses for enu1u1: 192.168.1.83/24
IPv6 addresses for enu1u1: 2001:569:5993:5900:1b4a:e1e6:140c:aac0/64, fe80::ab1f:8f98:b81:a479/64
IPv4 addresses for wlan0:
IPv4 addresses for wlu1u4:

OS Version: Home Assistant OS 12.3
Home Assistant Core: 2024.5.5

Home Assistant URL: http://homeassistant.local:8123
Observer URL: http://homeassistant.local:4357
[core-ssh ~]$

3. ESPHome with Home Assistant

One of my very old blogs LVT ESP32-Cam has talked about ESP32 Camera. Today, I found that blog posted 4 years ago before COVID-19, and I’m trying to integrate some of my [ESP32 Cameras] into Home Assistant. Namely, use Home Assistant running on the Raspberry Pi to manage a couple of my ESP32 Cameras.

3.1 ESP32 Boards Management

Please ensure the following 2 boards support have been installed successfully.

Arduino IDE Esp32

3.2 CameraWebServer

Current ESP32 Examples provide an webcam server example: ESP32 Example CameraWebServer. Or, we can simply open up the example from within Arduino IDE: File->Examples->ESP32->Camera->CameraWebServer.

3.2.1 Four ESP32 Cameras

Both are compatible with the configuration CAMERA_MODEL_AI_THINKER in ESP32 Example CameraWebServer. Therefore, three places are to be correctly setup:

  • #define CAMERA_MODEL_AI_THINKER // Has PSRAM
  • const char *ssid = "XXXXXXXXX";
  • const char *password = "YYYYYYYYY";

3.2.2 Verify and Upload

Verify

Upload

3.2.3 Demonstration

CameraWebServer

However, as you can see, the captured image is not quite stable. And, I did find the WiFi connection is easy to get disconnected. What to do???

[!NOTE:] What to do??? Please continue reading.

3.3 RTSP with MJPEG

As of today, June 4, 2024, there is NO H.264 or H.265 streaming server support. Therefore, I’m going to follow the following 2 blogs and build up RTSP server with MJPEG video streams.

3.4 Integrate ESPHome Into Home Assistant

Getting Started with ESPHome and Home Assistant

3.5 Demonstration

ESPHome ESPHome
ESPHome Build Failed ESPHome Compile
ESPHome Device Discovered ESPHome Device Info
ESPHome Devices ESPHome Flash
ESPHome Installation ESPHome Install Connecting Hang
ESPHome Installed 3232 Connection Refused ESPHome Visit
Home Assistant Overview Home Assistant Media Live
ESPHome ESP32Cam Configured ESPHome ESP32Cam Integrated