Home Assistant

Raspberry Pi Projects

Project 5 — Home Automation with Home Assistant

What you will build A self-hosted smart home hub that unifies all your devices and lets you create powerful automations
Difficulty Intermediate — setup is guided, but automations reward patience
Time to complete 1 – 3 hours (plus time to explore)
Recommended hardware Raspberry Pi 4 (2 GB+ RAM), USB SSD strongly recommended over SD card

What is Home Assistant?

Home Assistant (HA) is an open-source home automation platform that runs entirely on your own hardware. It connects to thousands of smart home devices — lights, thermostats, sensors, cameras, door locks, voice assistants, and more — and lets you control them all from one interface, create automations ("when the sun sets, turn on the lounge lights"), and build dashboards tailored exactly to your home.

Unlike Amazon Alexa or Google Home, everything stays on your network. You own your data, your automations work without internet, and you are not at the mercy of a company shutting down its cloud service.

Home Assistant integrates with over 3,000 different devices and services — the largest ecosystem of any home automation platform.

Choosing an Installation Method

Home Assistant comes in four flavours. The differences matter — choose the wrong one and you'll hit limitations later:

Home Assistant OS Recommended
  • Dedicated OS — Pi runs nothing else
  • One-click add-on installation (HACS, Node-RED, Mosquitto, etc.)
  • Supervised updates — update HA itself from the dashboard
  • Automatic backups built in
  • Full support — all features available
  • Requires a dedicated Pi (can't share with web server etc.)
Home Assistant Container
  • Runs alongside other services on Raspberry Pi OS
  • Good if the Pi already has other roles
  • No add-on store — must manually install extras (Node-RED, MQTT, etc.)
  • No supervised updates from the dashboard
Home Assistant Supervised
  • Add-on store available
  • Runs on Debian alongside other software
  • Complex to maintain — officially "unsupported" if OS deviates from requirements
  • Easy to break with OS updates
Home Assistant Core
  • Runs in a Python virtualenv — maximum flexibility
  • Full control over the environment
  • No add-on store, no supervised updates
  • Manual dependency management
  • Recommended only for advanced users

This project uses Home Assistant OS — it is the official recommended installation and gives you access to every feature. You flash it directly to an SD card or SSD, just like Raspberry Pi OS.

What You Will Need

🍓 Raspberry Pi 4 (2 GB+) Pi 4 4 GB or 8 GB recommended. Pi 5 is excellent. Pi 3B+ works but is noticeably slower.
💾 USB SSD (recommended) HA writes frequently to storage. SD cards wear out fast under this load — a USB SSD lasts years longer and is much faster.
🔌 Wired Ethernet Strongly recommended. HA communicates with dozens of devices — a reliable network connection matters.
💻 Raspberry Pi Imager Used to flash the Home Assistant OS image. Download from raspberrypi.com/software.
🌐 A web browser Once running, all HA configuration is done through a web interface — no SSH or terminal needed for day-to-day use.
🏠 Smart home devices Philips Hue, IKEA Tradfri, Sonos, smart plugs, thermostats, door sensors — whatever you already own.
SSD boot on Pi 4: For USB SSD boot, you may need to update the Pi's bootloader first. Boot from a regular Raspberry Pi OS SD card, run sudo rpi-eeprom-update, and if an update is available install it with sudo rpi-eeprom-update -a then reboot. After that, the Pi will boot from USB SSD automatically if no SD card is inserted.

Step 1 — Flash Home Assistant OS

  1. Open Raspberry Pi Imager.
  2. Click Choose Device and select your Pi model.
  3. Click Choose OS → scroll down to Other specific-purpose OSHome assistants and home automationHome Assistant.
  4. Select the correct image for your hardware (e.g. Home Assistant OS 14.x (RPi 4)).
  5. Click Choose Storage and select your SSD or SD card.
  6. Click Next. Do not apply OS customisation settings — Home Assistant has its own first-run wizard. Click No if asked.
  7. Click Write and wait for it to complete.
Home Assistant OS takes over the entire drive. It is not a Raspberry Pi OS image — there is no desktop, no SSH by default, and no pi user. Everything is managed through the web interface.

Step 2 — First Boot

Insert the flashed SSD/SD card into your Pi and power it on. The first boot takes 5 – 20 minutes as Home Assistant downloads and installs itself. This is normal — the progress bar in the web interface moves slowly. Be patient.

Open a browser on any device on your network and go to:

http://homeassistant.local:8123
# If that doesn't resolve, use your Pi's local IP directly:
http://192.168.1.xx:8123

You'll see a preparation screen while HA installs. When it finishes, the setup wizard appears.

Finding your Pi's IP: check your router's connected devices list, or if you have Pi-hole you'll see it there. Alternatively, connect a screen and keyboard to the Pi — the IP address is shown on the console after boot.

Step 3 — Initial Setup Wizard

The wizard walks you through the one-time configuration:

  • Create your owner account — this is the master admin account. Choose a strong password and store it somewhere safe — there is no password reset without console access.
  • Name your home — give your home a name and set your location (city/country). This is used to calculate sunrise/sunset times for automations.
  • Set your units — metric or imperial, 12/24-hour clock, currency.
  • Discover devices — HA scans your network and lists smart home devices it found automatically. You can add them now or skip and add later. Don't worry if not everything is found — some devices need manual configuration.

Click Finish. You'll arrive at the Home Assistant dashboard for the first time.

Step 4 — Add Integrations

Integrations are how Home Assistant connects to your devices and services. Go to Settings → Devices & Services → Add Integration.

Popular integrations — search for these by name in the integration catalogue:

💡 Philips Hue Auto-discovered on local network. Click bridge button to authorise.
💡 IKEA Tradfri Zigbee or direct local API. No cloud account needed.
🔊 Sonos Auto-discovered. Full playback control and TTS announcements.
🌡 Nest / Google Home Thermostat, smoke detectors. Requires Google Cloud project setup.
🔌 TP-Link Kasa / Tapo Smart plugs and switches. Auto-discovered on local network.
📷 Frigate / ONVIF IP camera integration. Frigate adds AI object detection.
🌤 Met.no / OpenWeather Local weather sensors for automations (rain, temperature, UV).
📱 Mobile App Install on phone for presence detection, notifications, and phone sensors (battery, GPS).
🕳 Pi-hole Monitor your Pi-hole stats and control blocking from the HA dashboard.
🎬 Jellyfin / Plex Track what's playing and trigger automations (dim lights when playback starts).
🔒 Yale / August Smart locks — check status, auto-lock when you leave home.
Shelly Wi-Fi relays and energy monitors. Local API, no cloud required.
For Zigbee devices (many IKEA, Aqara, and Sonoff products): add a Zigbee USB coordinator dongle to your Pi (e.g. the Sonoff Zigbee 3.0 USB dongle, ~£15). Then install the Zigbee2MQTT or ZHA add-on. This lets HA communicate directly with Zigbee devices without needing any manufacturer hub.

Step 5 — Install Add-ons

Add-ons extend Home Assistant OS with additional services. Go to Settings → Add-ons → Add-on Store.

Add-onWhat it doesWhy you might want it
File EditorEdit YAML config files from the browserEssential — replaces SSH for most config tasks
Terminal & SSHSSH and web terminal accessAdvanced troubleshooting and scripting
Node-REDVisual flow-based automation editorMore powerful than the built-in automation editor for complex logic
Mosquitto BrokerMQTT message brokerRequired for MQTT-based devices (many DIY sensors, Tasmota firmware)
Zigbee2MQTTZigbee coordinator bridgeConnect Zigbee devices without a manufacturer hub
Studio Code ServerFull VS Code in the browserBest editor for complex YAML configurations
Samba ShareSMB network share of HA config folderEdit config files from Windows Explorer / Mac Finder

To install an add-on: click it in the store → click Install → toggle Start on boot → click Start.

Step 6 — Create Your First Automation

Automations are the heart of Home Assistant. Go to Settings → Automations & Scenes → Create Automation → Start with an empty automation.

Each automation has three parts:

💡 Turn on lounge lights at sunset Example automation
Trigger
Sun sets
Condition (optional)
Someone is home
Action
Turn on light.lounge
📱 Send notification when someone arrives home Example automation
Trigger
person.philip arrives home
Condition
Time is after 22:00
Action
Send push notification
🎬 Dim lights when Jellyfin starts playing Example automation
Trigger
media_player state → playing
Condition
Time is after 18:00
Action
Set brightness to 20%

Writing automations in YAML

The visual editor generates YAML behind the scenes. Click the </> button in an automation to switch to YAML view — this is useful for complex conditions and for copying automations from the HA community forums.

alias: "Turn on lounge at sunset"
trigger:
  - platform: sun
    event: sunset
    offset: "-00:30:00"       # 30 minutes before sunset
condition:
  - condition: state
    entity_id: group.all_people
    state: "home"
action:
  - service: light.turn_on
    target:
      entity_id: light.lounge
    data:
      brightness_pct: 80
      color_temp: 400         # warm white (mireds)

Step 7 — Customise Your Dashboard

The default dashboard is auto-generated from your entities. To build a custom one go to Settings → Dashboards → Add Dashboard, or click the pencil icon on an existing dashboard.

Useful card types to explore:

Card typeBest for
EntitiesSimple list of device states — great for a quick overview
GlanceCompact grid of icons — perfect for many sensors at once
ThermostatVisual temperature control for climate devices
Media ControlPlayback controls for Sonos, Plex, Jellyfin
History GraphLine chart of sensor values over time (temperature, humidity)
MapShows location of people/devices tracked via the mobile app
ButtonOne-tap trigger for scripts or scenes
EnergyVisualise electricity usage if you have smart plugs/meters
Install HACS (Home Assistant Community Store) for hundreds of additional card types and integrations created by the community. Go to Settings → Add-ons → Add-on Store and search for HACS, or follow the installation guide at hacs.xyz.

Step 8 — Remote Access

To access Home Assistant from outside your home you have two main options:

Option A — Nabu Casa (simplest, ~£5/month)

Home Assistant's official cloud subscription. In Settings → Home Assistant Cloud, click Sign in and create a Nabu Casa account. Remote access is then available immediately with no port forwarding — plus voice assistant integration with Alexa and Google Home. The subscription fee funds HA development.

Option B — Your own reverse proxy with SSL

If you completed Project 1 (web server) and have a domain, put Home Assistant behind your Apache/Nginx proxy. Forward port 8123 internally and serve it at https://ha.yourdomain.com. Home Assistant needs one extra setting in its config to trust the proxy:

pi@homeassistant:~$ # Edit /config/configuration.yaml via the File Editor add-on:

http:
  use_x_forwarded_for: true
  trusted_proxies:
    - 192.168.1.xx     # IP of your web server Pi

Option C — WireGuard (most secure)

If you completed Project 4, just connect to your home VPN and access HA at its local IP (http://192.168.1.xx:8123). No additional configuration needed — the VPN handles the security.

Step 9 — Backups

Home Assistant OS has a built-in backup system. Go to Settings → System → Backups → Create Backup.

Automate backups with an automation:

alias: "Weekly backup"
trigger:
  - platform: time
    at: "03:00:00"
condition:
  - condition: time
    weekday:
      - sun
action:
  - service: backup.create
Store backups somewhere other than the Pi itself — a USB drive, network share, or cloud storage (HA can automatically upload to Google Drive or Nextcloud via add-ons). If your SSD fails and your only backup was on it, you lose everything.

Troubleshooting Common Problems

⚠ homeassistant.local:8123 doesn't load after first boot
The first boot genuinely takes up to 20 minutes — Home Assistant downloads its own components on first run. Be patient and keep refreshing. If it hasn't appeared after 25 minutes: (1) Check the Pi has a working network connection — LEDs on the Ethernet port should be active. (2) Try the IP address directly instead of the hostname. (3) Check your router's device list to confirm the Pi received an IP address. (4) The SD card/SSD write may have failed — reflash and try again.
⚠ An integration is discovered but won't finish setting up
Most common cause: a firewall or VLAN on your router is blocking communication between the Pi and the device. Put your Pi and your smart home devices on the same network segment. For cloud integrations (Nest, Google), check that the OAuth redirect URI and API credentials are configured correctly in the cloud developer console — the HA documentation for each integration has exact instructions.
⚠ Automations don't trigger reliably
Check the Automation Traces — click the automation, then click Traces to see a step-by-step execution log of what happened (or didn't). Common issues: (1) Condition is blocking the action — the condition may be true when you don't expect it. (2) Trigger fires but the device is unavailable — check the device's entity state in Developer Tools → States. (3) Time-based triggers are off because HA's time zone is wrong — check Settings → System → General → Time Zone.
⚠ Entities show as "unavailable" after a restart
The device is not reachable on the network. Check: (1) The device is powered on. (2) It has the same IP as when it was configured — if it got a new IP, set a DHCP reservation for it in your router. (3) For Zigbee devices, the coordinator is running — check the ZHA or Zigbee2MQTT add-on is started. (4) For cloud integrations, re-authenticate in Settings → Devices & Services → click the integration → Re-authenticate.
⚠ Home Assistant is slow or the dashboard takes a long time to load
Check hardware: (1) If running from SD card, this is expected — move to a USB SSD for a dramatic speed improvement. (2) Run top via the Terminal add-on to see if a process is pegging the CPU. Recorder (the history database) can be resource-intensive — consider setting a shorter retention period in configuration.yaml: recorder: purge_keep_days: 7. (3) Too many integrations polling frequently can cause slowdowns — review your integrations and increase polling intervals where possible.
⚠ I locked myself out — forgot the admin password
Connect a screen and keyboard to the Pi. At the Home Assistant OS console prompt, type login to get a root shell. Then run: ha auth reset --username YOUR_USERNAME --password NEW_PASSWORD. Alternatively, restore from a backup (which is another reason backups are important!).
⚠ Configuration YAML has an error and HA won't start
Before restarting after any YAML edit, always validate: Developer Tools → YAML → Check Configuration. If HA is already in a broken state, connect to the Terminal add-on (or SSH) and run ha core check to see the error. YAML is sensitive to indentation — use spaces (not tabs) and be consistent. The Studio Code Server add-on highlights YAML errors in real time as you type.

Quick Reference

TaskWhere / Command
Add a new integrationSettings → Devices & Services → Add Integration
Add an add-onSettings → Add-ons → Add-on Store
Create an automationSettings → Automations & Scenes → Create Automation
Create a backupSettings → System → Backups → Create Backup
Restore from backupSettings → System → Backups → Upload backup
Check YAML configDeveloper Tools → YAML → Check Configuration
Reload config without restartDeveloper Tools → YAML → Reload All YAML
View entity statesDeveloper Tools → States
Call a service manuallyDeveloper Tools → Actions
View automation traceSettings → Automations → [click automation] → Traces
Update Home AssistantSettings → System → Updates
View system logsSettings → System → Logs
Web interfacehttp://homeassistant.local:8123
Config file location/config/configuration.yaml (via File Editor add-on)
SSH into HA OSInstall Terminal & SSH add-on, then ssh root@homeassistant.local