Home Assistant on Raspberry Pi 5: Event-Driven Architecture That Gets You Hired

The career reason to run Home Assistant has very little to do with home automation.

Home Assistant is an event-driven platform with a REST API, a WebSocket API, thousands of integrations, a state engine, and YAML configuration that follows the same patterns as Ansible, Kubernetes manifests and CI/CD pipelines. It’s an integration platform that also happens to turn lights on, and you don’t need a single smart bulb to get value from it: it can watch your Pi, alert you when something misbehaves and act as a notification hub for the rest of your homelab.

The quick answer for a Raspberry Pi 5: if the Pi is already your Docker host, install Home Assistant Container with the Compose file below (host networking, privileged, /run/dbus mounted), run docker compose up -d and open http://YOUR-PI-IP:8123. If the Pi will do nothing but Home Assistant, flash Home Assistant OS with Raspberry Pi Imager instead and get apps (formerly add-ons) and one-click restores. Both are officially supported; the next section helps you choose.

Career Value: Event-driven architecture is the backbone of modern enterprise systems — from Azure Event Grid and AWS EventBridge to Kafka streams and CI/CD pipelines. Integration Architects and Automation Engineers who can design event-driven workflows command £60-85k. Home Assistant teaches the same patterns: triggers, conditions, actions, state management, and API orchestration. When an interviewer asks about your experience with event-driven systems, “I run a Home Assistant instance that monitors infrastructure and orchestrates automated responses” is a concrete, demonstrable answer.

docker-compose.yml used in the guide: Home Assistant on Raspberry Pi 5: Event-Driven A
The base docker-compose.yml for this guide. The current copy-paste version, with the settings from the official docs, is in the installation section below.

What You’ll Learn

  • Choosing between Home Assistant OS and Home Assistant Container on a Pi 5
  • Deploying Home Assistant Container with Docker Compose, and why it uses host networking
  • Running the things add-ons used to give you as ordinary containers
  • YAML configuration patterns that mirror enterprise config management
  • Useful automations without any smart home devices
  • The Home Assistant REST API and webhooks for external integrations
  • Putting Home Assistant behind a reverse proxy without the 400 Bad Request error
  • Database size, backups, updates and the Pi 5-specific failure modes

Home Assistant OS or Container on a Pi 5?

Since 2025.12, Home Assistant supports exactly two installation methods: Home Assistant OS and Home Assistant Container. Core (a Python virtual environment) and Supervised were deprecated in 2025.6 and became unsupported in 2025.12, so guides that install “Supervised on Docker” on a Pi are walking you into an unsupported setup.

Home Assistant OS Home Assistant Container
What it is A complete OS image that takes over the Pi One Docker container on your existing OS
Install Raspberry Pi Imager > Other specific-purpose OS > Home automation > Home Assistant (pick the RPi 5 image) Docker Compose, as below
Apps (add-ons) Yes, from the UI No; run the equivalent containers yourself
Backups Full system, including apps, restored from the UI Home Assistant settings and history only
Shares the Pi with other services No Yes
Best for A dedicated smart home hub A homelab Pi already running Docker

This series builds a homelab: your Pi already runs Docker, Portainer, Pi-hole and a reverse proxy. HAOS would wipe all of that, so this guide uses Container. You lose the Supervisor and its app store, but every popular app is just a container you can run alongside it with more control. That’s the same trade-off enterprises make constantly: managed convenience against operational control.

Prerequisites

  • A Raspberry Pi 5 with the official 27W USB-C power supply. Home Assistant’s own Pi page asks for at least 2 GB of RAM; on a shared Docker host, 4 GB leaves room for the rest of this series and 8 GB is for when you add heavier services such as local AI.
  • A 64-bit OS: Raspberry Pi OS (64-bit) or Ubuntu Server. Home Assistant stopped building 32-bit (armv7/armhf) images after 2025.12.
  • Docker and the Compose plugin installed (see Project 1)
  • Basic familiarity with YAML

An SSD or NVMe drive is worth it here. Home Assistant writes state changes to its database every few seconds, which is exactly the workload that wears out SD cards; the official docs’ minimum for SD is a 32 GB A2-rated card.

You do not need any smart home devices.

Confirm the architecture before you pull anything:

dpkg --print-architecture
docker compose version

