Skip to content

feat(ha): first-party Home Assistant add-on (deploy/homeassistant)#620

Closed
HuggeK wants to merge 3 commits into
srcfl:masterfrom
HuggeK:claude/ha-addon-packaging-issue-v9dkwd
Closed

feat(ha): first-party Home Assistant add-on (deploy/homeassistant)#620
HuggeK wants to merge 3 commits into
srcfl:masterfrom
HuggeK:claude/ha-addon-packaging-issue-v9dkwd

Conversation

@HuggeK

@HuggeK HuggeK commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

Rebased onto current master (v1.4.0 / srcfl/ftw structure). The community
add-on (erikarenhill/ha-addon-forty-two-watts) pinned
ghcr.io/frahlg/forty-two-watts:v1.3.0 and stopped tracking releases after the
Sourceful restructure:

  • Canonical image is now ghcr.io/srcfl/ftw; the frahlg path survives only as
    a byte-identical mirror (same manifest digest).
  • Runtime binary is /app/ftw; the -config/-web/-drivers/-user-drivers
    interface is unchanged, so the wrapper drives it exactly as before.
  • The MPC optimizer, which upstream runs as a separate ftw-optimizer sidecar
    container, is bundled into the add-on image rather than dropped (see below) —
    a single-container add-on can't run a sidecar, so it supervises both processes
    instead.

Adds deploy/homeassistant/ (repository.yaml + ftw/ add-on): an all-in-one
image that bundles the srcfl/ftw:v1.4.0 core with the ftw-optimizer:v1.3.1
Python/CVXPY optimizer in one container. run.sh supervises both — core is the
primary process (its exit code propagates to Supervisor for correct
restart-on-crash), and the optimizer is optional: if it dies, core degrades over
FTW_OPTIMIZER_TRANSPORT=auto (bundled Python worker → in-Go DP planner) instead
of crash-looping the add-on. State lives on Supervisor's /data, the
-user-drivers overlay and host networking are restored, ingress is off (the app
isn't X-Ingress-Path aware), and self-update is off (no updater container).
Version 1.4.0 matches the release line (package.json / release / compose), so
the earlier semver-inversion concern does not apply.

docs/ha-addon.md carries the full findings, storage-growth guidance (Parquet
cold history ~a few GB/year, included in HA backups), and the open-items
checklist (live Supervisor smoke test + publishing the subtree to a root-level
add-on repo remain before release). README gains a Home Assistant add-on install
section.

Claude-Session: https://claude.ai/code/session_01HBjLafzpEYX1dptEE7AGsx

Rebased onto current master (v1.4.0 / srcfl/ftw structure). The community
add-on (erikarenhill/ha-addon-forty-two-watts) pinned
ghcr.io/frahlg/forty-two-watts:v1.3.0 and stopped tracking releases after
the Sourceful restructure:

- Canonical image is now ghcr.io/srcfl/ftw; the frahlg path survives only
  as a byte-identical mirror (same manifest digest).
- Runtime binary is /app/ftw; transparent to the wrapper (CMD overrides
  flags only, inherits ENTRYPOINT; the -config/-web/-drivers/-user-drivers
  interface is unchanged).
- The MPC optimizer runs as a separate ftw-optimizer sidecar container --
  the one restructure a single-container add-on can't mirror.

Adds deploy/homeassistant/ (repository.yaml + ftw/ add-on): a rebase
wrapper targeting srcfl/ftw:v1.4.0 onto Supervisor's /data, restoring the
-user-drivers overlay, host networking, no ingress, self-update off.
Version 1.4.0 matches the release line (package.json / release / compose),
so the earlier semver-inversion concern does not apply.

docs/ha-addon.md carries the full findings, storage-growth guidance
(Parquet cold history ~a few GB/year, included in HA backups), and the
open-items checklist. README gains a Home Assistant add-on install section.

Co-Authored-By: Hugo Karlsson <48095810+HuggeK@users.noreply.github.com>
Co-Authored-By: Erik Arenhill <758402+erikarenhill@users.noreply.github.com>
Claude-Session: https://claude.ai/code/session_01HBjLafzpEYX1dptEE7AGsx
@HuggeK
HuggeK force-pushed the claude/ha-addon-packaging-issue-v9dkwd branch from e781846 to e1681ce Compare July 21, 2026 11:51
HA add-ons are single-container, but FTW now runs as several (core,
Python/CVXPY optimizer, updater, mosquitto). Bundle the two that matter —
core + optimizer — into one image so the add-on ships the full CVXPY
optimizer with no extra setup.

Enabler: core <-> optimizer already talk over a Unix socket
(FTW_OPTIMIZER_TRANSPORT=auto, optimizer runs network_mode:none), so in one
container they just share /run/ftw-optimizer/optimizer.sock.

- Dockerfile bases on the optimizer image (Debian python:3.12-slim + CVXPY
  venv) and COPY --from the fully static, CGO-free Go core; runs unchanged.
- run.sh supervises both under tini (PID1): start optimizer, start core; if
  either exits, tear down and exit non-zero so Supervisor restarts the whole
  add-on. Health check hits core's /api/health.
- build.yaml pins both images (they version independently: core v1.4.0,
  optimizer v1.3.1) and passes FTW_CORE_FROM.
- Drop the updater (Supervisor owns updates) and mosquitto (HA add-on).
- Trade-off documented: the CVXPY stack makes the image a few hundred MB;
  a slim optimizer-less variant is a trivial derivative.

docs/ha-addon.md gains a "multiple containers -> one image" section, the
optimizer open-item is resolved, and the smoke-test command is updated.

Co-Authored-By: Hugo Karlsson <48095810+HuggeK@users.noreply.github.com>
Co-Authored-By: Erik Arenhill <758402+erikarenhill@users.noreply.github.com>
Claude-Session: https://claude.ai/code/session_01HBjLafzpEYX1dptEE7AGsx
@HuggeK
HuggeK force-pushed the claude/ha-addon-packaging-issue-v9dkwd branch 2 times, most recently from 08ea5f7 to f706f5c Compare July 21, 2026 13:42
@HuggeK

HuggeK commented Jul 21, 2026

Copy link
Copy Markdown
Contributor Author

Vad tycks @erikarenhill ?

@frahlg om nu ftw-web-sidan skriver om ett HA-addon, vad sägs då om att skapa ett srcfl/ftw-ha-addon eller något liknande namn?

The previous run.sh had two defects flagged in review:

1. It always exited 0 (the final `wait ... || true` swallowed the code),
   so a crashed core never signalled failure and Supervisor had no reason
   to restart the add-on.
2. `wait -n` on both PIDs plus an unconditional teardown coupled the
   optimizer's liveness to core: a transient optimizer crash (e.g. CVXPY
   OOM on a small Pi) tore down a healthy core, turning graceful
   degradation into a whole-add-on crash loop.

