Skip to content

feat(ha): install and run Home Assistant ports on the node - #320

Open
Developer-Simon wants to merge 16 commits into
prereleasefrom
feat/ha-ports-node
Open

Developer-Simon wants to merge 16 commits into
prereleasefrom
feat/ha-ports-node

Conversation

@Developer-Simon

Copy link
Copy Markdown
Owner

Squash-merge commit message

- feat(common): read the devices file of a port as a top-level array
- fix(common): use English in the devices loader docstring
- chore(bootstrap): add the Home Assistant ports signing key
- feat(dashboard): allow Home Assistant port sections in the config schema
- feat(bundle): add step 87 for Home Assistant ports
- feat(bootstrap): add the planner for Home Assistant port installs
- fix(bootstrap): validate inputs of the port planner
- feat(bootstrap): install, update and remove Home Assistant ports in step 87
- fix(bootstrap): let step 87 remove ports without a catalog and replace changed wheels
- feat(dashboard): list Home Assistant port units in diagnostics and service logs
- feat(dashboard): let the system action helper read and stop Home Assistant port units
- test(bootstrap): leave the ports step out of the service step rule

Co-authored-by: Claude Sonnet 5.5 <noreply@anthropic.com>

Highlight translations

Highlights (de):
- Home Assistant Ports werden auf dem Node installiert und betrieben

Tour

none

Summary

Makes a node able to run Home Assistant ports: the runner reads the array devices format, step 87 installs, updates and removes ports from the signed catalog, and diagnostics, service logs and the system action helper know port units. The installer side follows in a second PR.

Checks

  • The title is a Conventional Commits subject.
  • scripts/dev/check_tracked_secrets.sh is clean.
  • AI assistance disclosed per AI-DISCLAIMER.md: Claude Sonnet 5.5
  • Suites run locally: pytest, go test, shell tests, shellcheck, local smoke of step 87
  • Linked issue: none

Developer-Simon and others added 16 commits December 6, 2026 10:07
The runner now accepts the devices file as a top-level JSON array. The
legacy {"devices": [...]} object is still read until no node writes it.
Before the MQTT client is built, the runner exits with code 2 when the
port package energy_node_ha_<domain> is not installed.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
The core schema accepts services.ha_<name> sections through
patternProperties, with service_id as the only field. The config
validator now evaluates patternProperties, so matching keys are no
longer rejected by additionalProperties false, and unsupported keywords
inside those subschemas are refused like the rest.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Step 87 is an optional step, on by default, that sets up the Home
Assistant ports. The manifest marks it with ha_ports true, and the
bundle stages the port unit template at ha/energy-node-ha@.service,
rendered to the target user like the other units.

The step script bootstrap/87-*.sh comes in a later change, so until it
exists the manifest carries step 87 without a fingerprint.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
ha_ports.py validates the selected ports against the signed catalog
before anything is written: architecture, Python and layer versions,
and the SHA-256 of the port wheel and its dependencies. plan writes the
manifests and schemas only after all checks pass. config adds the
services.ha_<domain> section once, record writes the installed state.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Domains from the selection, the catalog and the installed state must
match ^[a-z0-9_]{1,40}$. Wheel filenames that are empty, ".", "..", or
contain a slash or backslash are rejected explicitly. A malformed
catalog reports HA_PORTS_CATALOG_INVALID instead of a traceback. The
config step accepts a null services value and rejects any other
non-object. A selection that is not a list of strings is rejected.
SHA-256 comparisons ignore case.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…tep 87

Step 87 reads the port selection, verifies the signed port catalog only
when ports are selected, and runs the planner in lib/ha_ports.py. It
then installs or removes the ports with pip, renders the port unit,
writes manifests, schemas and empty device files, adds the config
sections, and enables or restarts the services. The installed state is
recorded for the update hint. Without a selection and without installed
ports the step is skipped.

The service script test skips 87 like 89, since 87 is not a service
table entry.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…e changed wheels

Without a selection the planner no longer loads catalog.json and only
emits remove lines, so deselecting ports works when ha-ports/ is gone.
record with no domains writes an empty state without the catalog.

When a changed wheel arrives for a port that is already installed, the
step uninstalls the old package before installing the new one. pip
would otherwise skip a rebuilt wheel with an unchanged version.
Dependencies stay installed.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…rvice logs

Diagnose reports the unit of every ha_*.json manifest next to the step
units. The service log accepts ha-<domain> keys for manifests with an
ha_port entry, through ValidateWith and PortUnits. The display name of
ha_<domain>_devices reads "HA: <domain>".

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…stant port units

read-journal accepts the key ha-<domain> when the domain matches
^[a-z0-9_]{1,40}$ and the manifest ha_<domain>.json exists. The unit is
energy-node-ha@<domain>.service. service_units also lists every enabled
energy-node-ha@*.service whose domain passes the same check, so
stop-services and start-services cover port units.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Step 87 installs the Home Assistant ports and has no services/ input,
so the service step rule test must skip it like the 89 example.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
The services object of config.schema.json declares ha_<name> entries via
patternProperties. schema-form.js did not know that keyword, so a file
with an ha_ port was reported as containing unknown fields and fell back
to the raw editor.

findUnknownKeys treats a key that fully matches a pattern as known and
checks its value against that pattern's schema. renderNode renders such
keys as plain children, so readNode writes them back on save. Cache
version of schema-form.js bumped to 3.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
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.

1 participant