# Home automation got cheap: Home Assistant on a Pi with Claude

*Essay · 2026-11-03 · 7 min read · https://guilherme-andrade.com/writing/home-automation-got-cheap/*

None of this is new. Home Assistant has been around for years, ESP32 boards have cost about ten euros for a long time, and people were watering gardens with relays long before AI. What changed for me is how little time and money it now takes to go from "I wish the house did this" to a working, reliable setup.

I run Home Assistant on a Raspberry Pi at home, and I didn't write most of its configuration by hand. Claude Code did. My job was to describe what I wanted, check the result, and keep it safe.

This is what that looks like, what it costs, and what I'd tell anyone starting.

## Why it got cheap

The parts were never the expensive bit. The expensive bit was getting them to work.

A few years ago a project like an automatic watering valve went roughly like this. You read forum threads to guess which board, relay and power supply would work together. You bought them, sometimes the wrong ones, sometimes pricier ones because you didn't trust the cheap option. You wired it up and occasionally fried something with the wrong voltage. Then you copied code you didn't fully understand, flashed it, watched it fail, and changed things until it worked, without always knowing why it finally did. Each failed attempt cost a part, an evening or both, and plenty of projects died somewhere in that loop.

AI removes the most error-prone steps of that loop:

- **Choosing parts.** It checks compatibility, voltages and pinouts before you buy, and compares shops. In my case it priced the parts live and even caught its own mistake: it had compared a bare ESP32 module with a full dev board, which made one shop look 40% cheaper than it really was.
- **Wiring.** It explains which pin goes where and why, and flags the step that would destroy a board, like feeding 12 V to a 5 V input.
- **Code you can read.** The configuration it writes is plain YAML that it can explain line by line, instead of a sketch pasted from a forum.
- **Debugging.** It reads the logs and narrows a failure down to a cause, so a fix takes one attempt instead of ten.

The hardware costs what it always did, tens of euros. What dropped is the number of attempts, the broken parts and the evenings, and that is most of what a project used to cost.

## The setup: Home Assistant as code

Home Assistant runs well on a Raspberry Pi with HA OS. The one habit that makes working with an AI agent safe is keeping your configuration as code: YAML files in a git repository on your laptop, copied to the Pi with a small deploy script. Every change is a diff you can read, and every mistake is one revert away.

A few things make that setup easy to live with:

- **One file per area.** Watering in one file, heating in another, notifications in a third. Changes stay small and easy to review.
- **Validate before reloading.** Home Assistant can check its own configuration. Make the deploy script run that check first, so a broken config never goes live.
- **Write down the clicks.** Some steps only exist in the UI, like pairing a device or signing in to a vendor account. Keep them as a checklist in the README instead of pretending they're code.

## Keeping it secure

A home system has cameras, door and gate controls, and your Wi-Fi password in it. The rules I follow are simple, and none of them need special skills:

