Skip to content

Commit

Permalink
Add HvacOperationModeType to usecase types
Browse files Browse the repository at this point in the history
  • Loading branch information
David Sapir committed Nov 6, 2024
1 parent fe2b702 commit 03e6e6f
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
3 changes: 1 addition & 2 deletions usecases/api/ca_cdt.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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
}
9 changes: 9 additions & 0 deletions usecases/api/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,15 @@ const (
EVChargeStateTypeFinished EVChargeStateType = "finished"
)

type HvacOperationModeType string

const (
HvacOperationModeTypeTypeAuto HvacOperationModeType = "auto"
HvacOperationModeTypeTypeOn HvacOperationModeType = "on"
HvacOperationModeTypeTypeOff HvacOperationModeType = "off"
HvacOperationModeTypeTypeEco HvacOperationModeType = "eco"
)

// Defines a phase specific limit data set
type LoadLimitsPhase struct {
Phase model.ElectricalConnectionPhaseNameType // the phase
Expand Down
6 changes: 3 additions & 3 deletions usecases/ca/cdt/public.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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
}
Expand Down

0 comments on commit 03e6e6f

Please sign in to comment.