# Representative output:
# arm64
# Docker Compose version v2.x.x

If the first line says armhf, you’re on 32-bit Raspberry Pi OS and the pull fails with no matching manifest for linux/arm/v7. Reflash with the 64-bit image first.

Installation: Docker Compose Setup

Create the project directory:

mkdir -p ~/homeassistant
cd ~/homeassistant

Create docker-compose.yml. This follows the official Container instructions:

services:
  homeassistant:
    container_name: homeassistant
    image: ghcr.io/home-assistant/home-assistant:stable
    restart: unless-stopped
    stop_grace_period: 60s       # give HA time to close its database cleanly
    privileged: true             # USB radios (Zigbee/Z-Wave) and Bluetooth
    network_mode: host           # device discovery; see below
    volumes:
      - ./config:/config
      - /etc/localtime:/etc/localtime:ro
      - /run/dbus:/run/dbus:ro   # needed for the Bluetooth integration
    environment:
      TZ: Europe/London
      # Uncomment only if you hit the jemalloc page-size error (troubleshooting)
      # DISABLE_JEMALLOC: "true"

Launch it and check it answers:

docker compose up -d
docker compose logs -f homeassistant   # Ctrl+C to stop following
curl -sI http://localhost:8123 | head -n 1

# Representative output once it's up:
# HTTP/1.1 200 OK

The first start takes longer while it creates the configuration and database. Then open http://<your-pi-ip>:8123 and you’ll see the onboarding wizard. Create your account, set your location (this drives sunrise and sunset automations later), and you’re in.

Why network_mode: host?

This is the line that confuses people, and it comes up in enterprise networking conversations too.

Normally, Docker containers get their own virtual network. They’re isolated from the host and from each other unless you publish ports, which is least privilege applied to networking.

Home Assistant discovers devices with mDNS, SSDP and other multicast and broadcast protocols. Those only work on the same network segment as the devices, and Docker’s bridge network doesn’t forward multicast, so behind a bridge Home Assistant is effectively deaf to your LAN. network_mode: host removes that isolation: the container shares the Pi’s network stack, same IP and same broadcast domain. That’s also why there’s no ports: section: Home Assistant binds port 8123 directly on the Pi.

The trade-off is that you lose port isolation. If something else already uses 8123, you have a conflict to resolve.

Enterprise Parallel: This is the same decision you face with Kubernetes pod networking. Host networking (hostNetwork: true in a pod spec) gives direct access to the node’s network but sacrifices isolation. Understanding when to use it — and when not to — is a genuine interview topic for infrastructure roles.

No Add-ons in Container: Run Them as Containers

The official docs are blunt: Home Assistant Container “does not have access to apps” (the new name for add-ons). That’s the most common surprise for people coming from HAOS tutorials. Each popular app is an ordinary image you can run in its own Compose stack:

HAOS app Run it on Docker as
Mosquitto MQTT broker eclipse-mosquitto
Zigbee2MQTT koenkk/zigbee2mqtt
ESPHome ghcr.io/esphome/esphome
File editor / Studio Code Server Edit ~/homeassistant/config over SSH, e.g. VS Code Remote-SSH
Nginx Proxy Manager The Project 4 stack you may already have

Then connect each one through the matching integration in Settings > Devices & services. For a USB Zigbee or Z-Wave stick, map it by its stable path under /dev/serial/by-id/ rather than /dev/ttyUSB0, which can change between reboots.

YAML Configuration: Enterprise Config Management Patterns

The configuration system uses YAML, the same language behind Ansible playbooks, Kubernetes manifests, Docker Compose files and GitHub Actions. If you can write Home Assistant config, you can read any of those.

Your configuration lives in ~/homeassistant/config/configuration.yaml:

# configuration.yaml - Main Home Assistant config
# This is your "single source of truth" for the platform

homeassistant:
  name: Homelab
  unit_system: metric
  currency: GBP
  country: GB
  time_zone: Europe/London

# Enable the default set of integrations
default_config:

# Split configuration into separate files
# This is the same pattern as Ansible roles or K8s resource directories
automation: !include automations.yaml
script: !include scripts.yaml
scene: !include scenes.yaml
command_line: !include command_line.yaml

