Infrastructure

Deploying Home Assistant Config Changes With Git and Samba: A Loop You Can Trust

Written with AI assistance by the editorial team.
Updated November 27, 2026 8 min read

The default Home Assistant deploy process is: open the file editor add-on, change the YAML, hit restart, and hope. Sometimes the hope is misplaced. One bad indent in configuration.yaml and HA refuses to boot, and you are fixing it over a phone screen while the lights don’t work.

In our test home the whole config lives in git, changes deploy over the Samba share, and nothing reloads until a config check passes. One more step is worth adding: verify that the write actually landed. A Samba login can fail silently, and a deploy script can then report that everything is valid after deploying nothing at all.

This post is that workflow, including the boring parts that turn out to be the important parts.

The trap: editing the live config and praying

Every HA setup starts the same way — you edit the running system directly, through the UI editors or the file editor add-on. And to be fair, for a dozen automations it’s fine. The problems compound with scale:

  • There’s no undo. The UI has no history. When an automation that worked last month doesn’t now, you have nothing to diff against. Was it your edit? An HA upgrade? A renamed entity? You’re reconstructing the past from memory.
  • There’s no review step. The gap between “typed” and “live” is one click. Every typo ships instantly to the only production environment your family lives in.
  • You can’t answer “what changed?” — which is the first question in every debugging session, and the live-edit workflow throws the answer away.

The fix isn’t exotic. It’s the same thing that fixed this for software teams: version control and a deploy step. The trick is fitting it to HA’s quirks, because HA has opinions about how you’re allowed to touch it.

Layout: what’s in git, what’s ignored

Our HA config is a git repo — the copy on the HA box is just the deployed artifact. An example structure:

ha-config/
├── configuration.yaml
├── automations/          # one file per automation area
│   ├── lighting.yaml
│   ├── security.yaml
│   └── lock_battery_alert.yaml
├── scripts/
├── packages/
├── dashboards/
├── secrets.yaml          # NOT tracked
└── .gitignore

The load-bearing line in configuration.yaml:

automation: !include_dir_merge_list automations/
script: !include_dir_merge_named scripts/

One file per topic instead of a 4,000-line automations.yaml. Diffs stay readable, and two changes in different areas never collide. The tradeoff to know about: once automations come from an !include_dir_merge_list, the UI automation editor can’t save them anymore — there’s no single editable file for it to write to. That’s a feature in this workflow (the repo is the only writer), but decide deliberately, because you’re choosing files-as-truth over the UI.

The .gitignore matters as much as the tracked files:

secrets.yaml
.storage/
*.db
*.db-wal
*.db-shm
*.log*
backups/
tts/
.cloud/

secrets.yaml stays out for the obvious reason — every credential in your smart home lives there, and config repos have a way of ending up on GitHub eventually. .storage/ stays out because it’s HA’s private state — entity registries, auth, UI-managed config — and it is not yours to edit; hand-modifying files in there is the fastest route to an unbootable instance. The databases and logs stay out because they’re gigabytes of churn with zero config value.

The test: track what you wrote, ignore what Home Assistant writes.

Getting changes onto the box: Samba, SSH, or the VS Code add-on

You need a write path from where you edit to where HA runs. The realistic options:

The Samba share add-on exposes /config as a network share. This is our deploy path: the deploy step is smbclient (or a mounted share) copying changed files across. It’s protocol-boring, works from every OS, and needs no agent on the HA side beyond the add-on.

SSH (via the SSH & Web Terminal add-on) gets you rsync, which is strictly nicer for syncing a tree — but note that SSH is not enabled on a stock HAOS box until you install and configure the add-on, as the Home Assistant docs walk through. If you’re comfortable there, rsync -av --exclude-from=.gitignore ./ ha:/config/ is a great deploy step.

The VS Code add-on is the middle path most people land on: a real editor, in the browser, editing live files, with HA-aware autocomplete. It’s genuinely good — but it’s an editor, not a workflow. It edits in place with no history, no review, no rollback. Some people edit in the VS Code add-on and commit from an SSH session afterward, which works but inverts the safety: the change is live before it’s recorded.

