I Built a Software Factory for My Home Assistant

A modern two-story house at dusk with warm lights on and the garage closed. In the sky above it, a sample prompt reads "If sunset, then close garage and turn on warm exterior lights." It flows through a software factory into a glowing blueprint of the same house, passes a test and is pushed down to the real house.
Describe it, build it, test it on a twin of the house, then push it to the real one.

I love Home Assistant. I don’t love hand-coding it.

I freaking love Home Assistant. Lights that follow you room to room, blinds that open at sunrise, a garage that closes itself when someone forgets, a night sweep that turns the house off without killing the Wi-Fi. If you can imagine it, Home Assistant can probably do it.

But here’s the thing. I really don’t want to hand-code every automation, helper, template and integration. And I definitely don’t want to click through the UI editor at 11 PM trying to remember why I built two home zones in the first place.

I know how good software teams keep big systems sane: version control, code review, automated tests, and a deploy pipeline nobody has to babysit. A colleague who also runs Home Assistant asked how I manage mine, so this is the story of how I built my own software factory for my house. I describe what I want in plain English. Claude does the building, the testing and the paperwork. I review and approve.

In about four weeks the factory took me from a pile of UI automations to this:

Here’s how it came together.

Step 1: Build the factory floor

Before Claude could touch a single automation, I needed guardrails. The goal was simple: Claude can propose anything, but nothing reaches my house unless it passes checks, and anything risky waits for me.

Git is the source of truth. I created a private GitHub repo that mirrors my Home Assistant /config folder. Everything I want managed lives in packages/, one YAML file per topic (bedrooms, first floor, presence, safety), with its automations, helpers and templates together. The files the UI editors own (automations.yaml, scripts.yaml, scenes.yaml) stay out of Git so the two never fight. Secrets never get committed; CI uses a fake secrets file instead.

Deploys pull, they don’t push. The official Git Pull add-on on my Home Assistant Yellow checks main every 5 minutes, runs a config check and restarts Home Assistant. Nothing on the internet can push into my house. Merging a PR is the deploy.

CI checks every PR against the version I actually run. This one matters more than it sounds. AI models love to use options from a newer (or older) Home Assistant than the one you have. So the running version is pinned in a package, and the house rules tell Claude to confirm every trigger, condition and action against Home Assistant’s source code at that exact tag. CI runs the config check on that pinned version too.

House rules, written down and enforced. A CLAUDE.md file in the repo spells out how my house works. A few of the rules:

That last one is my favorite. I review automations by looking at the diagram, not by reading YAML.

One-way doors and two-way doors. I borrowed this idea from how big tech companies make decisions. A two-way door is easy to undo: a new automation, a dashboard tweak, a voice command, docs. A one-way door could hurt if it’s wrong: locks, the garage, the alarm, leak alerts, heater safety, the car, anything near do_not_turn_off, deletions, Home Assistant upgrades, and changes to the rules themselves. A CI job called door-gate reads every PR and picks the stricter of three signals: what the PR says, what the final code review says, and a script that scans the files and content. Two-way PRs auto-merge, but only between 7 AM and 10 PM and never while guest mode is on. One-way PRs wait for me.

