Skip to content

feat(common): add a Home Assistant compat layer for ported integrations - #319

Merged
Developer-Simon merged 12 commits into
prereleasefrom
feat/ha-compat-layer
Dec 6, 2026
Merged

Developer-Simon merged 12 commits into
prereleasefrom
feat/ha-compat-layer

Conversation

@Developer-Simon

Copy link
Copy Markdown
Owner

Squash-merge commit message

Adds `energy_node_common.ha`, a small layer that follows the Home Assistant API surface simple polling integrations use, so a ported HA integration runs as an energy-node service and publishes its entities as MQTT discovery and state topics. This is project 1 of the HA ports. Ports themselves, the signed catalog and the rollout follow in separate projects.

- Base modules: `HomeAssistant`, `ConfigEntry` with subentries, exceptions, constants, `slugify`, `util.dt`, one aiohttp session per config entry. New extra `ha` (aiohttp), CI installs it
- Entities and coordinator: `Entity`, `SensorEntity`, `BinarySensorEntity` with descriptions, `DataUpdateCoordinator` with its own timer and `async_shutdown`, `CoordinatorEntity`, `async_track_point_in_utc_time`. The timer keeps polling after config entry errors and failing listeners
- Runtime: `run_integration` builds the entry from a devices record, forwards `sensor` and `binary_sensor`, names entities from the integration's translations, maps enums, dicts and lists to payloads and rejects unsupported platforms and duplicate object IDs
- Runner: `python3 -m energy_node_common.ha <domain>` reads `ha_<domain>_devices.json`, reports `outstation/ha_<domain>/status/online` with a reason, exits 1 on setup failure and 2 on a missing or broken devices file. systemd template `energy-node-ha@.service` (not rolled out yet)
- `ha/README.md` describes the port contract, topics and license split

The layer stays importable on Python 3.11 and no other module of `energy_node_common` imports it. A real Forecast.Solar port ran end to end against a local broker and the demo.

Known limits:
- Only `sensor` and `binary_sensor`. No config flows, services, recorder or repairs
- Ports need Python 3.12 or newer, so they only target Trixie nodes

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

Highlight translations

Highlights (de):
- Kompatibilitätsschicht für portierte Home-Assistant-Integrationen

Tour

none

Summary

Adds energy_node_common.ha, a small layer that follows the Home Assistant API surface simple polling integrations use, so a ported HA integration runs as an energy-node service and publishes its entities as MQTT discovery and state topics. This is project 1 of the HA ports. Ports themselves, the signed catalog and the rollout follow in separate projects.

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
  • Linked issue: none

Developer-Simon and others added 12 commits December 6, 2026 01:01
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…ayer

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>
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>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…lar and nordpool

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@Developer-Simon
Developer-Simon merged commit fb0eb1c into prerelease Dec 6, 2026
30 checks passed
@Developer-Simon
Developer-Simon deleted the feat/ha-compat-layer branch December 6, 2026 00:44
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