package grpc import ( "context" hav1 "gitea.nik4nao.com/nik/home-services/gen/ha/v1" "gitea.nik4nao.com/nik/home-services/ha-gateway/internal/core/domain" "gitea.nik4nao.com/nik/home-services/ha-gateway/internal/core/ports/driving" ) type LightGRPC struct { hav1.UnimplementedLightServiceServer svc driving.LightService } func NewLightGRPC(svc driving.LightService) *LightGRPC { return &LightGRPC{svc: svc} } func (h *LightGRPC) TurnOn(ctx context.Context, req *hav1.TurnOnRequest) (*hav1.LightResponse, error) { s, err := h.svc.TurnOn(ctx, protoTurnOnToParams(req)) if err != nil { return nil, grpcError(err) } return &hav1.LightResponse{State: domainStateToProto(s)}, nil } func (h *LightGRPC) TurnOff(ctx context.Context, req *hav1.TurnOffRequest) (*hav1.LightResponse, error) { s, err := h.svc.TurnOff(ctx, protoTurnOffToParams(req)) if err != nil { return nil, grpcError(err) } return &hav1.LightResponse{State: domainStateToProto(s)}, nil } func (h *LightGRPC) Toggle(ctx context.Context, req *hav1.ToggleRequest) (*hav1.LightResponse, error) { s, err := h.svc.Toggle(ctx, domain.EntityID(req.EntityId)) if err != nil { return nil, grpcError(err) } return &hav1.LightResponse{State: domainStateToProto(s)}, nil }