The !include directives split configuration across files, the same organisational pattern you use when an Ansible playbook or a set of Kubernetes manifests gets too long. Settings you put under homeassistant: in YAML become read-only in the UI, which is the config-as-code trade-off in miniature.

System Sensors: Monitoring Without Smart Devices

Start with the built-in System Monitor integration. It is no longer configured in YAML: go to Settings > Devices & services > Add integration, add System monitor, then open its entities and enable the ones you want (they are all disabled by default). Enable at least Processor use, Memory usage, Disk usage /, Processor temperature and Last boot. Their entity IDs look like sensor.system_monitor_processor_use; check the exact IDs under Settings > Entities and adjust the automations below if yours differ.

For anything System Monitor does not cover, use a command-line sensor. Create command_line.yaml in the config directory (this uses the current format, where command_line is its own top-level key; the old - platform: command_line style under sensor: was removed in 2023):

# command_line.yaml - included from configuration.yaml
- sensor:
    name: "System Load Average"
    command: "cut -d' ' -f1 /proc/loadavg"
    scan_interval: 30
    unit_of_measurement: "load"

Gotcha: The command_line sensor runs commands inside the Home Assistant container, not on the host, so only tools that exist in the container image are available. The container does not include the docker CLI, so a docker ps sensor will not work even if you mount the Docker socket, and mounting the socket gives the container root-level control of Docker anyway — the same security consideration you’d evaluate in any enterprise deployment. For container health, use Uptime Kuma or Portainer from this series instead.

Before restarting after a YAML change, validate it. Either use Developer Tools > YAML > Check configuration, or from the Pi:

docker exec homeassistant python -m homeassistant --script check_config --config /config
docker restart homeassistant

A YAML syntax error can stop Home Assistant starting, and debugging a container that won’t boot is more frustrating than validating first. Same principle as nginx -t before nginx -s reload.

Building Automations: The “When X, If Y, Do Z” Mental Model

Every automation has three parts:

  1. Trigger (When X): the event that starts it
  2. Condition (If Y): optional checks before proceeding
  3. Action (Do Z): what happens

This is the pattern behind every enterprise automation system:

  • CI/CD: “When code is pushed (trigger), if tests pass (condition), deploy to staging (action)”
  • Azure Event Grid: “When a blob is created (trigger), if it’s in the uploads container (filter), run the processing function (action)”
  • n8n/Zapier: “When a webhook fires (trigger), if the payload contains X (filter), create a ticket (action)”

Here are practical automations that need no smart devices. They use the current syntax (triggers: / trigger:, actions: / action:, as in the automation YAML docs); older examples with platform: and service: still load, but this is what the UI writes today:

# automations.yaml
# Alert when CPU temperature gets too high
- id: 'cpu_temp_alert'
  alias: 'High CPU Temperature Alert'
  description: 'Send notification when Pi CPU exceeds 75°C'
  triggers:
    - trigger: numeric_state
      entity_id: sensor.system_monitor_processor_temperature
      above: 75
      for:
        minutes: 5
  conditions:
    - condition: time
      after: '07:00:00'
      before: '23:00:00'
  actions:
    - action: notify.notify
      data:
        title: "Pi 5 Temperature Warning"
        message: >
          CPU temperature has been above 75°C for 5 minutes.
          Current: {{ states('sensor.system_monitor_processor_temperature') }}°C.
          Check cooling and workload.

# Alert when disk usage gets high
- id: 'disk_usage_alert'
  alias: 'Disk Usage Warning'
  description: 'Warn when root filesystem exceeds 85%'
  triggers:
    - trigger: numeric_state
      entity_id: sensor.system_monitor_disk_usage
      above: 85
  actions:
    - action: notify.notify
      data:
        title: "Disk Space Warning"
        message: >
          Root filesystem is at {{ states('sensor.system_monitor_disk_usage') }}%.
          Time to clean up or expand storage.

# Daily system health report
- id: 'daily_health_report'
  alias: 'Daily Infrastructure Report'
  description: 'Send a morning summary of system health'
  triggers:
    - trigger: time
      at: '08:00:00'
  actions:
    - action: notify.notify
      data:
        title: "Morning Infrastructure Report"
        message: >
          CPU: {{ states('sensor.system_monitor_processor_use') }}%
          Memory: {{ states('sensor.system_monitor_memory_usage') }}%
          Disk: {{ states('sensor.system_monitor_disk_usage') }}%
          Temp: {{ states('sensor.system_monitor_processor_temperature') }}°C
          Uptime since: {{ states('sensor.system_monitor_last_boot') }}

