Feat: apply pulled changes to running HA after sync (apply_after_pull) - #6
Merged
Conversation
The add-on pulled merged PRs into /config but never told Home Assistant
to load them, so every merged change still required a manual "Reload
Automations". Files on disk were not the running config.
Add an apply_after_pull option (reload | restart | off, default reload).
When a sync advances HEAD (a merged PR came down) and not in dry_run, the
add-on calls the Home Assistant service via the Supervisor proxy:
- reload -> homeassistant.reload_all (automations, scripts, scenes,
templates, input_*), no restart
- restart -> homeassistant.restart (for configuration.yaml integration or
custom_components changes that are not hot-reloadable)
- off -> previous behaviour
Enables homeassistant_api so SUPERVISOR_TOKEN is accepted by the core API
proxy. Bumps version to 0.3.0 and adds static wiring asserts to the
self-check.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Signed-off-by: Anil Belur <abelur@linuxfoundation.org>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The add-on pulls merged PRs into
/config(git pull --rebase) but never tells Home Assistant to load them. Files on disk ≠ running config, so every merged change still needs a manual Reload Automations.Change
New option
apply_after_pull(reload|restart|off, defaultreload). When a sync advancesHEAD(a merged PR came down) and not indry_run, the add-on applies it via the Supervisor → core API proxy:reload→homeassistant.reload_all(automations, scripts, scenes, templates,input_*) — no restartrestart→homeassistant.restart— forconfiguration.yamlintegration orcustom_components/changes that aren't hot-reloadableoff→ previous behaviourEnables
homeassistant_apisoSUPERVISOR_TOKENis accepted by the core API proxy. Only fires on real upstream change, never on no-op runs or dry-run.Files
config.json—homeassistant_api: true, new option + schemalist(reload|restart|off), version →0.3.0rootfs/app/gitops_backup.sh— read option,ha_apply()helper, captureHEADaround the pull, apply after stash-popDOCS.md,translations/en.yaml,CHANGELOG.md— document the optiontests/self_check.sh— static wiring assertsValidation
jq empty config.jsonOK;bash -n+shellcheckclean;yamllint .cleanbash tests/self_check.sh→ OK: all self-checks passedNotes
reload_alldoes not applyconfiguration.yamlintegration orcustom_components/changes — that's therestartoption, documented, not a silent gap.