From 05f7b2148aa95605b246e0e1f7d91944fc9e0447 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 | 13 ++++++------- usecases/api/types.go | 9 +++++++++ usecases/ca/cdt/public.go | 6 +++--- 3 files changed, 18 insertions(+), 10 deletions(-) diff --git a/usecases/api/ca_cdt.go b/usecases/api/ca_cdt.go index ee53d3a5..30a5143b 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 { @@ -11,26 +10,26 @@ type CaCDTInterface interface { // Scenario 1 - // Return the current setpoints data + // Return the setpoints. // // parameters: // - entity: the entity to get the setpoints data from // // return values: - // - setpoints: A map of the setpoints for supported modes + // - setpoints: A list of setpoints // // possible errors: // - ErrDataNotAvailable if no such limit is (yet) available // - and others Setpoints(entity spineapi.EntityRemoteInterface) ([]Setpoint, error) - // Return the constraints for the setpoints + // Return the constraints for the setpoints. // // parameters: // - entity: the entity to get the setpoints constraints from // // return values: - // - setpointConstraints: A map of the constraints for supported modes + // - setpointConstraints: A list of setpoint constraints // // possible errors: // - ErrDataNotAvailable if no such limit is (yet) available @@ -42,6 +41,6 @@ type CaCDTInterface interface { // parameters: // - 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 + // - temperature: the temperature setpoint value to write + WriteSetpoint(entity spineapi.EntityRemoteInterface, mode HvacOperationModeType, temperature 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 }