Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 35 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

**Automatic backup, history tracking, and instant restore for your Home Assistant configuration.**

[![Release](https://img.shields.io/github/v/release/saihgupr/HomeAssistantVersionControl?style=flat-square&label=release)](https://github.com/saihgupr/HomeAssistantVersionControl/releases) [![Docker pulls](https://img.shields.io/badge/Docker_pulls-58.4K-blue?style=flat-square&logo=docker)](https://github.com/saihgupr/HomeAssistantVersionControl/pkgs/container/home-assistant-version-control) [![License: MIT](https://img.shields.io/badge/License-MIT-yellow?style=flat-square)](https://github.com/saihgupr/HomeAssistantVersionControl/blob/main/LICENSE)
[![Release](https://img.shields.io/github/v/release/saihgupr/HomeAssistantVersionControl?style=flat-square&label=release)](https://github.com/saihgupr/HomeAssistantVersionControl/releases) [![Docker pulls](https://img.shields.io/badge/Docker_pulls-61.9K-blue?style=flat-square&logo=docker)](https://github.com/saihgupr/HomeAssistantVersionControl/pkgs/container/home-assistant-version-control) [![License: MIT](https://img.shields.io/badge/License-MIT-yellow?style=flat-square)](https://github.com/saihgupr/HomeAssistantVersionControl/blob/main/LICENSE)

Home Assistant Version Control provides complete version history for your setup. It automatically tracks every change to your YAML configuration files using a robust local Git backend. Browse your history, visualize diffs, and restore individual files or your entire configuration to any previous state with a single click.

Expand All @@ -14,20 +14,34 @@ Home Assistant Version Control provides complete version history for your setup.
<img src="https://github.com/saihgupr/HomeAssistantVersionControl/raw/develop/images/screenshots/ha-tweaks-version-history.png" width="960" alt="Version history navigation in the Home Assistant automation editor" />
</p>

## What's New in v1.6!
## What's New in v1.7!

v1.6 focuses on cloud sync and hands-free reloads.
v1.7 adds API authentication for standalone Docker and cuts idle CPU.

* **Mirror Remote for Cloud Sync:** Add a second Git remote and every sync pushes to both. Use it for a redundant off-site copy, drift detection, or an audit repository. Mirror pushes are non-fatal, so a failure never blocks your primary backup.
* **Auto-reload Changed Components:** Optionally reload the Home Assistant domain that changed after each automatic backup. Edit automations, scripts, scenes, inputs, or templates and the matching reload service runs without a Developer Tools trip. Off by default.
* **Cleaner Cloud Sync Fields:** Token inputs no longer show the browser's password and autofill icons.
* **API Authentication for Docker:** The standalone container now asks for HTTP Basic auth on `/api/*`. It is on by default there. The username is `havc`, and the password is generated on first start and saved to `/data/api-password`. Set `HAVC_USERNAME` and `HAVC_PASSWORD` to choose your own, or `HAVC_API_AUTH=off` behind an authenticating reverse proxy. The add-on behind Ingress is unchanged.
* **Lower Idle CPU:** The watcher now ignores files HAVC can never commit, so polling no longer stats dependency folders, model caches, and other large directories.
* **Faster Startup Recovery:** A stale `.git/index.lock` is cleared after ten minutes, and startup and watcher retries now share one initialization run instead of racing for the git lock.

### Also in This Release

* **Optional Add-on Auth:** Added `api_auth` and `api_auth_password` for add-on users who publish port 54001 directly.
* **Input Validation:** Client-supplied paths and commit hashes are validated before use.
* **Exact-Match CORS:** `HAVC_ALLOWED_ORIGINS` takes an exact origin list instead of the old substring matching.

<details>
<summary>v1.6 highlights</summary>

v1.6 focused on cloud sync and hands-free reloads.

* **Mirror Remote for Cloud Sync:** Add a second Git remote and every sync pushes to both. Use it for a redundant off-site copy, drift detection, or an audit repository. Mirror pushes are non-fatal, so a failure never blocks your primary backup.
* **Auto-reload Changed Components:** Optionally reload the Home Assistant domain that changed after each automatic backup. Edit automations, scripts, scenes, inputs, or templates and the matching reload service runs without a Developer Tools trip. Off by default.
* **Cleaner Cloud Sync Fields:** Token inputs no longer show the browser's password and autofill icons.
* **Nested Git Repositories Documented:** Folders under `/config` with their own `.git` are skipped, so an ESPHome repo or similar no longer shows up as a broken submodule.
* **Embedded Credentials (from v1.5.2):** Custom remotes using `user:pass@` or `token@` authenticate reliably during automatic pushes and connection tests.
* **Masked Logs (from v1.5.1):** Tokens in remote URLs are redacted from startup logs and diagnostics.

</details>

<details>
<summary>v1.5 highlights</summary>

Expand Down Expand Up @@ -146,6 +160,9 @@ There are two ways to install Home Assistant Version Control: as a Home Assistan

### 2. Standalone Docker Installation

> [!WARNING]
> The standalone container requires API authentication by default. Requests to `/api/*` need HTTP Basic auth, while static files and the `/` healthcheck stay open. If you don't set `HAVC_PASSWORD`, a password is generated on first start, printed in the container logs as `[auth] API password: ...`, and saved to `/data/api-password` inside the container. Set `HAVC_USERNAME` and `HAVC_PASSWORD` to use your own credentials. Set `HAVC_API_AUTH=off` only when an authenticating reverse proxy already sits in front of the container. For internet exposure, keep an authenticating reverse proxy in front and leave the port closed on untrusted networks.

<details>
<summary>Click to expand Docker deployment options</summary>

Expand All @@ -163,14 +180,16 @@ For Docker users who aren't using the Home Assistant app, you have three deploym
nano compose.yaml
# Update the volume path: /path/to/your/ha/config
# Update timezone: TZ environment variable (e.g., America/New_York)
# Optional: set HAVC_USERNAME and HAVC_PASSWORD for API authentication
# Without HAVC_PASSWORD the generated one is in /data/api-password and the container logs
```

3. Start the service:
```bash
docker compose up -d
```

Access the interface at `http://localhost:54001`.
Access the interface at `http://localhost:54001`. Log in with your `HAVC_USERNAME` and `HAVC_PASSWORD`, or with `havc` and the generated password from the logs or `/data/api-password`.

**Option B: Docker Run (pre-built image):**

Expand All @@ -179,6 +198,8 @@ docker run -d \
-p 54001:54001 \
-v /path/to/your/config:/config \
-e TZ=America/New_York \
-e HAVC_USERNAME=havc \
-e HAVC_PASSWORD=choose-a-strong-password \
-e SUPERVISOR_TOKEN=your_long_lived_access_token_here \
-e HA_URL=http://homeassistant.local:8123 \
--name home-assistant-version-control \
Expand All @@ -198,6 +219,8 @@ docker run -d \
-p 54001:54001 \
-v /path/to/your/config:/config \
-e TZ=America/New_York \
-e HAVC_USERNAME=havc \
-e HAVC_PASSWORD=choose-a-strong-password \
-e SUPERVISOR_TOKEN=your_long_lived_access_token_here \
-e HA_URL=http://homeassistant.local:8123 \
--name home-assistant-version-control \
Expand All @@ -207,6 +230,9 @@ docker run -d \
> [!NOTE]
> The `SUPERVISOR_TOKEN` and `HA_URL` are optional. You can omit those lines if you don't need Home Assistant restart/reload features.

> [!NOTE]
> API authentication is on by default. If you don't set `HAVC_PASSWORD`, the generated password is printed in the container logs and saved to `/data/api-password`. Mount `/data` so it survives container recreation. Set `HAVC_API_AUTH=off` only when an authenticating reverse proxy already protects the container.

Access the interface at `http://localhost:54001`.

### Docker Data & Settings
Expand Down Expand Up @@ -247,6 +273,8 @@ Notes:
- Files are still filtered by `include_extensions` and `exclude_files`.
- For `.conf` files, add `conf` to `include_extensions`.

By default the app relies on Ingress and Home Assistant authentication for the panel. If you expose port `54001` directly, set `api_auth: true` to require HTTP Basic auth on `/api/*`, and set `api_auth_password` to choose the password. If the password is left empty, HAVC generates one and stores it in `/data/api-password`.

#### Manual mode (existing git repositories)

Set `manual_mode: true` if `/config` is already a git repository you manage yourself. The option is read before HAVC touches the repository, so it applies from the very first start, and when set it takes precedence over the toggle in the settings UI:
Expand Down
9 changes: 9 additions & 0 deletions compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,15 @@ services:
# Optional: Home Assistant URL (required for Docker mode to enable reload/restart features)
# Format: http://homeassistant.local:8123 or http://192.168.1.100:8123
- HA_URL=http://homeassistant.local:8123

# API authentication is on by default. Leave these commented out to use the
# generated password, which is written to /data/api-password and printed in
# the container logs as "[auth] API password: ...".
# - HAVC_USERNAME=havc
# - HAVC_PASSWORD=choose-a-strong-password

# Set to off only if an authenticating reverse proxy sits in front of this container
# - HAVC_API_AUTH=off
volumes:
# Mount your Home Assistant config directory
# This directory will be tracked for changes
Expand Down
18 changes: 18 additions & 0 deletions homeassistant-version-control/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,23 @@
# Changelog

## [Unreleased]

## [1.7.0]

### Security Hardening
- **API Authentication for Docker:** The standalone container can now ask for HTTP Basic auth on `/api/*` routes. It is on by default there because that deployment listens on the network. Static files and the `/` healthcheck stay open. If you do not set a password, one is generated on first start, written to `/data/api-password` (mode 0600), and printed in the container logs. Set `HAVC_USERNAME` and `HAVC_PASSWORD` to choose your own, or `HAVC_API_AUTH=off` when an authenticating reverse proxy already protects the container.
- **Add-on Authentication Option:** Added `api_auth` (default `false`) and `api_auth_password` for add-on users who publish port 54001 directly. With `api_auth` off, Ingress and Home Assistant authentication still protect the panel.
- **Exact-Match CORS Allowlist:** `HAVC_ALLOWED_ORIGINS` takes a comma-separated list of exact origins. No CORS headers are sent when the list is empty.

### Fixed & Improved
- **Lower CPU Usage:** The watcher now ignores files HAVC can never commit (everything outside the configured extensions and whitelisted `.storage` files), so polling no longer stats `deps`, `tts`, `www`, model caches, and other large folders. Polling is off by default; enable it only for network mounts that need it.
- **Stale Git Lock Recovery:** A crashed git process could leave `.git/index.lock` behind and block every commit, which made the watcher retry initialization forever. The lock is now cleared on startup when it is older than ten minutes.
- **Serialized Initialization:** Startup and watcher retries now share one initialization run and retries are throttled, instead of racing each other for `index.lock` and spawning duplicate git processes.
- **Path and Commit Validation:** All client-supplied paths are checked for traversal, and invalid paths or commit hashes are rejected with `400`.
- **Quieter Health and Debug Endpoints:** `/api/health` and `/api/debug` no longer echo request headers. `/api/debug` only responds when `HAVC_DEBUG=1`.
- **Loopback by Default:** `HOST` now defaults to `127.0.0.1` for bare-metal runs. The Docker image sets `HOST=0.0.0.0` so containers and the app keep listening on all interfaces.
- **Scope:** The add-on behind Ingress was not exposed as long as port 54001 was not published. The standalone Docker deployment was the one that needed this hardening. Details are in advisory GHSA-vm55-p93v-fr5f.

## [1.6.1]

### Fixed & Improved
Expand Down
1 change: 1 addition & 0 deletions homeassistant-version-control/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ LABEL \
org.opencontainers.image.version=${BUILD_VERSION}

ENV LANG C.UTF-8
ENV HOST=0.0.0.0

# Install Node.js and npm
RUN apk add --no-cache \
Expand Down
Loading