Nik Afiq b327150d45
All checks were successful
CI / test (push) Successful in 5s
CI / build-ai-gateway (push) Successful in 39s
CI / build-ha-gateway (push) Successful in 39s
CI / build-discord-bot (push) Successful in 40s
feat: implement ClimateApp for managing HVAC entities
- Added ClimateApp to handle climate entity operations including turning on/off, adjusting temperature, and setting HVAC modes.
- Implemented caching mechanism for climate entities to optimize state retrieval.
- Created domain model for Climate with attributes such as current temperature, target temperature, and HVAC modes.
- Developed unit tests for ClimateApp to ensure functionality and correctness.

feat: add RemoteApp for SwitchBot commands

- Introduced RemoteApp to facilitate sending commands to SwitchBot devices.
- Implemented SendCommand method for executing device commands without state management.

chore: update configuration for SwitchBot integration

- Added SwitchBotToken and SwitchBotSecret to configuration for enabling SwitchBot Cloud commands.

feat: define gRPC services for Climate and Remote operations

- Created climate.proto and remote.proto files to define gRPC services for climate management and remote command execution.
- Implemented corresponding request and response message structures for gRPC interactions.
2026-07-23 13:49:54 +09:00

27 lines
789 B
Go

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 RemoteGRPC struct {
hav1.UnimplementedRemoteServiceServer
svc driving.RemoteService
}
// NewRemoteGRPC constructs the gRPC adapter for RemoteService.
func NewRemoteGRPC(svc driving.RemoteService) *RemoteGRPC {
return &RemoteGRPC{svc: svc}
}
// SendCommand forwards a SwitchBot Cloud device command to the domain service.
func (h *RemoteGRPC) SendCommand(ctx context.Context, req *hav1.SendCommandRequest) (*hav1.SendCommandResponse, error) {
if err := h.svc.SendCommand(ctx, req.DeviceId, req.Command, req.CommandType); err != nil {
return nil, grpcError(err)
}
return &hav1.SendCommandResponse{}, nil
}