1. **Don't open ports to the internet.** You don't need them. Remote access goes through [Tailscale](https://tailscale.com): the Pi makes an outbound connection to a private network, and your phone reaches Home Assistant through that network from anywhere. Nothing in your home listens to the public internet.
2. **Keep secrets out of the repository.** Passwords, tokens and Wi-Fi keys live in a `secrets.yaml` that git ignores. The repo carries a `secrets.yaml.example` with the same shape and fake values, so the config is readable without exposing anything.
3. **Give every token the least it needs.** If another service needs your sensor data, give it a token for a dedicated read-only user. If that token leaks, someone can read sensor values and nothing else.
4. **Prefer local over cloud.** When you can, pick devices Home Assistant can talk to on your own network, and keep camera recordings on storage you control. Some devices only work through a cloud account. Accept that per device, knowingly, and write it down.
5. **Validate before you deploy.** Home Assistant checks its own config before anything reloads. A bad change is rejected instead of half-applied.
6. **Decide what the AI may touch.** Claude edits files in the repo and runs the deploy script. The secrets it relies on sit in files outside the repo, so they never end up in a diff or a chat. It doesn't log in to vendor accounts or pair devices. Those steps stay with me, in the UI.

None of this is exotic. It's the same discipline you'd use for a small web app, applied to a house.

## Cheap devices and circuits

The part that surprised me most is how little the hardware costs. These are real prices for the parts of a typical small project, read from Portuguese and Spanish shops in July 2026:

| Part | Price | What it does |
| --- | --- | --- |
| ESP32 dev board (NodeMCU) | €10.18 | The brain of every small device: Wi-Fi, Bluetooth, GPIO pins |
| ESP32-S3 camera board with PIR sensor | €30.98 | A camera that wakes on motion |
| 12 V 3 A power supply | ~€10 | Powers a whole small project from mains |
| LM2596 buck converter | check the shop | Steps 12 V down to 5 V for the board |
| 12 V solenoid valve, float switch, flow meter | €9–20 each | Open water, know when a tank is full, measure litres |
| Misting nozzles (15) and 25 m of drip tube | €9.74 and €8.33 | Cooling and watering |
| Wi-Fi powerline kit | €81.32 | The most expensive part: a reliable network at the far end of the property |

The pattern is always the same: an ESP32 running [ESPHome](https://esphome.io), a sensor or a relay, a power supply, and a waterproof box. Prices move, so check before you order, but the order of magnitude is tens of euros per device, not hundreds.

## What you can build with them

None of these are new ideas. The point is that each is now an afternoon instead of a month.

**Irrigation is the best place to start.** A valve per zone and an ESP32, or a Bluetooth tap timer, and Home Assistant does the thinking: it skips a run when the forecast says rain, waters longer after hot, dry days, and logs how much water each run used. Compare each run with the last few and you get a leak alert almost for free. Add your water company's prices and it can estimate the bill. It's useful from the first week, it saves water, and nothing bad happens if a run goes wrong.

More ideas on the same budget:

- **Control an old air conditioner or TV.** An infrared blaster learns the remote and Home Assistant replays it, so a ten-year-old unit gets a schedule and a thermostat.
- **Know when a tank is full or the water is running.** A float switch and a flow meter cost about ten euros each.
- **A camera that wakes on motion.** An ESP32 camera board with a motion sensor, around thirty euros, sends a snapshot to your phone.
- **Use Bluetooth gadgets without their apps.** An ESP32 can act as a Bluetooth proxy, so devices out of the Pi's range still show up in Home Assistant.
- **Get told when something opens.** A door or gate sensor plus a notification is one of the simplest and most useful automations there is.
- **Look after animals.** Automatic water, feed and a camera for a chicken coop come from the same parts as everything above.

## How Claude fits in, and where to stay careful

The way I work is the same for every device:

1. Describe the outcome in plain words: "water zone 2 for longer when it's been hot and dry, and tell me if it uses more water than usual."
2. Claude reads the existing packages, writes or changes the YAML, and explains what it did.
3. The deploy script validates the config on the Pi and reloads it.
4. I check the result on the dashboard or the device, and Claude reads the logs when something is off.

What it does well: reading datasheets and integration docs, writing configuration, working out protocols, keeping notes in the README so the next change starts from what was learned, and pricing parts.

Where I stay careful:

- **Anything with mains power.** AI can explain the wiring, but a 230 V circuit gets checked by me, and by an electrician when it's more than plugging in a supply.
- **Anything that opens or locks.** Gates and doors deserve a manual override and a notification on every change, so an automation bug never locks anyone in or out.
- **Accounts and pairing.** Logging in to vendor clouds and pairing devices stay manual steps.
- **Prices and stock.** They change weekly. The AI reads them live, and I still look before ordering.

The result isn't a smart home that impresses visitors. It's a house that waters the garden properly, warns me about a leak, and lets me check the cameras from anywhere, built mostly from parts that cost tens of euros each, with a lot less frustration than it used to take.
