git-ha-ppens
Git Integration for Home Assistant to allow versioning your configuration
ActiveNo CI- Other
- Fork
★ 0 · Last push 3 Dec 2026
README
git-ha-ppens
GitOps for Home Assistant — right from your UI.
GitOps for Home Assistant. Edit your config in VS Code or directly on GitHub, push the changes, and your HA instance pulls them automatically. Roll back any breaking change directly from the Home Assistant UI. Review config changes in a pull request before they ever reach your live system.
git-ha-ppens brings native git directly into Home Assistant — auto-commit on file change, auto-push to your remote, and now auto-pull when new commits arrive. All configured through the UI, no command line needed.
📥 Installation
Prerequisites
Requirements:
- 🏠 Home Assistant 2024.1 or later
- 🔧 Git available to the Home Assistant Core runtime
The Home Assistant Core image used by Home Assistant OS and the official Home Assistant Container image already include Git, so no separate installation is normally required. git-ha-ppens checks for Git during setup. Custom container images must include Git in the Home Assistant Core image itself.
HACS (Recommended)
- Make sure HACS is installed
- Click the badge above — or go to HACS → Integrations → ⋮ → Custom repositories and add:
with category Integrationhttps://github.com/manuveli/git-ha-ppens - Search for git-ha-ppens and click Install
- Restart Home Assistant
- Go to Settings → Devices & Services → Add Integration and search for git-ha-ppens
Manual Installation
- Download the latest release from the Releases page
- Copy the
custom_components/git_ha_ppensfolder into yourconfig/custom_components/directory - Restart Home Assistant
- Go to Settings → Devices & Services → Add Integration and search for git-ha-ppens
📑 Table of Contents
- 📥 Installation
- ✨ Features
- 🔁 GitOps Workflow
- ⚙️ Configuration
- 🔐 SOPS Secrets Encryption
- ⏪ Roll back to a historical configuration
- 🤖 AI Commit-Messages
- 🚀 Services
- 📊 Sensors & Entities
- ⚡ Events
- 💡 Example Automations
- 🛡️ Auto-Generated .gitignore
- 🔧 Troubleshooting
- 🤝 Contributing
- 📄 License
✨ Features
🤖 Automatic Version Control
- 👁️ File watcher detects config changes in real time (powered by watchdog)
- ⏱️ Configurable debounce interval (default 5 min) to batch changes and avoid excessive commits
- 📝 Auto-generated commit messages listing the changed files
🔁 Auto-Sync (GitOps)
- 🔄 Periodic git fetch checks the remote on a configurable interval (default 5 min, range 60–3600s)
- ⬇️ Auto-pull when the integration detects your instance is behind the remote
- ⬆️ Auto-push sends any clean local commits upstream, including commits created by ESPHome, VS Code, or manual Git commands
- ✅ Pre-deploy check (optional) — validates incoming remote changes after pulls or push-fallback merges and automatically rolls them back if the check fails
🔧 Manual Control
- 7 services callable from automations, scripts, or Developer Tools:
git_ha_ppens.commit— create a commit with an optional custom messagegit_ha_ppens.push— push commits to the configured remotegit_ha_ppens.pull— pull from remote (auto-backs up uncommitted changes first)git_ha_ppens.fetch— fetch from remote without merging (updates ahead/behind counts)git_ha_ppens.sync— commit + push in one stepgit_ha_ppens.diff— get the current diff of uncommitted changesgit_ha_ppens.discard_changes— discard tracked local changes
- Push, Pull, and Fetch buttons when a remote is configured, plus an optional disabled-by-default Discard Local Changes button
- Native rollback from the configuration UI — select a historical commit, preview the changes, validate the configuration and restore it
🛡️ Security & Secrets
- 🔐 Native SOPS & age encryption — seamlessly versions
secrets.yaml(andesphome/secrets.yaml) as encryptedsecrets.enc.yamlsidecar files in Git, with zero plaintext leakage risk - 🚫 Automatic
.gitignoreforsecrets.yaml,.storage/, databases, logs, and more - 📦 Core/Container backup protection excludes HA-created
.tararchives without hiding other files in a user-createdbackupsdirectory - 🔍 Best-effort secret warning checks staged or modified configuration files when the integration loads
- 🔔 Fires a
git_ha_ppens_secret_detectedevent when potential secrets are found - ⚠️ Secret warnings do not block commits or pushes and are not a substitute for a carefully maintained
.gitignore
☁️ Remote Support
- Push and pull from GitHub, GitLab, Bitbucket, or any git remote
- HTTPS with personal access token or SSH key authentication
📊 Visibility & Monitoring
- 11 sensors + 2 binary sensors for real-time git status and encryption health
- Events for commit, push, pull, fetch, errors, secret detection, and SOPS lifecycle
- Build dashboards, notifications, and automations around your config history
🩺 Diagnostics
- Full diagnostics support via Settings → Devices & Services → git-ha-ppens → Diagnostics
- Sensitive values are automatically redacted
🔁 GitOps Workflow
GitOps means your git repository is the single source of truth for your Home Assistant configuration. Instead of editing files directly on your HA instance, you manage changes through git — and your instance automatically stays in sync.
With git-ha-ppens you get a full GitOps loop without any extra tooling:
Edit config in VS Code / GitHub → push to remote
↓
git-ha-ppens fetches periodically (default: every 5 min)
↓
Detects your instance is behind → auto-pull
↓
(optional) Pre-deploy check → rollback if config is invalid
↓
Home Assistant is up to date ✓
Why this matters
- Edit from anywhere — use your local editor, the GitHub web UI, or any other git client. Changes reach HA automatically.
- Review before it goes live — open a pull request for config changes and merge only when you're ready.
- Instant rollback — select a previous configuration directly in the Home Assistant UI. The integration restores it as a new commit without rewriting history or requiring Git commands.
- Safe deploys — enable the optional pre-deploy check to run a Home Assistant configuration check on incoming changes. If it fails, the remote merge is rolled back automatically and your instance keeps running on the last working config.
- Full history — every config change is a commit. Know exactly what changed, when, and why.
Enabling the GitOps loop
- Configure a remote repository (GitHub, GitLab, etc.) in the integration setup
- Enable Auto-Pull in the commit settings
- Set a Fetch Interval (default 5 min) so the integration checks for remote changes periodically
- Optionally enable Auto-Push to send clean local commits upstream automatically, including commits created by external tools
- Optionally enable the Pre-deploy check to validate incoming changes and roll back automatically if the config is broken
That's it. From this point on, your HA config and your git remote stay in sync automatically.
🛡️ Pre-deploy check: When enabled, every incoming remote merge — whether triggered by a pull or by a rejected push that needs to integrate remote commits — runs a Home Assistant configuration check after merging and before the result is pushed. If the check reports errors, git-ha-ppens performs a
git reset --hardback to the last working commit, fires agit_ha_ppens_check_failedevent, and creates a persistent notification listing the errors — so a bad commit on the remote can't take down your instance. This check validates the live configuration directory, so it only runs whenrepo_pathis your HA config directory (e.g./config).The rejected remote revision is not retried until the remote advances. Once you push a corrective commit, Auto-Pull explicitly merges and validates the corrected history. If Auto-Push is also enabled, git-ha-ppens publishes that validated merge automatically so the repository returns to a fully synchronized state. A real content conflict is aborted cleanly and still requires manual resolution; remote history is never force-pushed.
⚙️ Configuration
The integration is configured entirely through the UI. The setup flow has 3 steps:
Step 1: 📁 Repository Settings
| Option | Description | Default |
|---|---|---|
repo_path |
Path to the HA configuration directory | /config |
git_user |
Git author name for commits | (required) |
git_email |
Git author email for commits | (required) |
Step 2: 🔄 Auto-Commit Settings
| Option | Description | Default |
|---|---|---|
auto_commit |
Automatically commit when files change | true |
auto_push |
Push any clean local committed history to the remote, including commits created by external tools | true |
auto_pull |
Pull automatically when the instance is behind the remote | false |
pre_deploy_check |
Validate incoming remote merges and roll back if the check fails | false |
commit_interval |
Debounce interval in seconds (30–86400) | 300 |
scan_interval |
Status polling interval in seconds (10–3600) | 30 |
fetch_interval |
How often to fetch from remote in seconds (60–3600) | 300 |
Step 3: ☁️ Remote Repository (recommended; required for GitOps sync)
A remote repository is optional only if you want to use git-ha-ppens for local
version history, status monitoring, and configuration restores. Configure a
remote to use Push, Pull, Fetch, off-device backups, or the automatic GitOps
workflow. The auto_push, auto_pull, and fetch_interval settings only take
effect when a remote is configured.
| Option | Description | Default |
|---|---|---|
remote_url |
Git remote URL (HTTPS or SSH) | (empty) |
auth_method |
none / token / ssh |
none |
auth_token |
Personal access token (for HTTPS) | (empty) |
auth_username |
Username paired with the HTTPS token | oauth2 |
ssh_key_path |
Path to SSH private key file | (empty) |
The oauth2 authentication username preserves existing GitHub and GitLab
setups. Bitbucket repository, project, or workspace access tokens commonly use
x-token-auth; Bitbucket API tokens can use x-bitbucket-api-token-auth or the
account's Bitbucket username. The setting is ignored for SSH and unauthenticated
remotes.
💡 Tip: All settings can be changed later via Settings → Devices & Services → git-ha-ppens → Configure. The options menu provides General Settings, Edit .gitignore, SOPS Secrets Encryption, and Restore configuration.
🔐 SOPS Secrets Encryption
Traditionally, GitOps for Home Assistant forced a dilemma: secrets.yaml contains passwords, API tokens, and credentials that must never be pushed to a Git remote unencrypted. But ignoring secrets completely means repository clones and remote restores are missing critical configuration needed to boot Home Assistant.
git-ha-ppens solves this elegantly using SOPS (Secrets OPerationS) and modern age cryptography through an Encrypted Sidecar Pattern:
┌───────────────────────────────┐
│ Home Assistant Live Runtime │
│ (reads secrets.yaml / plain)│
└───────────────┬───────────────┘
│
Auto-Encrypt on Commit (SOPS + age)
│
▼
secrets.yaml ─────────────► secrets.enc.yaml ─────────────► git push
(always in .gitignore, (encrypted ciphertext, (safe for private
NEVER leaves host) committed to Git) or public remotes)
▲
│
Auto-Decrypt on Pull (SOPS + age)
│
┌───────────────┴───────────────┐
│ Pre-Deploy Validation Check │
│ (validates before running) │
└───────────────────────────────┘
Why the Sidecar Pattern?
- 🛡️ Guaranteed Plaintext Leak Prevention:
secrets.yaml(andesphome/secrets.yaml) remain permanently listed in.gitignore. Even if SOPS fails, a manual git commit is run, or an external tool commits files, plaintext secrets can never leak into Git history. - ⚙️ Home Assistant Native: Home Assistant Core requires a standard plaintext
secrets.yamlon disk to resolve!secrettags at boot. The sidecar pattern gives Home Assistant what it needs on disk while versioning onlysecrets.enc.yamlin Git. - 🔑 Standard X25519 & Bech32 (
age): Keys use standard modernagekeypairs (AGE-SECRET-KEY-1.../age1...). Zero proprietary formatting. - 🚀 Auto-Managed Binary: No manual binary installation needed on 64-bit platforms. git-ha-ppens automatically detects your architecture (Linux
x86_64/amd64,aarch64/arm64, and macOS) and downloads the official standalone SOPS binary into/config/.storage/git_ha_ppens/bin/sopswith SHA-256 integrity verification.
🖥️ Platform & Architecture Support
Official standalone SOPS binaries are published by upstream getsops/sops:
| Architecture | Platform | Auto-Download | Setup Method |
|---|---|---|---|
x86_64 / amd64 |
Linux / Docker / HA OS | ✅ Yes | Automatic |
aarch64 / arm64 |
Linux / Docker / HA OS (e.g. Raspberry Pi 4/5 64-bit) | ✅ Yes | Automatic |
x86_64 / arm64 |
macOS (Intel / Apple Silicon) | ✅ Yes | Automatic |
armv7l / armv6l (32-bit ARM) |
Linux (e.g. Raspberry Pi 2/3/4 on 32-bit OS) | ❌ No | Manual installation required (see callout below) |
i386 / i686 (32-bit x86) |
Linux | ❌ No | Manual installation required (see callout below) |
Important
32-Bit ARM Architectures (armv7l/armv6l/ Raspberry Pi 32-bit OS): Upstream SOPS does not publish pre-compiled 32-bit standalone binaries. If your Home Assistant runs on a 32-bit operating system or architecture:
- Install SOPS manually on the host:
- Alpine Linux:
apk add sops- Go toolchain:
go install github.com/getsops/sops/v3/cmd/sops@latest- Or copy a custom pre-built 32-bit
sopsbinary to your system.- Open Settings → Devices & Services → git-ha-ppens → Configure → SOPS Secrets Encryption.
- Enter the absolute path to your binary (e.g.
/usr/bin/sopsor/usr/local/bin/sops) in Custom SOPS binary path.
Quick Setup
- Go to Settings → Devices & Services → git-ha-ppens → Configure.
- Select SOPS Secrets Encryption.
- Check Enable SOPS encryption.
- Check Generate a new age key pair automatically (or paste your existing age secret key if you already have one).
- (Optional / 32-bit only) If using a 32-bit architecture or custom binary, enter its path in Custom SOPS binary path.
- Click Submit.
- The integration generates a standard X25519 age keypair and displays your private key and public recipient.
⚠️ IMPORTANT: Save your secret key (
AGE-SECRET-KEY-1...) in your password manager! If lost, encrypted secrets cannot be decrypted on other machines. - Click Submit to confirm. A
.sops.yamlconfiguration file is automatically created in your repository root with your public recipient, and any secrets already tracked are re-encrypted for it.
Warning
Regenerating a key later: if an age secret key is already configured, "Generate a new age key pair automatically" requires checking I understand this will replace the existing age key first. On confirm, tracked secrets are re-encrypted for the new recipient before the old key is discarded — but only the files currently resolved by your configured Secrets files and glob patterns. Anything encrypted outside that scope (e.g. an old export) will only ever decrypt with the OLD key, so keep it until you've confirmed everything you need still decrypts with the new one.
📝 Configurable Secret Files & Glob Patterns
Every Home Assistant setup is unique. In addition to the standard secrets.yaml and esphome/secrets.yaml, you can customize exactly which files contain secrets:
- Open Settings → Devices & Services → git-ha-ppens → Configure → SOPS Secrets Encryption.
- In the Secrets files and glob patterns field, list one relative path or wildcard glob pattern per line:
secrets.yaml esphome/secrets.yaml zigbee2mqtt/secrets.yaml **/secrets.yaml secrets/*.yaml
- Direct paths: Specific files like
zigbee2mqtt/secrets.yamlare encrypted tozigbee2mqtt/secrets.enc.yaml. - Wildcard glob patterns: Patterns like
**/secrets.yamlrecursively discover and encrypt any matching file in subdirectories. - Pull-time Decryption: On
git pull, git-ha-ppens decrypts the.enc.*sidecars that belong to your configured Secrets files and glob patterns (e.g.secrets.enc.yamlforsecrets.yaml). Unrelated*.enc.*files elsewhere in the repository are intentionally left alone.
How it Works in the GitOps Loop
- On Commit: Whenever files change (via file watcher auto-commit or the
commit/syncservices), git-ha-ppens automatically runs SOPS to encryptsecrets.yamltosecrets.enc.yaml(andesphome/secrets.yamltoesphome/secrets.enc.yaml) before staging and creating the git commit. - On Pull: When remote changes arrive via Auto-Pull or manual pull, git-ha-ppens decrypts
secrets.enc.yamlback intosecrets.yamlusing your local secret key before running the pre-deploy Home Assistant configuration validation check. - On Restore: When rolling back to a historical commit snapshot, the matching secrets are decrypted and verified atomically before the new rollback commit is applied.
- Atomic & Safe: File writes during decryption use atomic temp-file replacement with strict POSIX file permissions (
0600, owner-only read/write). If decryption fails (e.g. invalid key or corrupted file), the existingsecrets.yamlis never modified or wiped out. - Loop Prevention: The file watcher automatically suppresses events during pull and rollback decryptions and ignores
.enc.yamlfiles, preventing recursive commit loops.
Multi-Instance & Team Sharing
Because SOPS supports multiple age recipients simultaneously, you can share a single encrypted repository across multiple Home Assistant instances or team members without sharing private keys:
- Each Home Assistant instance generates its own unique age keypair.
- In
.sops.yaml, add all public recipients undercreation_rules:creation_rules: - age: >- age1instance1..., age1instance2..., age1yourworkstation... - Run Developer Tools → Services →
git_ha_ppens.encrypt_secretsto re-encrypt secrets with all recipients. - Each instance can now decrypt using its own private
AGE-SECRET-KEY-1....
⏪ Roll back to a historical configuration
You can safely restore an earlier configuration without leaving Home Assistant or using Git commands:
- Open Settings → Devices & Services → git-ha-ppens → Configure → Restore configuration.
- Choose one of the 20 most recent earlier commits. For an older state, select Enter an older commit SHA and enter its ID.
- Review the selected commit, the newer commits that will be undone, the affected tracked files, and the diff statistics.
- Confirm the restore and, when a remote is configured, choose whether to push the new restore commit immediately.
The current HEAD is shown above the recent-commit selector as active and
cannot be selected. To undo only the latest commit, select the first earlier
commit directly below it. The selected commit represents the exact tracked
configuration snapshot that will be restored.
The working tree must be completely clean, including staged, unstaged, and untracked files. This prevents an unrelated local edit from being lost or included in the restore. Ignored files and other files not tracked by Git are not part of the snapshot and remain untouched.
After explicit confirmation, the integration restores the tracked tree from
the selected commit and runs a Home Assistant configuration check when the
repository is the live HA configuration directory. A failed check or Git
operation restores the original HEAD, index, and working tree. On success, a
new commit such as revert: restore configuration to abc1234 is created and
verified to exactly match the selected historical snapshot.
This is an additive, history-preserving rollback. It does not reset or rewrite branch history, and it never force-pushes. The default for pushing the new restore commit follows the Auto-Push setting. If the push fails, the valid restore commit remains local and can be sent later with the Push button.
🤖 AI Commit-Messages
By default, git-ha-ppens generates simple commit messages listing the changed files — for example Auto: config.yaml changed or Auto: 3 files changed. This works great out of the box and does not require any AI setup.
If you want more descriptive, context-aware commit messages, you can optionally enable AI-generated commit messages. The integration uses Home Assistant's built-in Conversation service to analyze the git diff and generate a meaningful commit message — powered by whichever AI agent you have configured in HA (OpenAI, Google Generative AI, Ollama, etc.).
✅ Enabling AI Commit-Messages
AI commit messages can be enabled during the initial setup (Step 2: Auto-Commit Settings) or at any time later via Settings → Devices & Services → git-ha-ppens → Configure.
| Option | Description | Default |
|---|---|---|
ai_commit_messages |
Enable AI-generated commit messages | false |
ai_agent_id |
Conversation agent to use | (empty) |
💡 Tip: Leave
ai_agent_idempty to use Home Assistant's default conversation agent. If you have multiple AI agents configured, you can specify exactly which one should generate your commit messages.
🔎 Diff Selection & Privacy
Before calling the conversation agent, git-ha-ppens builds a compact, bounded
view of the changes and distributes the available context across changed files.
The full output returned by git_ha_ppens.diff is not affected.
Common passwords, API keys, access and refresh tokens, authorization headers,
credential-bearing URLs, and private keys are redacted on a best-effort basis
before the prompt is sent. Redaction is an additional safeguard, not a
guarantee. Continue to exclude sensitive files such as secrets.yaml and
.storage/ with .gitignore, especially when using a cloud-hosted conversation
agent.
🛡️ Fallback Behavior
AI commit messages are designed to never interfere with normal operation:
- 🔒 If AI is disabled (default), the integration works exactly as before — no AI code is executed at all
- ⚠️ If AI is enabled but the conversation agent is unavailable or returns an error, the integration silently falls back to the standard auto-generated message
- ✅ Commits are never blocked by AI failures — your configuration changes are always saved regardless of AI availability
📌 No AI? No problem. The integration is fully functional without any AI agent configured. The AI feature is a purely optional enhancement.
🚀 Services
The git-ha-ppens device page provides an optional Discard Local Changes button. When a remote repository is configured, it also provides Push, Pull, and Fetch buttons under Controls. The Push button first commits all pending changes using the configured standard or AI commit-message behavior, then immediately pushes them to the remote. Pull and Fetch run the same operations as the corresponding services below.
The destructive Discard Local Changes button is disabled by default and
must be enabled from its entity settings. It restores staged and unstaged
changes to tracked files back to HEAD. Untracked files are preserved. This is
not a historical rollback, does not reset to the remote branch, and cannot undo
a change after auto-commit has already created a commit.
| Service | Description | Parameters |
|---|---|---|
git_ha_ppens.commit |
Stage all changes and create a commit | message (optional) — custom commit message |
git_ha_ppens.push |
Push commits to the configured remote | — |
git_ha_ppens.pull |
Pull from remote (backs up uncommitted changes first) | — |
git_ha_ppens.fetch |
Fetch from remote without merging — updates the ahead/behind counts | — |
git_ha_ppens.discard_changes |
Permanently discard staged and unstaged changes to tracked files; untracked files are preserved | — |
git_ha_ppens.sync |
Commit + push in one step | message (optional) — custom commit message |
git_ha_ppens.diff |
Get the current diff of uncommitted changes | — (returns response data) |
git_ha_ppens.encrypt_secrets |
Encrypt plain secrets files to their .enc.yaml equivalents using SOPS |
files (optional) — list of specific relative file paths to encrypt |
git_ha_ppens.decrypt_secrets |
Decrypt encrypted .enc.yaml secrets files back to plain secrets |
files (optional) — list of specific relative file paths to decrypt |
Example: Call sync from an automation
action:
- service: git_ha_ppens.sync
data:
message: "Manual sync from automation"
Example: Get the current diff
The diff service returns response data containing the diff content and a status summary. Use it in scripts or automations to inspect changes before committing.
action:
- service: git_ha_ppens.diff
response_variable: git_diff
📊 Sensors & Entities
Sensors
| Entity | Description | Attributes |
|---|---|---|
sensor.git_ha_ppens_last_commit |
Last commit hash (short) | message, author, full_hash |
sensor.git_ha_ppens_last_commit_time |
Timestamp of last commit | — |
sensor.git_ha_ppens_uncommitted_changes |
Number of changed files | changed_files, untracked_files, staged_files |
sensor.git_ha_ppens_branch |
Current branch name | — |
sensor.git_ha_ppens_remote_status |
Sync status (e.g. "in sync", "ahead 3") | ahead, behind, remote_configured, has_upstream, total_commits |
sensor.git_ha_ppens_commits_ahead |
Number of local commits not yet pushed | — |
sensor.git_ha_ppens_commits_behind |
Number of remote commits not yet pulled | — |
sensor.git_ha_ppens_last_fetch_time |
Timestamp of last successful fetch | — |
sensor.git_ha_ppens_last_pull_time |
Timestamp of last successful pull | — |
sensor.git_ha_ppens_last_push_time |
Timestamp of last successful push | — |
sensor.git_ha_ppens_sops_status |
Status of SOPS secret encryption (ready, disabled, binary_missing, no_recipient or no_key) |
enabled, has_encryption_key, has_decryption_key, binary_available, recipient |
Binary Sensors
| Entity | Description | Device Class |
|---|---|---|
binary_sensor.git_ha_ppens_dirty |
on when there are uncommitted changes |
problem |
binary_sensor.git_ha_ppens_sops_ready |
on when SOPS is enabled, binary is available, and keys are configured |
— |
⚡ Events
Use these events as automation triggers to build notifications, dashboards, or recovery workflows.
| Event | Fired when | Data |
|---|---|---|
git_ha_ppens_commit |
A commit is created | hash, message, author, changed_files, auto |
git_ha_ppens_push |
Commits are pushed | commits_pushed |
git_ha_ppens_pull |
Commits are pulled | commits_pulled, changed_files, auto |
git_ha_ppens_fetch |
A fetch completes | — |
git_ha_ppens_check_failed |
A pull or historical restore was blocked and rolled back by the configuration check | errors, auto |
git_ha_ppens_restore |
A historical snapshot was restored as a new commit | target_hash, target_message, restore_hash, commits_restored, changed_files, pushed, auto |
git_ha_ppens_error |
A git operation fails | operation, error |
git_ha_ppens_secret_detected |
Potential secrets are found in staged or modified files during the load-time scan | findings, count |
git_ha_ppens_sops_encrypted |
Secrets files were successfully encrypted | files, encrypted_files |
git_ha_ppens_sops_decrypted |
Secrets files were successfully decrypted | files, decrypted_files |
git_ha_ppens_sops_error |
A SOPS encrypt/decrypt operation fails (manual service call, or during an automatic commit/pull) | operation, error |
💡 Example Automations
🔔 Notify when your instance is behind the remote
A useful GitOps signal: let HA notify you when new commits are available on the remote but haven't been pulled yet (e.g. if auto-pull is disabled).
automation:
- alias: "Git: Notify when behind remote"
trigger:
- platform: numeric_state
entity_id: sensor.git_ha_ppens_commits_behind
above: 0
action:
- service: notify.mobile_app
data:
title: "git-ha-ppens"
message: "{{ states('sensor.git_ha_ppens_commits_behind') }} new commit(s) available on the remote."
⬆️ Auto-push after every commit
automation:
- alias: "Git: Push after commit"
trigger:
- platform: state
entity_id: sensor.git_ha_ppens_last_commit
action:
- service: git_ha_ppens.push
🔔 Notify when changes are uncommitted for over an hour
automation:
- alias: "Git: Remind to commit"
trigger:
- platform: state
entity_id: binary_sensor.git_ha_ppens_dirty
to: "on"
for: "01:00:00"
action:
- service: notify.mobile_app
data:
title: "git-ha-ppens"
message: "You have uncommitted configuration changes."
📅 Weekly configuration snapshot
automation:
- alias: "Git: Weekly snapshot"
trigger:
- platform: time
at: "02:00:00"
condition:
- condition: time
weekday:
- sun
action:
- service: git_ha_ppens.commit
data:
message: "Weekly config snapshot"
🚨 Alert on secret detection
automation:
- alias: "Git: Secret detected alert"
trigger:
- platform: event
event_type: git_ha_ppens_secret_detected
action:
- service: notify.mobile_app
data:
title: "⚠️ git-ha-ppens Security Alert"
message: "Found {{ trigger.event.data.count }} potential secret(s) in staged or modified files!"
🛡️ Alert when remote changes are blocked by the pre-deploy check
automation:
- alias: "Git: Pre-deploy check blocked remote changes"
trigger:
- platform: event
event_type: git_ha_ppens_check_failed
action:
- service: notify.mobile_app
data:
title: "🛡️ git-ha-ppens: Remote changes blocked"
message: >-
Config check failed, rolled back to the last working state:
{{ trigger.event.data.errors | join(', ') }}
🛡️ Auto-Generated .gitignore
The integration automatically creates a .gitignore with sensible defaults for Home Assistant on first setup.
You can customize the .gitignore entries at any time via Settings → Devices & Services → git-ha-ppens → Configure → Edit .gitignore. The built-in editor lets you add, remove, or modify entries directly from the UI.
Only tracked files that are not ignored become part of commits, remote backups,
or historical restores. Home Assistant's UI-managed .storage directory is
excluded by default because it can contain credentials and internal state in
addition to dashboard configuration.
| Category | Entries |
|---|---|
| Sensitive files | secrets.yaml, .storage/, .cloud/, tls/, .ssh/, .jwt_secret, SERVICE_ACCOUNT.json |
| HA Core/Container backups | backups/*.tar, tmp_backups/*.tar (only for the live HA config repository on installations without Supervisor) |
| Databases & logs | *.db, *.db-shm, *.db-wal, *.log, home-assistant_v2.db, home-assistant.log*, zigbee.db, OZW_Log.txt |
| System files | .HA_VERSION, known_devices.yaml, ip_bans.yaml |
| Python cache | __pycache__/, *.pyc, *.pyo |
| Runtime & other | .git/, deps/, tts/, .venv/, .cache/, .claude/, custom_components/, www/snapshots/, .ha_run.lock, .exports, .timeline, .vacuum |
| Zigbee2MQTT | zigbee2mqtt/state.json, zigbee2mqtt/coordinator_backup.json |
| Editor swap files | *.swp, *.swo |
📌 Defaults are applied once during initial setup. After that, you can freely edit
.gitignore— your changes will be preserved across restarts.
Home Assistant Core and Container installations store locally created backup
archives below the configuration directory. These compressed .tar files can
contain the complete configuration and, depending on the backup, the database;
they are large, binary, and potentially highly sensitive. When the configured
repository is the live Home Assistant configuration directory and no Supervisor
is present, git-ha-ppens therefore adds the precise root-relative patterns
backups/*.tar and tmp_backups/*.tar. Home Assistant OS/Supervised uses its
separate Supervisor backup storage, and repositories outside the live config
directory are not changed. Files such as backups/notes.yaml, nested files, and
similarly named directories elsewhere remain trackable.
Existing installations receive the same protection through a versioned
one-time migration. A git-ha-ppens-managed .gitignore is extended only when
Git confirms that its existing rules do not already cover the archives. Matching
archives that were already tracked are removed only from the Git index; the
files on disk and unrelated staged, unstaged, or untracked changes are preserved.
For a manually managed .gitignore, git-ha-ppens never adds rules: it logs a
warning that names any missing pattern and points to Configure → Edit
.gitignore.
⚠️ Removing an archive from the index affects future commits only. It does not remove data from existing local or remote Git history. If a backup archive was already pushed, inspect the repository history and assume credentials in the archive may have been exposed. Rotate affected credentials and clean the history using an appropriate manual process if necessary. git-ha-ppens never rewrites history or force-pushes this migration.
🔧 Troubleshooting
Start with Settings → Devices & Services → git-ha-ppens → Diagnostics and the Home Assistant logs. Diagnostics redact configured credentials and make it easier to identify repository, permission, and remote-status problems.
❌ "Git is not installed"
The Home Assistant Core image used by Home Assistant OS and the official Home Assistant Container image already include Git. If setup still reports this error, restart Home Assistant and install any pending Core update. For a custom container image, install Git in that image during its build.
If your prompt starts with [core-ssh ~], you are inside the separate
Terminal & SSH add-on. Git is bundled with the official add-on, but on an
Alpine-based terminal image it can also be installed with:
apk add git
This makes Git available for manual commands inside that terminal container,
for example against the shared /config directory. It does not install Git
for git-ha-ppens: the integration runs inside Home Assistant Core and therefore
needs Git in the Core container.
If the error occurs with an up-to-date official Home Assistant image, include your Home Assistant version and diagnostics when reporting the problem.
❌ Nothing is pushed / remote status is "no remote" or "not pushed"
- Confirm that a remote URL is configured under Configure → General Settings
- Enable Auto-Push if clean local commits should be sent automatically. This also includes commits created by ESPHome, VS Code, or manual Git commands; no additional git-ha-ppens commit is required
- Press the Push button to commit pending changes and push them manually
- Check the Home Assistant logs if the remote was configured but could not be verified
- A completely empty remote is the simplest first-time setup. If the remote already has history, compatible histories are merged automatically; conflicts fail safely and are never resolved by force-pushing over remote commits
❌ Push fails with "permission denied", "401", or "403"
- Check that the remote URL is correct and the repository exists
- Ensure the token or access key can read and write repository contents
- For GitHub classic tokens, this normally means the
reposcope; fine-grained tokens must have access to the target repository and Contents read/write permission - Verify the token authentication username for your provider:
oauth2for existing GitHub/GitLab setups, commonlyx-token-authfor Bitbucket repository access tokens, or the value required by your provider - For SSH, ensure the private-key path is accessible from Home Assistant Core and the public key is registered with the provider
❌ Auto-pull is not happening
- Auto-Pull is disabled by default and requires a configured remote
- Press Fetch and check the
commits_behindandlast_fetch_timesensors - Confirm that the incoming commits are on the tracked branch
- If the pre-deploy check blocked the pull, review the persistent notification, fix the remote configuration, and push a new commit. The same failing revision is skipped; the new revision is merged and validated automatically. With Auto-Push enabled, the recovered merge is also pushed back to the remote
- If Git reports a real merge conflict, git-ha-ppens aborts the merge without changing either branch. Resolve the conflicting changes manually, then use Pull or Push again
❌ ESPHome or another app created an embedded Git repository
ESPHome Device Builder
runs separately, but it can write to the shared /config directory. Its
version history adopts an existing parent Git repository. If ESPHome starts
before /config/.git exists, however, it can create /config/esphome/.git.
Git may then record esphome as a Gitlink instead of backing up the YAML files
themselves.
git-ha-ppens detects nested .git directories, .git files, and indexed
Gitlinks before changing repository contents or history. It blocks setup and
runtime mutations with a Home Assistant repair. This setup error is an
intentional safety stop, not a crash: open Settings → System → Repairs.
The repair offers a reversible Migrate the ESPHome repository action only
when it can prove that exactly /config/esphome/.git is a simple Device
Builder-managed repository. It refuses repositories with remotes, submodules,
extra worktrees, active Git operations or locks, ignored esphome/ paths,
missing ignore rules for known secrets and Device Builder runtime state,
unexpected index entries, or ambiguous ownership. Before confirming the
migration, either stop ESPHome or disable Settings → Expert mode → Save
version history. The repair then:
- moves the inner
.gitdirectory atomically into a private.git/git-ha-ppens-recovery/...directory instead of deleting it; - prepares the real ESPHome files in a separate temporary Git index;
- rejects Gitlinks, secrets,
.esphome/, key files, and pairing files; - publishes the prepared index only if the real outer index is unchanged.
The success screen shows the recovery path. Keep that directory until you have verified the ESPHome YAML files in the remote repository. With Auto-Commit enabled, the staged snapshot is committed normally; otherwise use Commit or Sync. The inner commit history is retained in the recovery copy but is not merged into the outer history.
If automatic migration is unavailable, use the repair's manual recheck after
the following procedure. The
official Terminal & SSH add-on
mounts /backup writable, which makes it a suitable recovery location:
git -C /config rev-parse --show-toplevel
git -C /config/esphome rev-parse --show-toplevel
git -C /config/esphome status --short
git -C /config/esphome log --oneline -n 10
git -C /config ls-files --stage -- esphome
Disable ESPHome version history where available and stop ESPHome. Then preserve
the inner repository outside /config:
esphome_backup="/backup/esphome-git-$(date +%Y%m%d-%H%M%S)"
mkdir -p "$esphome_backup"
mv /config/esphome/.git "$esphome_backup/dot-git"
Only when the first check showed mode 160000 for esphome, remove that
Gitlink from the outer index:
git -C /config rm --cached -f -- esphome
Before staging, verify that sensitive and runtime paths are ignored:
git -C /config check-ignore -v --no-index -- \
esphome/secrets.yaml \
esphome/.esphome/ \
esphome/.device-builder.json \
esphome/.device-builder-peer-link-key.bin \
esphome/.receiver_peers.json \
esphome/.offloader_pairings.json
Add missing ignore rules first. Then stage and inspect only the ESPHome path:
git -C /config add -A -- esphome
git -C /config status --short -- esphome
git -C /config ls-files --stage -- esphome
YAML files should have mode 100644; no 160000, secrets.yaml, .esphome/,
key, or pairing files may appear. Commit the verified path, reload
git-ha-ppens, restart ESPHome, and confirm that ESPHome now resolves the parent
work tree:
git -C /config commit -m "fix: track ESPHome configuration in main repository" -- esphome
git -C /config/esphome rev-parse --show-toplevel
The expected final output is /config. If it is /config/esphome again,
esphome/ is usually ignored by the outer repository. Keep the recovery copy
until the remote backup has been verified.
Repositories excluded by the outer .gitignore do not block git-ha-ppens.
Correctly declared Git submodules are also allowed for compatibility, but
git-ha-ppens does not commit, pull, push, or otherwise manage their contents
recursively.
For manual installations, also verify that the integration directory is named
/config/custom_components/git_ha_ppens; /config/custom_components/githappens
is not the supported component path and is unrelated to the Git collision.
❌ Auto-commit is not triggering
- Verify
auto_commitis enabled in the integration options - The commit interval is a debounce: it starts after the most recent file change
- Check the current
.gitignore; the watcher reloads it automatically, while.gititself is always ignored - Review HA logs for file watcher errors
- If a Git operation was interrupted, git-ha-ppens automatically removes a regular
.git/index.lockafter it has been stale for at least 15 minutes and retries once - If Home Assistant shows an Automatic commits are blocked repair, first make sure no Git process is running, then remove the exact lock path shown in the repair. The repair clears automatically after the next successful check
❌ UI-managed dashboards or settings are not included
Home Assistant stores many UI-managed dashboards and settings in .storage,
which is ignored by default because it can also contain credentials and internal
state. Removing .storage from .gitignore may expose sensitive data. Prefer
YAML-managed dashboards where practical, or review every file carefully before
tracking selected .storage content.
❌ Configuration restore is unavailable or fails
The working tree must be completely clean, including staged, unstaged, and untracked files. Commit or sync wanted changes, discard unwanted tracked changes, and handle remaining untracked files before starting the restore again. Ignored files are not part of the restore and remain untouched.
❌ "Secrets detected" warning
- Review the flagged files and move sensitive values to
secrets.yaml - Ensure
secrets.yamlis listed in.gitignore(it is by default) - The warning is best-effort, runs when the integration loads, and does not block commits or pushes
- If a credential has already been pushed, revoke or rotate it immediately. Adding the file to
.gitignoredoes not remove the credential from existing Git history
🤝 Contributing
Contributions are welcome! Whether it's bug reports, feature requests, or pull requests — feel free to get involved.
- 🐛 Bug reports & feature requests: GitHub Issues
- 🔀 Pull requests: Fork, create a branch, and submit a PR
Development Setup
- Clone this repository
- Symlink or copy
custom_components/git_ha_ppensinto your HA dev instance'scustom_components/directory - Restart Home Assistant
- Follow Home Assistant's coding conventions (
ruff,mypy)
📄 License
This project is licensed under the MIT License.
Made with ❤️ for the Home Assistant community
github.com/manuveli/git-ha-ppens