Pro Tip: The for: parameter on the temperature trigger prevents flapping alerts — it only fires if the condition has been true for 5 continuous minutes. This is the same concept as alert dampening in Prometheus/Alertmanager or evaluation windows in Azure Monitor. Learning to set appropriate thresholds and dampening periods is an operational skill that takes practice.

Setting Up Notifications

The automations above use notify.notify, which needs configuring. The simplest option for a homelab is Telegram. First add the Telegram bot integration in the UI (Settings > Devices & services > Add integration > Telegram bot, choose the polling platform, paste the token from BotFather, then add your chat ID to its allowed chats); current versions no longer take the bot’s own settings in YAML. Then add the notifier to configuration.yaml:

# Telegram notifier (needs the Telegram bot integration set up in the UI first).
# Home Assistant marks this notify platform as legacy; it still works, and the
# newer alternative is the notify.send_message action on the bot's notify entity.
notify:
  - platform: telegram
    name: notify
    chat_id: !secret telegram_chat_id

And create secrets.yaml in the config directory:

# secrets.yaml - NEVER commit this file to Git
telegram_chat_id: "your-chat-id"

The !secret pattern separates secrets from configuration, the same principle as environment variables, Azure Key Vault or HashiCorp Vault in enterprise deployments.

The API: Connecting Home Assistant to Everything

Home Assistant exposes a REST API on the same port (8123). This is where it becomes useful as an integration platform.

Create a long-lived access token: open your profile (bottom-left), go to the Security tab, scroll to Long-lived access tokens and create one. It is only shown once, so store it securely.

Test it first. The API root returns a fixed message when your token works:

curl -s -H "Authorization: Bearer YOUR_TOKEN" http://your-pi-ip:8123/api/

# Expected:
# {"message":"API running."}
# A 401 means the token is wrong or was pasted with a line break.

Now you can query and control Home Assistant from anywhere on your network:

# Get all sensor states
curl -s -H "Authorization: Bearer YOUR_TOKEN" \
  http://your-pi-ip:8123/api/states | python3 -m json.tool

# Get a specific sensor
curl -s -H "Authorization: Bearer YOUR_TOKEN" \
  http://your-pi-ip:8123/api/states/sensor.system_monitor_processor_temperature

# Fire an event (trigger automations externally)
curl -X POST \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"message": "Deployment complete"}' \
  http://your-pi-ip:8123/api/events/custom_deployment_event

# Call an action (the API path still says "services")
curl -X POST \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"title": "Test", "message": "API notification works"}' \
  http://your-pi-ip:8123/api/services/notify/notify

That last one is particularly useful. Any script, cron job or CI/CD pipeline can send a notification by hitting the API. Backup finished? POST to the API. Health check failed? POST to the API. Home Assistant becomes the notification hub for your whole homelab. The full endpoint list is in the REST API developer docs.

Connecting to n8n: Advanced Workflow Orchestration

If you’re running n8n from Project 9, the combination with Home Assistant is where things get properly interesting. n8n handles complex multi-step workflows; Home Assistant handles real-time events and state.

n8n Calling Home Assistant

Use n8n’s Home Assistant node or an HTTP Request node with your long-lived token to query HA’s API, for example a workflow that checks system health every hour and posts a summary to Telegram, Slack or email.

Home Assistant Triggering n8n

Create a webhook in n8n, then a Home Assistant automation that POSTs to it. Now Pi events can trigger multi-step workflows: HA detects high memory use, calls the n8n webhook, and n8n gathers diagnostics and sends a report.

This is a real integration architecture pattern: the event source (HA) decoupled from the processing logic (n8n) via a webhook. It’s the same shape as Azure Event Grid triggering a Logic App, or an EventBridge rule triggering a Step Function.

# Automation that triggers an n8n workflow via webhook
- id: 'n8n_memory_alert'
  alias: 'Trigger n8n Memory Investigation'
  triggers:
    - trigger: numeric_state
      entity_id: sensor.system_monitor_memory_usage
      above: 90
      for:
        minutes: 2
  actions:
    - action: rest_command.trigger_n8n
      data:
        payload: >
          {{ states('sensor.system_monitor_memory_usage') }}