And one path that doesn’t exist, despite being the first thing an API-minded person reaches for: the REST API is effectively read-only for configuration. It’s excellent for reads — states, templates, history — and it can trigger service calls, including the reload services used below. But the documented REST endpoints include a config check and no endpoint that writes YAML config. Even the UI’s own automation editor endpoint stops working once your automations come from an include directory. If you want to change config from outside, a file share or SSH is the way; the API is for reading state and pulling triggers.

The silent Samba failure: why you verify writes

Here’s the failure mode behind the paranoid part of the workflow.

A deploy script copies files over Samba, runs a config check, and prints “Config valid!” Then a “deploy” does nothing. The changed automations keep their old behavior. No error anywhere.

A typical cause: the password the script uses for the Samba add-on has gone stale, and Samba auth fails silently if your script doesn’t check for it. smbclient returns NT_STATUS_LOGON_FAILURE, the script doesn’t inspect that particular exit path, no files are written… and then the config check runs against the local repo copy, which is of course valid. Every green light is telling the truth about the wrong thing. “Your YAML parses” and “your YAML is what the server is running” are different claims, and the script has quietly switched from the second to the first.

Three fixes, all worth having even if you never hit this exact bug:

1. Probe auth before deploying. One cheap listing catches a dead credential before you trust it:

smbclient //192.168.1.50/config -U "homeassistant%$SMB_PASS" -c 'ls' > /dev/null \
  || { echo "SAMBA AUTH FAILED — aborting deploy"; exit 1; }

2. Verify the write landed. After copying, pull one deployed file back and compare hashes with the local copy. Half a second, and it converts “the copy probably worked” into “the bytes on the server match the repo.”

3. Validate on the box, not just locally. The config check has to run against /config on the HA machine (via the CLI: ha core check, documented in the HAOS common tasks) — validating your local copy proves nothing about what’s deployed.

If a deploy ever “succeeds” but behavior doesn’t change, check the write path first, before you debug the YAML. The YAML you’re staring at may simply not be there.

The deploy loop

The full sequence, end to end — this is a small shell script, but the steps matter more than the tooling:

  1. Edit locally, commit. Every change is a commit with a message saying why. Whoever debugs this at midnight reads these like case notes.
  2. Snapshot before anything mutates. A quick backup via ha backups new --name "pre-deploy-$(date +%F)" (or the equivalent button). HA’s built-in backups are fine for this; the point is that “roll back” is always a real option, not a hope.
  3. Probe Samba auth (see above). Abort loudly on failure.
  4. Copy changed files to the share.
  5. Verify one round-tripped file hash.
  6. Run the config check on the box. ha core check — and actually gate on it. If it fails, the deploy stops here, and the running system keeps running the last good config. This single gate is what prevents bad-indent outages: broken YAML fails at deploy time, not at 11 PM when HA restarts for an update.
  7. Reload the affected domain — don’t restart. Automations changed? POST /api/services/automation/reload (a long-lived token and one curl). Scripts, scenes, templates, groups all have equivalents. Reloads are ~instant and don’t drop the Zigbee network or blind every sensor the way a restart does. Restart only for the domains that require it: recorder, http, logger, new integrations.
  8. Verify behavior, not vibes. The script pulls the state of one touched automation via the REST API (this is where the read-only API shines) and confirms it exists and is on. For anything risky, trigger it manually once.

The loop adds little time to a typical change, and in exchange the config can never silently drift, never deploy broken, and never lose history.

What to prioritise

Add the auth probe on day one. The rest of the loop can be built incrementally, but the silent-write-failure class of bug is the one that costs you a weekend, because every indicator is green while nothing is true.

Split automations into per-area files early. With a single automations.yaml, every diff is noise and git blame is useless. The !include_dir_merge_list change is small and improves every subsequent day.

Dashboards can go in the repo too. We moved our Lovelace config to YAML mode for the same versioning benefits, but it’s a bigger workflow change than it looks (you give up the UI dashboard editor entirely, and resource declarations move into YAML with it). That migration has enough of its own gotchas that it’s a separate post.

The philosophical shift is the real upgrade: the running Home Assistant box stops being a pet you edit and becomes a target you deploy to. The repo is the house’s memory. When something misbehaves, git log -p automations/lighting.yaml answers “what changed and when” in five seconds.


Related guides: A Home Assistant backup strategy · Node-RED to native HA YAML · Storage-mode to YAML dashboards

Tags #home-assistant #configuration #git #workflow
Share X / Twitter Facebook
Keep reading