The registry Action. Labels, areas and entity renames live in Home Assistant’s internal storage, not in YAML, so you can’t deploy them as files. I didn’t want to give every Claude session a live admin token to my house either. Instead the wanted state lives in registry/*.yaml. Each PR gets a dry-run plan as a comment, and after I merge, a GitHub Action applies it through Home Assistant’s API. The token only exists in a GitHub environment that just the main branch can read. Agents never see it.

A real development process, borrowed from people smarter than me. I integrated Matt Pocock’s open-source agent skills (github.com/mattpocock/skills) into the repo. Every change follows the same loop:

  1. Plan by size. Small changes get /grill-me, where Claude interviews me until it understands what I want. Bigger ones get a written spec and tickets that I approve.
  2. Claude builds it on a branch.
  3. Claude reviews its own branch with /code-review, fixes what it finds and opens the PR.
  4. A fresh Claude thread that didn’t write the code does the final review and records whether it’s a one-way or two-way door.
  5. After each spec, a /retro suggests how to make the factory itself better. Retro changes are always one-way, so I decide.

One rule I don’t bend on: agents never merge. Ever. The auto-merge workflow merges two-way doors, and I merge one-way doors.

Two tracks to the house My ask goes to Claude, which builds it and runs it in the test house, a digital twin of my house with 178 scenarios. The pull request runs the twin again, with CI and a fresh review. At the door gate the line splits. Two-way changes, such as a new automation, a dashboard tweak or docs, take the fast track and auto-merge from 7 AM to 10 PM. One-way changes, such as locks, the garage, the alarm, deletions and upgrades, take the slow track and wait for me to merge. Both tracks rejoin at main. The house's Git Pull add-on pulls main every 5 minutes, and Home Assistant checks its config, then restarts. Two tracks to the house My askplain English Claudebuilds Pull requestCI + review Door gate Fast track: two-way auto-merges 7 AM to 10 PM I merge Slow track: one-way locks, garage, alarm, deletions, upgrades Test house digital twin, 178 scenarios, runs twice main pulls Home Assistant checks, restarts
The factory, from ask to running house.

Put together, every change takes the same road, and the door gate decides whether I have to be in the loop.

Step 2: Move every UI automation into Git

With the factory floor built, I had a problem: almost everything I’d built over the years lived in the UI editor. The registry export found 39 UI automations and 10 UI scripts. None of it had tests, diagrams, or a history of why it worked the way it did.

The pilot taught me the pattern. We started with one automation, Everything Off at Night, and it took several PRs to get right. The first attempt reused the UI automation’s id for the Git copy. Home Assistant loads automations.yaml before packages, saw a duplicate id and quietly dropped the Git copy. It never showed up. That’s the kind of thing you learn once and write down, so it became the migration playbook:

  1. Claude builds a Git copy with its own id and a “(Git)” name, side by side with the original.
  2. I disable the UI original and watch the Git copy run for a night or two.
  3. A clean-up PR deletes the UI original through the registry Action and renames the Git copy onto the original’s entity id, so dashboards and history keep working.

I never delete anything by hand, and I never delete the original until the copy has proven itself.

Then we did the rest in batches. Claude wrote a spec and split the work into six batches: the foundation (the morning “make sure automations are on” sweep and guest mode), presence, the first floor, bedrooms, offices, and safety (leak alerts, the car, the garage, low batteries). Each batch went build PR, registry PR, then clean-up PR. Because almost every PR touched the registry or a safety device, nearly all of them were one-way doors, so I merged each one myself. That was the right call for a migration.

My rule: port it as-is. A migration is not the time to sneak in improvements. If Claude found a bug, it told me, and I decided whether to fix it in the migration or later. It found plenty:

The migration finished on November 19. Every automation in my house now lives in Git (except one bathroom pair waiting on a new motion sensor), with a diagram, an icon, a category and the git_managed label so I can find them in the UI.

Step 3: A digital twin of my house

CI could tell me an automation was valid YAML. It couldn’t tell me whether it did the right thing. “Does the night sweep actually leave the Wi-Fi on?” was still a question I answered by waiting until 11 PM and checking. So I asked Claude for a test house: a virtual copy of my home where automations run before they ever touch the real one.

It’s real Home Assistant, not a mock. The test house boots Home Assistant Core at the exact version I run, inside pytest, and loads my repo’s real packages. Every device is a stand-in built on Home Assistant’s own entity class for that domain, with the real entity id, device id, area and labels. So a service call takes Home Assistant’s real path: schemas, supported features, unavailable devices skipped. Each stand-in records the calls it gets and changes its own state. Notifications and announcements are recorded, never sent, and nothing can reach the real house: no device integrations, no token, and every network socket except localhost is blocked.

The house model comes from the real house. A nightly job snapshots my Home Assistant registry. Every Monday a workflow turns that snapshot into a trimmed house model and opens a PR, so the twin keeps up when I add a device or move one to another room.

Scenarios read like plain English. Each package has a scenario file. A scenario says what the house looks like, what happens, and what should (and shouldn’t) get a call:

- name: leaves guest_mode devices alone while Guests is on
  given:
    time: "2026-11-14 22:40:00"
    states:
      input_boolean.guests: "on"
  when:
    - wait: 20 min
  expect:
    calls:
      light.turn_off: [light.living_room_light, light.kitchen_ceiling_lights]
    untouched: [switch.hallway_lights]

I made one rule for scenarios: each one sets up the conditions it tests. If a scenario checks that the night sweep closes the garage, it opens the garage first. It never relies on whatever state the house happened to be in when the snapshot was taken.

It runs in two places. Claude runs it locally with one command (testhouse/run.sh) while it builds, so it finds problems before a PR even exists. Then every PR runs all the scenarios again in a scenarios CI job, which is a required check: a red test house means no merge. The house rules also fail any automation that doesn’t have at least one scenario.

It paid for itself right away. While writing scenarios for every automation, Claude found that Everyone Leaves Home turned off the lights, switches and covers, but never locked the front door. That had been true for who knows how long. I filed it as a critical issue, and it was fixed, tested and merged the same day. Today the twin runs 178 scenarios across 33 automations on every PR.

Step 4: The garage that opened itself, fixed by conversation

This is the moment the whole thing clicked for me.

One Saturday morning I noticed the garage door had been opened the night before, and I had no idea why. I opened a thread and typed one sentence: “My garage door was opened last night and I want to figure out what opened it.” I didn’t open the logbook, the YAML or a code editor. Here’s how the next four and a half hours went.

9:07 AM. The question. Claude first read the repo and listed which Git automations could open the garage. Then it asked me to sign in to Home Assistant in the Claude app’s browser pane (it can’t type my password, which I appreciate) so it could read the logbook.

9:16 AM. The diagnosis. The garage had opened twice. The 10:32 PM open came from outside Home Assistant, 8 seconds after the door from the house into the garage opened. That was a person with the wall button, not a bug. The 9:52 PM open was my Someone Arrives Home automation, which thought I had just arrived. I’d been home since 11 AM.

The root cause: GPS drift between two home zones. I have two zones on my house: Home Assistant’s built-in home zone (100 m) and a small one I created myself called “Home” (20 m). Phone GPS inside a house wanders more than 20 m, so my phone kept slipping out of the small zone into the big one and back. Someone Arrives Home only asked “did someone just enter Home?”, so every re-entry looked like an arrival. It disarmed the alarm and opened the garage.

GPS drift on the couch opens the garage Before the fix. A phone sitting on the couch drifts in and out of the 20 m Home zone. The old rule opens the garage whenever someone enters Home, so every drift back in disarms the alarm and opens the garage. Close to Home · 1.9 km Near Home · 100 m Home · 20 m Before the fix The old rule Garage opens on entering Home. Away Close to Home Near Home Home Garage Closed On the couch
Before the fix: the phone never leaves the couch, but GPS wanders past the 20 m circle and back, and every return looks like an arrival. The map is made up and not to scale.

I didn’t remember why I had two zones, so before deleting anything I asked Claude how each one was used. It searched the repo and Home Assistant’s related items: four automations, all in Git, one on the big zone and three on the small one. I decided to keep both.

11:35 AM. The first fix was wrong, and the test data caught it. Claude offered three options and I picked the simplest: ignore an arrival if the person was already in the big zone just before. While building the test scenario for it, Claude pulled the real location history from the day before, and found a problem. A real family arrival at 5:16 PM went away, then Close to Home, then the 100 m zone, then the 20 m zone. Its last step was the exact pattern the fix ignored, so a real arrival would never open the garage again. Claude stopped, undid the change and told me plainly: “I got Option A wrong.” Nothing shipped.

12:42 PM. I designed the real fix, in plain English. Claude’s next idea was to trigger on the 100 m zone. I didn’t want that: if I walk to a neighbor’s house, my GPS could wander into the big zone and open the garage. Claude built a version with a “left home” flag, and its code reviews found gaps in it. While that was happening, I thought about how I actually come home and typed out a design:

Maybe we create a helper, one for each of us, that only changes from home to away when we leave the Close to Home radius. When we return to Close to Home it changes our status to Close to Home, then when we enter the 100 m zone it gives us a new status, and when we enter Home, that’s when the garage opens.

That’s it. That was my whole contribution to the code.

1:14 PM. The PR. Claude rebuilt the fix around my design. Each of us gets a Home Status helper: Away, Close to Home, Near Home or Home. It only switches to Away when the phone leaves the Close to Home zone (about 1.9 km). The garage opens only when you enter the 20 m zone and your status isn’t already Home. GPS drift and walks around the neighborhood never leave Close to Home, so they can’t open anything.

Home Status on the couch and driving home After the fix. On the couch, the same GPS drift never leaves the 1.9 km zone, so the status stays Home and the garage stays shut. Driving home, the car steps from Away to Close to Home at 1.9 km, Near Home at 100 m and Home at 20 m, and only then does the garage open. Close to Home · 1.9 km Near Home · 100 m Home · 20 m After the fix Home Status Away only after leaving Close to Home. Away Close to Home Near Home Home Garage Closed On the couch
After the fix: drift on the couch never leaves the 1.9 km zone, so the status stays Home. A real trip home steps down through every zone, and only the last step opens the garage. The map is made up and not to scale.

Each phone has to step down through the zones in order, and only the last step into the 20 m zone opens the garage.

The code reviews also caught things I’d never have thought of. When a phone goes unavailable, Home Assistant reports it in no zones, which would have looked like Away, so a status now holds through an outage. After a restart, anyone outside Close to Home is set to Away. And if two of us pull in together, both arrivals count.

The test house replayed the real night: my 9:52 PM drift did nothing, a neighborhood walk did nothing, a real family arrival (including a bounce at the edge of a zone) fired exactly once, and two people arriving together both counted. All 178 scenarios passed, CI went green, a fresh Claude thread did the final review and called it a one-way door, because it touches the garage and the alarm.

1:40 PM. I merged it. Within five minutes Git Pull deployed it to the house.

From “what opened my garage?” to a deployed, tested fix took about four and a half hours of a Saturday, and most of that I spent doing other things. I never wrote a line of YAML. I described the problem, pushed back when an answer didn’t sound right, designed the behavior I wanted in my own words, and approved the result.

What I learned, and how to start your own

The AI is the easy part. The factory is what makes it trustworthy. Claude writes good YAML, but what lets me sleep at night is everything around it: a pinned version, house rules in writing, a test house, a door gate, and a human merge for anything that can lock, open or alarm.

A few things I’d tell anyone trying this:

I still love tinkering with Home Assistant. I just get to spend that time on what I want the house to do, not on typing it in. If you want to try this yourself, start small: a repo, a CLAUDE.md with your house rules, a CI config check and the Git Pull add-on. Then migrate one automation and see how it feels.