With the corresponding REST command in configuration.yaml:

rest_command:
  trigger_n8n:
    url: "http://your-pi-ip:5678/webhook/memory-alert"
    method: POST
    content_type: "application/json"
    payload: '{"memory_percent": "{{ payload }}", "hostname": "pi5"}'

Home Assistant Behind a Reverse Proxy

If you followed Project 4: Nginx Proxy Manager, you’ll want https://ha.home.arpa instead of an IP and port. Create the proxy host with scheme http, your Pi’s LAN IP, port 8123, and Websockets Support turned on (the whole frontend runs over a websocket). Then open it, and you’ll most likely get:

400: Bad Request

Home Assistant refuses proxied requests until it’s told to trust the proxy. The log (Settings > System > Logs, or docker logs homeassistant) tells you exactly what it saw:

A request from a reverse proxy was received from 172.18.0.2, but your HTTP integration is not set-up for reverse proxies

Add an http: block to configuration.yaml trusting that address, as described in the HTTP integration docs:

http:
  use_x_forwarded_for: true
  trusted_proxies:
    - 172.18.0.0/16   # the Docker network NPM runs on; match the IP in your log
    - 127.0.0.1

Because Home Assistant uses host networking, requests from an NPM container arrive from NPM’s address on its Docker network, not from the Pi’s LAN IP, which is why the log line is the reliable source for this value. Check the config and restart. If the log now says Received X-Forwarded-For header from an untrusted proxy, the range you listed doesn’t include the address NPM is connecting from.

Gotchas and Troubleshooting

Database Growth: The Silent Disk Eater

Home Assistant records state changes in a SQLite database, home-assistant_v2.db in the config folder. By default the recorder keeps 10 days and purges nightly at 04:12, so it doesn’t grow forever, but chatty sensors (network throughput updating every few seconds, for example) can still make 10 days surprisingly large on a Pi. Check it with:

du -h ~/homeassistant/config/home-assistant_v2.db

Then trim what you record in configuration.yaml:

# Recorder configuration - control what gets stored and for how long
recorder:
  purge_keep_days: 7
  commit_interval: 30     # seconds; default is 5. Fewer, larger writes are kinder to SD cards
  exclude:
    domains:
      - automation
    entity_globs:
      - sensor.system_monitor_network_*

Seven days of detailed history is plenty for a homelab. For long-term metrics, export to InfluxDB or Prometheus, which are built for time-series data.

Pi 5: “<jemalloc>: Unsupported system page size”

Raspberry Pi OS runs the Pi 5 with a 16K memory page size kernel, where most systems use 4K. The Home Assistant container uses the jemalloc memory allocator, and the official docs note that it can fail on hardware with a page size larger than 4K, with <jemalloc>: Unsupported system page size as the known sign. Check your page size with getconf PAGESIZE (16384 means 16K). If you see that error in docker compose logs, uncomment DISABLE_JEMALLOC: "true" in the Compose file and run docker compose up -d.

Devices aren’t discovered

Check that network_mode: host is set and that you haven’t added a ports: section (the two don’t mix). Discovery relies on multicast, which a bridge network blocks.

Bluetooth doesn’t work in Docker

The Bluetooth integration talks to the host’s BlueZ stack over D-Bus. You need the /run/dbus:/run/dbus:ro mount from the Compose file and the Bluetooth service running on the Pi: systemctl status bluetooth should show active (running).

Home Assistant won’t start after a config change

# See why
docker logs homeassistant --tail 50

# Validate the config without starting HA
docker exec homeassistant python -m homeassistant --script check_config --config /config

The usual YAML errors: indentation with tabs (YAML needs spaces), missing colons, and unquoted strings containing special characters. You’ll make the same mistakes in Ansible and Kubernetes manifests, so learning to spot them now pays off.

Port 8123 already in use

With host networking, HA binds 8123 directly on the Pi. Find what else has it:

sudo ss -tlnp | grep 8123

Move that service, or change HA’s port with server_port under the http: section of configuration.yaml.

Locked out of your account

Follow the official “I’m locked out” guide, which covers Container installs.

