From dc118c1cde288a17536402883d90a700eeae13d8 Mon Sep 17 00:00:00 2001 From: David Sapir Date: Wed, 6 Nov 2024 13:35:37 +0200 Subject: [PATCH] Add HvacOperationModeType to usecase types --- usecases/api/ca_cdt.go | 3 +-- usecases/api/types.go | 9 +++++++++ usecases/ca/cdt/public.go | 6 +++--- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/usecases/api/ca_cdt.go b/usecases/api/ca_cdt.go index ee53d3a5..ef54ef10 100644 --- a/usecases/api/ca_cdt.go +++ b/usecases/api/ca_cdt.go @@ -3,7 +3,6 @@ package api import ( "github.com/enbility/eebus-go/api" spineapi "github.com/enbility/spine-go/api" - "github.com/enbility/spine-go/model" ) type CaCDTInterface interface { @@ -43,5 +42,5 @@ type CaCDTInterface interface { // - entity: the entity to write the setpoint to // - mode: the mode to write the setpoint for // - degC: the temperature setpoint value to write - WriteSetpoint(entity spineapi.EntityRemoteInterface, mode model.HvacOperationModeTypeType, degC float64) error + WriteSetpoint(entity spineapi.EntityRemoteInterface, mode HvacOperationModeType, degC float64) error } diff --git a/usecases/api/types.go b/usecases/api/types.go index c2516e0e..76bf9ce3 100644 --- a/usecases/api/types.go +++ b/usecases/api/types.go @@ -17,6 +17,15 @@ const ( EVChargeStateTypeFinished EVChargeStateType = "finished" ) +type HvacOperationModeType string + +const ( + HvacOperationModeTypeAuto HvacOperationModeType = "auto" + HvacOperationModeTypeOn HvacOperationModeType = "on" + HvacOperationModeTypeOff HvacOperationModeType = "off" + HvacOperationModeTypeEco HvacOperationModeType = "eco" +) + // Defines a phase specific limit data set type LoadLimitsPhase struct { Phase model.ElectricalConnectionPhaseNameType // the phase diff --git a/usecases/ca/cdt/public.go b/usecases/ca/cdt/public.go index bd42b26a..b27d0c49 100644 --- a/usecases/ca/cdt/public.go +++ b/usecases/ca/cdt/public.go @@ -194,10 +194,10 @@ func (e *CDT) mapSetpointsToModes(entity spineapi.EntityRemoteInterface) error { // - Other errors: Any other errors encountered during the process. func (e *CDT) WriteSetpoint( entity spineapi.EntityRemoteInterface, - mode model.HvacOperationModeTypeType, + mode usecasesapi.HvacOperationModeType, temperature float64, ) error { - if mode == model.HvacOperationModeTypeTypeAuto { + if model.HvacOperationModeTypeType(mode) == model.HvacOperationModeTypeTypeAuto { // 'Auto' mode is controlled by a timetable, meaning the current setpoint // for the HVAC system function changes according to the timetable. // Only the 'Off', 'On', and 'Eco' modes can be directly controlled by a setpoint. @@ -208,7 +208,7 @@ func (e *CDT) WriteSetpoint( return api.ErrDataNotAvailable } - setpointId, found := e.modes[mode] + setpointId, found := e.modes[model.HvacOperationModeTypeType(mode)] if !found { return api.ErrDataNotAvailable }