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 } // NewSwitchGRPC constructs the gRPC adapter for SwitchService. func NewSwitchGRPC(svc driving.SwitchService) *SwitchGRPC { return &SwitchGRPC{svc: svc} } // ListSwitches returns discovery-oriented switch metadata for clients. 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 is stubbed until switch control orchestration exists in the app layer. // TODO: implement switch control RPCs — see plan.md for context func (h *SwitchGRPC) TurnOn(ctx context.Context, req *hav1.SwitchRequest) (*hav1.SwitchResponse, error) { return nil, grpcError(ErrNotImplemented) } // TurnOff is stubbed until switch control orchestration exists in the app layer. // TODO: implement switch control RPCs — see plan.md for context func (h *SwitchGRPC) TurnOff(ctx context.Context, req *hav1.SwitchRequest) (*hav1.SwitchResponse, error) { return nil, grpcError(ErrNotImplemented) } // Toggle is stubbed until switch control orchestration exists in the app layer. // TODO: implement switch control RPCs — see plan.md for context func (h *SwitchGRPC) Toggle(ctx context.Context, req *hav1.SwitchRequest) (*hav1.SwitchResponse, error) { return nil, grpcError(ErrNotImplemented) }