Backups

Home Assistant’s built-in backups work on Container too. Go to Settings > System > Backups and select Set up backups. Download the emergency kit first: backups are encrypted by default and you can’t restore them without its key. The recommended settings take a daily backup and keep the last three. On Container they land in ~/homeassistant/config/backups/, and they contain Home Assistant’s settings and, optionally, history; the separate containers you run for MQTT or Zigbee2MQTT need their own backups.

A backup on the same SD card as the thing it protects isn’t a backup, so copy that folder somewhere else on a schedule:

#!/bin/bash
# Copy Home Assistant's own backups off the Pi - add to cron
set -euo pipefail

DEST="/mnt/backup/homeassistant"   # NAS mount, USB drive, etc.

mkdir -p "$DEST"
rsync -a ~/homeassistant/config/backups/ "$DEST/"

# Keep 14 days of copies
find "$DEST" -name "*.tar" -mtime +14 -delete

echo "Copied Home Assistant backups to $DEST"

Know what you lose if you only back up YAML. Copying just your .yaml files is not enough. Integrations, users, dashboards and devices you set up in the UI live in config/.storage/, and history plus long-term statistics (the energy dashboard, for example) live in the database. Home Assistant creates a fresh, empty database if one is missing, so a YAML-only restore boots, but without that data. Restore Container backups with the same or a newer Home Assistant version; the Container docs cover downgrades.

Updating Home Assistant Container

cd ~/homeassistant
docker compose pull homeassistant
docker compose up -d

Take a backup first and read the “Backward-incompatible changes” section of the release notes for every version you’re jumping. Afterwards, check Settings > System > Repairs and the logs. If you’d rather choose when updates happen, pin a version tag (for example ghcr.io/home-assistant/home-assistant:2026.10.4) instead of stable.

Cheat Sheet

Task Command or location
Check 64-bit OS dpkg --print-architecture (want arm64)
Web UI http://PI-IP:8123
Config folder ~/homeassistant/config/
Validate config docker exec homeassistant python -m homeassistant --script check_config --config /config
Logs docker logs homeassistant --tail 50
Update docker compose pull homeassistant && docker compose up -d
Test API token curl -s -H "Authorization: Bearer TOKEN" http://PI-IP:8123/api/
Backups Settings > System > Backups; files in config/backups/
400 Bad Request behind a proxy http: > use_x_forwarded_for + trusted_proxies
jemalloc page size error DISABLE_JEMALLOC: "true"

What You’ve Actually Learned

  • Event-driven architecture — Triggers, conditions, actions. The foundation of reactive systems from Azure Functions to Kafka consumers.
  • YAML configuration management — File splitting, includes, secrets management. Directly transferable to Ansible, Kubernetes, and CI/CD pipelines.
  • API integration — REST APIs, authentication tokens, webhook patterns. The glue that connects every enterprise system.
  • State management — Understanding that entities have states that change over time, and building logic around state transitions.
  • Operational monitoring — Using automation to watch your own infrastructure and alert on problems. The basis of every SRE practice.
  • Network architecture decisions — Host networking vs bridge networking, trusted proxies, and the security/functionality trade-offs involved.

None of these skills are specific to home automation. All of them appear on job descriptions for DevOps Engineers, Platform Engineers, Integration Architects, and SREs.

The RTM Essential Stack - Gear I Actually Use

Where to Go Next

Home Assistant becomes significantly more powerful when connected to other services in your homelab:

  • Project 6: Ollama — Use HA events as triggers for AI-powered analysis. “When a service fails, ask the LLM to summarise recent logs.”
  • Project 7: Uptime Kuma — Feed uptime data into HA for unified monitoring dashboards and cross-system alerting.
  • Project 9: n8n — The combination of HA’s real-time event engine with n8n’s multi-step workflow orchestration covers almost every automation scenario.

The pattern emerging here — loosely coupled services communicating via APIs and webhooks — is microservices architecture in miniature. You’re building it on a computer that fits in your hand, but the architectural patterns are identical to what runs behind every major platform you use.

That’s the real career value. Not the technology. The thinking.

Enjoyed this guide?

New articles on Linux, homelab, cloud, and automation every 2 days. No spam, unsubscribe anytime.

Scroll to Top