Home Assistant
Raspberry Pi Projects
Project 5 — Home Automation with Home Assistant
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:
- 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.)
- 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
- 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
- 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
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
- Open Raspberry Pi Imager.
- Click Choose Device and select your Pi model.
- Click Choose OS → scroll down to Other specific-purpose OS → Home assistants and home automation → Home Assistant.
- Select the correct image for your hardware (e.g. Home Assistant OS 14.x (RPi 4)).
- Click Choose Storage and select your SSD or SD card.
- Click Next. Do not apply OS customisation settings — Home Assistant has its own first-run wizard. Click No if asked.
- Click Write and wait for it to complete.
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.
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:
Step 5 — Install Add-ons
Add-ons extend Home Assistant OS with additional services. Go to Settings → Add-ons → Add-on Store.
| Add-on | What it does | Why you might want it |
|---|---|---|
| File Editor | Edit YAML config files from the browser | Essential — replaces SSH for most config tasks |
| Terminal & SSH | SSH and web terminal access | Advanced troubleshooting and scripting |
| Node-RED | Visual flow-based automation editor | More powerful than the built-in automation editor for complex logic |
| Mosquitto Broker | MQTT message broker | Required for MQTT-based devices (many DIY sensors, Tasmota firmware) |
| Zigbee2MQTT | Zigbee coordinator bridge | Connect Zigbee devices without a manufacturer hub |
| Studio Code Server | Full VS Code in the browser | Best editor for complex YAML configurations |
| Samba Share | SMB network share of HA config folder | Edit 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:
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 type | Best for |
|---|---|
| Entities | Simple list of device states — great for a quick overview |
| Glance | Compact grid of icons — perfect for many sensors at once |
| Thermostat | Visual temperature control for climate devices |
| Media Control | Playback controls for Sonos, Plex, Jellyfin |
| History Graph | Line chart of sensor values over time (temperature, humidity) |
| Map | Shows location of people/devices tracked via the mobile app |
| Button | One-tap trigger for scripts or scenes |
| Energy | Visualise electricity usage if you have smart plugs/meters |
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
Troubleshooting Common Problems
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.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!).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
| Task | Where / Command |
|---|---|
| Add a new integration | Settings → Devices & Services → Add Integration |
| Add an add-on | Settings → Add-ons → Add-on Store |
| Create an automation | Settings → Automations & Scenes → Create Automation |
| Create a backup | Settings → System → Backups → Create Backup |
| Restore from backup | Settings → System → Backups → Upload backup |
| Check YAML config | Developer Tools → YAML → Check Configuration |
| Reload config without restart | Developer Tools → YAML → Reload All YAML |
| View entity states | Developer Tools → States |
| Call a service manually | Developer Tools → Actions |
| View automation trace | Settings → Automations → [click automation] → Traces |
| Update Home Assistant | Settings → System → Updates |
| View system logs | Settings → System → Logs |
| Web interface | http://homeassistant.local:8123 |
| Config file location | /config/configuration.yaml (via File Editor add-on) |
| SSH into HA OS | Install Terminal & SSH add-on, then ssh root@homeassistant.local |