Ingestion: Home Assistant WebSocket push path
ci / build-test (push) Successful in 1m16s

HomeAssistantWebSocketWorker holds a persistent state_changed subscription per HA endpoint that opts in via the connector's WebSocket toggle (HaEndpointConfig.UseWebSocket): auth handshake, subscribe, ingest in real time, capped-backoff reconnect. The REST poll worker skips WS endpoints so each is served once. HaWebSocketProtocol holds the pure handshake/parse logic. Verified by 11 protocol unit tests + a live integration test against an in-process fake HA server. CLAUDE.md updated.

Claude-Session: https://claude.ai/code/session_01Kib2MniVFbD95fkgLgBBnB
This commit is contained in:
2026-07-17 11:05:01 +02:00
parent 14930bc3d8
commit 8550ed8d9e
10 changed files with 695 additions and 8 deletions
@@ -22,6 +22,13 @@ public sealed record HaEndpointConfig
/// <summary>Name of the environment variable holding the long-lived access token.</summary>
public string? TokenEnv { get; init; }
/// <summary>
/// When true, a persistent WebSocket subscription pushes state changes in real time
/// (<see cref="HomeAssistantWebSocketWorker"/>); when false (default) the REST poll worker
/// samples on each source's interval. An endpoint is handled by exactly one of the two.
/// </summary>
public bool UseWebSocket { get; init; }
public static HaEndpointConfig Parse(string? json)
{
if (string.IsNullOrWhiteSpace(json))