package grpc import ( "context" hav1 "gitea.nik4nao.com/nik/home-services/gen/ha/v1" "gitea.nik4nao.com/nik/home-services/ha-gateway/internal/core/ports/driving" ) type SwitchGRPC struct { hav1.UnimplementedSwitchServiceServer svc driving.SwitchService } func NewSwitchGRPC(svc driving.SwitchService) *SwitchGRPC { return &SwitchGRPC{svc: svc} } func (h *SwitchGRPC) ListSwitches(ctx context.Context, req *hav1.ListSwitchesRequest) (*hav1.ListSwitchesResponse, error) { switches, err := h.svc.ListSwitches(ctx) if err != nil { return nil, grpcError(err) } out := make([]*hav1.SwitchEntity, 0, len(switches)) for _, s := range switches { out = append(out, domainSwitchToProto(s)) } return &hav1.ListSwitchesResponse{Switches: out}, nil } // TurnOn, TurnOff, Toggle — left as Unimplemented for now. // TODO: implement once app/switch.go has callService support. // Follow the same pattern as LightGRPC: payload{"entity_id": ...} → ha.CallService. func (h *SwitchGRPC) TurnOn(ctx context.Context, req *hav1.SwitchRequest) (*hav1.SwitchResponse, error) { return nil, grpcError(ErrNotImplemented) } func (h *SwitchGRPC) TurnOff(ctx context.Context, req *hav1.SwitchRequest) (*hav1.SwitchResponse, error) { return nil, grpcError(ErrNotImplemented) } func (h *SwitchGRPC) Toggle(ctx context.Context, req *hav1.SwitchRequest) (*hav1.SwitchResponse, error) { return nil, grpcError(ErrNotImplemented) }