syntax = "proto3"; package ha.v1; option go_package = "gitea.nik4nao.com/nik/home-services/gen/ha/v1;hav1"; import "ha/v1/common.proto"; // TODO: implement EventService fan-out. // Architecture: // 1. adapters/secondary/ha/websocket.go connects to HA WebSocket, // authenticates, and subscribes to state_changed events. // 2. An internal broker (internal/fanout/broker.go) holds a sync.Map of // subscriber channels, one per active Subscribe stream. // 3. The WebSocket adapter publishes to the broker; the gRPC Subscribe // handler reads from its channel and streams to the client. // 4. On client disconnect (ctx.Done()), the handler deregisters its channel. service EventService { rpc Subscribe(SubscribeRequest) returns (stream StateChangeEvent); } message SubscribeRequest { repeated string entity_ids = 1; repeated string domains = 2; } message StateChangeEvent { string entity_id = 1; optional EntityState old_state = 2; // absent on first appearance EntityState new_state = 3; string event_time = 4; // RFC3339 }