Rework the supervision model around core as the primary process:

- Wait on CORE only and `exit` with its code, so success/failure
  propagates to Supervisor (non-zero -> restart, SIGTERM -> clean 0).
- Supervise the optimizer in a background loop with capped exponential
  backoff and a healthy-run reset; after repeated failures it gives up and
  leaves core running on the in-Go DP planner (transport=auto) instead of
  restarting the whole container. Its death no longer touches core.

Control flow verified with stubbed binaries: optimizer crash-loop leaves
core running, core rc=7 propagates, SIGTERM exits 0. The socket path and
optimizer entrypoint still need the live Supervisor smoke test.

Co-Authored-By: Hugo Karlsson <48095810+HuggeK@users.noreply.github.com>
Co-Authored-By: Erik Arenhill <758402+erikarenhill@users.noreply.github.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HBjLafzpEYX1dptEE7AGsx
@HuggeK
HuggeK force-pushed the claude/ha-addon-packaging-issue-v9dkwd branch from cc75d1e to 54d0ef5 Compare July 21, 2026 16:13
@erikarenhill

Copy link
Copy Markdown
Contributor

Vad tycks @erikarenhill ?

@frahlg om nu ftw-web-sidan skriver om ett HA-addon, vad sägs då om att skapa ett srcfl/ftw-ha-addon eller något liknande namn?

låter rimligt med en officiell addon, den jag satte upp var mest ett snabbhack 😊

@frahlg

frahlg commented Jul 22, 2026

Copy link
Copy Markdown
Member

Packaging decision — 2026-07-22

Recommendation: do not merge this subtree into srcfl/ftw. Put the first-party package in a separate official repository, preferably srcfl/home-assistant-addons if that name is approved.

Home Assistant requires repository.yaml at the Git root, so users cannot add deploy/homeassistant/ to Supervisor. Current Home Assistant guidance also prefers pre-built multi-architecture images. This PR has no image: entry in config.yaml, so its current public path would make each Home Assistant host build the image locally.

Proposed boundary:

  • The add-on repo owns repository.yaml, the FTW app manifest, wrapper and process supervision, Home Assistant docs and assets, the add-on image, CI, and releases.
  • srcfl/ftw owns the FTW runtime and API. It should contain only a short install link and compatibility notes.
  • Add-on install, boot, update, mount, and Supervisor faults go to the add-on repo. FTW runtime and device faults go to the right upstream repo.
  • Community support remains best effort with no SLA. Commercial support stays a separate Sourceful service.

Minimum new repo:

repository.yaml
LICENSE
README.md
SUPPORT.md
SECURITY.md
CODEOWNERS
ftw/
  config.yaml
  build.yaml
  Dockerfile
  run.sh
  README.md
  DOCS.md
  CHANGELOG.md
  icon.png
  logo.png
.github/workflows/
  check.yml
  release.yml

The add-on should use its own version, pin a tested Core and Optimizer pair, publish a pre-built amd64/aarch64 image to GHCR, pass a live Home Assistant OS/Supervisor smoke test, publish beta first, and promote the tested artifact to stable.

Keep #620 as a draft source until the new repo gets approval. Then move and adapt the package in a new-repo PR, make a small docs-only FTW PR with the install link, and close #620 as moved. Do not merge this PR as-is.

Current checks pass, but most code checks skip these paths. The PR still lacks a live Supervisor build and boot test.

References: Home Assistant repository rules and publishing guidance.

@frahlg

frahlg commented Jul 22, 2026 via email

Copy link
Copy Markdown
Member

frahlg commented Jul 22, 2026

Copy link
Copy Markdown
Member

Moved to the official Home Assistant repository: https://github.com/srcfl/home-assistant-addons

The usable add-on work from this PR now lives in the new repository and was merged through srcfl/home-assistant-addons#1. The new repository also records the source work and attribution in https://github.com/srcfl/home-assistant-addons/blob/main/ATTRIBUTION.md.

Home Assistant requires repository.yaml at the Git root, so the add-on could not stay under deploy/homeassistant in this repository. I am closing this PR as moved. A small FTW docs PR will add the official repository link and current beta status. No add-on beta or stable image has been published yet.

@frahlg frahlg closed this Jul 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants