From 723e0a4d6dbce0ec25550b51860f9e8617b81546 Mon Sep 17 00:00:00 2001 From: Andreas Linde Date: Sat, 29 Jun 2024 16:24:52 +0200 Subject: [PATCH 1/8] Update README badges --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 0e66927f..871a5eba 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,8 @@ # eebus-go -[![Build Status](https://github.com/enbility/eebus-go/actions/workflows/default.yml/badge.svg?branch=main)](https://github.com/enbility/eebus-go/actions/workflows/default.yml/badge.svg?branch=main) +[![Build Status](https://github.com/enbility/eebus-go/actions/workflows/default.yml/badge.svg?branch=dev)](https://github.com/enbility/eebus-go/actions/workflows/default.yml/badge.svg?branch=dev) [![GoDoc](https://img.shields.io/badge/godoc-reference-5272B4)](https://godoc.org/github.com/enbility/eebus-go) -[![Coverage Status](https://coveralls.io/repos/github/enbility/eebus-go/badge.svg?branch=main)](https://coveralls.io/github/enbility/eebus-go?branch=main) +[![Coverage Status](https://coveralls.io/repos/github/enbility/eebus-go/badge.svg?branch=dev)](https://coveralls.io/github/enbility/eebus-go?branch=dev) [![Go report](https://goreportcard.com/badge/github.com/enbility/eebus-go)](https://goreportcard.com/report/github.com/enbility/eebus-go) [![CodeFactor](https://www.codefactor.io/repository/github/enbility/eebus-go/badge)](https://www.codefactor.io/repository/github/enbility/eebus-go) From e62fa5ee928e534228e271efb1dd2438fc8a4c9c Mon Sep 17 00:00:00 2001 From: Andreas Linde Date: Sat, 29 Jun 2024 16:59:19 +0200 Subject: [PATCH 2/8] Fix usecase readme --- usecases/README.md | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/usecases/README.md b/usecases/README.md index 230ee146..47a977b1 100644 --- a/usecases/README.md +++ b/usecases/README.md @@ -29,12 +29,8 @@ Actors: - `lpc`: Limitation of Power Consumption - `lpp`: Limitation of Power Production -- `gcp`: Grid Connection Point - - Use Cases: - - `mgcp`: Monitoring of Grid Connection Point - - `ma`: Monitoring Appliance Use Cases: - `mpc`: Monitoring of Power Consumption + - `mgcp`: Monitoring of Grid Connection Point From fd922854fc4d8604eb10eefe50adbaea7ebf44f5 Mon Sep 17 00:00:00 2001 From: Andreas Linde Date: Fri, 5 Jul 2024 09:55:41 +0200 Subject: [PATCH 3/8] More tests and improve a log message --- features/client/feature.go | 4 +++- features/client/feature_test.go | 8 ++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/features/client/feature.go b/features/client/feature.go index 58ed51b2..cc695970 100644 --- a/features/client/feature.go +++ b/features/client/feature.go @@ -2,6 +2,7 @@ package client import ( "errors" + "fmt" "github.com/enbility/eebus-go/api" spineapi "github.com/enbility/spine-go/api" @@ -135,7 +136,8 @@ func (f *Feature) requestData(function model.FunctionType, selectors any, elemen fTypes := f.featureRemote.Operations() op, exists := fTypes[function] if !exists || !op.Read() { - return nil, api.ErrOperationOnFunctionNotSupported + errWithFunction := fmt.Sprintf("%s %s", api.ErrOperationOnFunctionNotSupported.Error(), function) + return nil, errors.New(errWithFunction) } // remove the selectors if the remote does not allow partial reads diff --git a/features/client/feature_test.go b/features/client/feature_test.go index 326c50ee..cf49aa07 100644 --- a/features/client/feature_test.go +++ b/features/client/feature_test.go @@ -155,6 +155,14 @@ func (s *FeatureSuite) Test_requestData() { assert.Nil(s.T(), err) assert.NotNil(s.T(), counter) + counter, err = s.testFeature2.requestData(model.FunctionTypeMeasurementDescriptionListData, nil, nil) + assert.NotNil(s.T(), err) + assert.Nil(s.T(), counter) + + counter, err = s.testFeature2.requestData(model.FunctionTypeLoadControlLimitListData, nil, nil) + assert.Nil(s.T(), err) + assert.NotNil(s.T(), counter) + selectors2 := &model.LoadControlLimitListDataSelectorsType{ LimitId: util.Ptr(model.LoadControlLimitIdType(0)), } From aef0f7bf9e5d32fc319e82cf989ca95f541320ee Mon Sep 17 00:00:00 2001 From: Andreas Linde Date: Fri, 5 Jul 2024 10:56:43 +0200 Subject: [PATCH 4/8] Fix EVCem Workaround for power not provided Add tests with real example data and fix workaround using currents to provide power values, if there are power descriptions but no values provided. (E.g. Elli Charger Connect/Pro Gen 1) --- usecases/cem/evcem/public.go | 3 +- usecases/cem/evcem/public_test.go | 117 +++++++++++++++++++++++++++++- 2 files changed, 117 insertions(+), 3 deletions(-) diff --git a/usecases/cem/evcem/public.go b/usecases/cem/evcem/public.go index 3373402f..1371cfac 100644 --- a/usecases/cem/evcem/public.go +++ b/usecases/cem/evcem/public.go @@ -138,7 +138,8 @@ func (e *EVCEM) PowerPerPhase(entity spineapi.EntityRemoteInterface) ([]float64, ScopeType: util.Ptr(model.ScopeTypeTypeACPower), } data, err = evMeasurement.GetDataForFilter(filter) - if err != nil || len(data) == 0 { + // Elli Charger Connect/Pro (Gen1) returns power descriptions, but only measurements without actual values, see test caseTest_EVPowerPerPhase_Current + if err != nil || len(data) == 0 || data[0].Value == nil { powerAvailable = false // If power is not provided, fall back to power calculations via currents diff --git a/usecases/cem/evcem/public_test.go b/usecases/cem/evcem/public_test.go index 8f65541f..8f32c44c 100644 --- a/usecases/cem/evcem/public_test.go +++ b/usecases/cem/evcem/public_test.go @@ -249,9 +249,58 @@ func (s *CemEVCEMSuite) Test_EVPowerPerPhase_Current() { { ElectricalConnectionId: util.Ptr(model.ElectricalConnectionIdType(0)), ParameterId: util.Ptr(model.ElectricalConnectionParameterIdType(0)), + ScopeType: util.Ptr(model.ScopeTypeTypeACPowerTotal), + AcMeasuredPhases: util.Ptr(model.ElectricalConnectionPhaseNameTypeAbc), + }, + { + ElectricalConnectionId: util.Ptr(model.ElectricalConnectionIdType(0)), + ParameterId: util.Ptr(model.ElectricalConnectionParameterIdType(1)), MeasurementId: util.Ptr(model.MeasurementIdType(0)), ScopeType: util.Ptr(model.ScopeTypeTypeACCurrent), AcMeasuredPhases: util.Ptr(model.ElectricalConnectionPhaseNameTypeA), + AcMeasurementVariant: util.Ptr(model.ElectricalConnectionMeasurandVariantTypeRms), + }, + { + ElectricalConnectionId: util.Ptr(model.ElectricalConnectionIdType(0)), + ParameterId: util.Ptr(model.ElectricalConnectionParameterIdType(2)), + MeasurementId: util.Ptr(model.MeasurementIdType(1)), + ScopeType: util.Ptr(model.ScopeTypeTypeACCurrent), + AcMeasuredPhases: util.Ptr(model.ElectricalConnectionPhaseNameTypeB), + AcMeasurementVariant: util.Ptr(model.ElectricalConnectionMeasurandVariantTypeRms), + }, + { + ElectricalConnectionId: util.Ptr(model.ElectricalConnectionIdType(0)), + ParameterId: util.Ptr(model.ElectricalConnectionParameterIdType(3)), + MeasurementId: util.Ptr(model.MeasurementIdType(2)), + ScopeType: util.Ptr(model.ScopeTypeTypeACCurrent), + AcMeasuredPhases: util.Ptr(model.ElectricalConnectionPhaseNameTypeC), + AcMeasurementVariant: util.Ptr(model.ElectricalConnectionMeasurandVariantTypeRms), + }, + { + ElectricalConnectionId: util.Ptr(model.ElectricalConnectionIdType(0)), + ParameterId: util.Ptr(model.ElectricalConnectionParameterIdType(4)), + MeasurementId: util.Ptr(model.MeasurementIdType(3)), + AcMeasuredPhases: util.Ptr(model.ElectricalConnectionPhaseNameTypeA), + }, + { + ElectricalConnectionId: util.Ptr(model.ElectricalConnectionIdType(0)), + ParameterId: util.Ptr(model.ElectricalConnectionParameterIdType(5)), + MeasurementId: util.Ptr(model.MeasurementIdType(4)), + AcMeasuredPhases: util.Ptr(model.ElectricalConnectionPhaseNameTypeB), + }, + { + ElectricalConnectionId: util.Ptr(model.ElectricalConnectionIdType(0)), + ParameterId: util.Ptr(model.ElectricalConnectionParameterIdType(6)), + MeasurementId: util.Ptr(model.MeasurementIdType(5)), + AcMeasuredPhases: util.Ptr(model.ElectricalConnectionPhaseNameTypeC), + }, + { + ElectricalConnectionId: util.Ptr(model.ElectricalConnectionIdType(0)), + ParameterId: util.Ptr(model.ElectricalConnectionParameterIdType(7)), + MeasurementId: util.Ptr(model.MeasurementIdType(6)), + VoltageType: util.Ptr(model.ElectricalConnectionVoltageTypeTypeAc), + AcMeasuredPhases: util.Ptr(model.ElectricalConnectionPhaseNameTypeAbc), + AcMeasurementType: util.Ptr(model.ElectricalConnectionAcMeasurementTypeTypeReal), }, }, } @@ -271,6 +320,49 @@ func (s *CemEVCEMSuite) Test_EVPowerPerPhase_Current() { MeasurementType: util.Ptr(model.MeasurementTypeTypeCurrent), CommodityType: util.Ptr(model.CommodityTypeTypeElectricity), ScopeType: util.Ptr(model.ScopeTypeTypeACCurrent), + Unit: util.Ptr(model.UnitOfMeasurementTypeA), + }, + { + MeasurementId: util.Ptr(model.MeasurementIdType(1)), + MeasurementType: util.Ptr(model.MeasurementTypeTypeCurrent), + CommodityType: util.Ptr(model.CommodityTypeTypeElectricity), + ScopeType: util.Ptr(model.ScopeTypeTypeACCurrent), + Unit: util.Ptr(model.UnitOfMeasurementTypeA), + }, + { + MeasurementId: util.Ptr(model.MeasurementIdType(2)), + MeasurementType: util.Ptr(model.MeasurementTypeTypeCurrent), + CommodityType: util.Ptr(model.CommodityTypeTypeElectricity), + ScopeType: util.Ptr(model.ScopeTypeTypeACCurrent), + Unit: util.Ptr(model.UnitOfMeasurementTypeA), + }, + { + MeasurementId: util.Ptr(model.MeasurementIdType(3)), + MeasurementType: util.Ptr(model.MeasurementTypeTypePower), + CommodityType: util.Ptr(model.CommodityTypeTypeElectricity), + ScopeType: util.Ptr(model.ScopeTypeTypeACPower), + Unit: util.Ptr(model.UnitOfMeasurementTypeW), + }, + { + MeasurementId: util.Ptr(model.MeasurementIdType(4)), + MeasurementType: util.Ptr(model.MeasurementTypeTypePower), + CommodityType: util.Ptr(model.CommodityTypeTypeElectricity), + ScopeType: util.Ptr(model.ScopeTypeTypeACPower), + Unit: util.Ptr(model.UnitOfMeasurementTypeW), + }, + { + MeasurementId: util.Ptr(model.MeasurementIdType(5)), + MeasurementType: util.Ptr(model.MeasurementTypeTypePower), + CommodityType: util.Ptr(model.CommodityTypeTypeElectricity), + ScopeType: util.Ptr(model.ScopeTypeTypeACPower), + Unit: util.Ptr(model.UnitOfMeasurementTypeW), + }, + { + MeasurementId: util.Ptr(model.MeasurementIdType(6)), + MeasurementType: util.Ptr(model.MeasurementTypeTypeEnergy), + CommodityType: util.Ptr(model.CommodityTypeTypeElectricity), + ScopeType: util.Ptr(model.ScopeTypeTypeCharge), + Unit: util.Ptr(model.UnitOfMeasurementTypeWh), }, }, } @@ -287,7 +379,27 @@ func (s *CemEVCEMSuite) Test_EVPowerPerPhase_Current() { MeasurementData: []model.MeasurementDataType{ { MeasurementId: util.Ptr(model.MeasurementIdType(0)), - Value: model.NewScaledNumberType(10), + Value: model.NewScaledNumberType(5.09), + }, + { + MeasurementId: util.Ptr(model.MeasurementIdType(1)), + Value: model.NewScaledNumberType(4.04), + }, + { + MeasurementId: util.Ptr(model.MeasurementIdType(2)), + Value: model.NewScaledNumberType(5.09), + }, + { + MeasurementId: util.Ptr(model.MeasurementIdType(3)), + }, + { + MeasurementId: util.Ptr(model.MeasurementIdType(4)), + }, + { + MeasurementId: util.Ptr(model.MeasurementIdType(5)), + }, + { + MeasurementId: util.Ptr(model.MeasurementIdType(6)), }, }, } @@ -297,7 +409,8 @@ func (s *CemEVCEMSuite) Test_EVPowerPerPhase_Current() { data, err = s.sut.PowerPerPhase(s.evEntity) assert.Nil(s.T(), err) - assert.Equal(s.T(), 2300.0, data[0]) + assert.Equal(s.T(), 3, len(data)) + assert.Equal(s.T(), 1170.7, data[0]) } func (s *CemEVCEMSuite) Test_EVChargedEnergy() { From 605b8c5365e8933739867c13d76c617518ca35fc Mon Sep 17 00:00:00 2001 From: Andreas Linde Date: Fri, 5 Jul 2024 15:07:04 +0200 Subject: [PATCH 5/8] Remove voltage configuration - No need to setup default voltage - EVCem `PowerPerPhase` returns an error if power is not available instead of using currents and static voltage value --- api/configuration.go | 12 -- api/configuration_test.go | 20 ++-- cmd/controlbox/main.go | 2 +- cmd/evse/main.go | 2 +- cmd/hems/main.go | 2 +- features/server/deviceconfiguration_test.go | 2 +- features/server/devicediagnosis_test.go | 2 +- features/server/electricalconnection_test.go | 2 +- features/server/feature_test.go | 2 +- features/server/loadcontrol_test.go | 2 +- features/server/measurement_test.go | 2 +- service/service_test.go | 6 +- usecases/cem/cevc/testhelper_test.go | 2 +- usecases/cem/evcc/testhelper_test.go | 2 +- usecases/cem/evcem/public.go | 15 +-- usecases/cem/evcem/public_test.go | 113 ++++++++++++++++++- usecases/cem/evcem/testhelper_test.go | 2 +- usecases/cem/evsecc/testhelper_test.go | 2 +- usecases/cem/evsoc/testhelper_test.go | 2 +- usecases/cem/opev/testhelper_test.go | 2 +- usecases/cem/oscev/testhelper_test.go | 2 +- usecases/cem/vabd/testhelper_test.go | 2 +- usecases/cem/vapd/testhelper_test.go | 2 +- usecases/cs/lpc/testhelper_test.go | 2 +- usecases/cs/lpp/testhelper_test.go | 2 +- usecases/eg/lpc/testhelper_test.go | 2 +- usecases/eg/lpp/testhelper_test.go | 2 +- usecases/internal/testhelper_test.go | 2 +- usecases/ma/mgcp/testhelper_test.go | 2 +- usecases/ma/mpc/testhelper_test.go | 2 +- usecases/usecase/testhelper_test.go | 2 +- 31 files changed, 148 insertions(+), 70 deletions(-) diff --git a/api/configuration.go b/api/configuration.go index 9d5f40c8..150e3a5d 100644 --- a/api/configuration.go +++ b/api/configuration.go @@ -64,11 +64,6 @@ type Configuration struct { // The certificate used for the service and its connections, required certificate tls.Certificate - // The sites grid voltage - // This is useful when e.g. power values are not available and therefor - // need to be calculated using the current values - voltage float64 - // The timeout to be used for sending heartbeats heartbeatTimeout time.Duration @@ -86,13 +81,11 @@ func NewConfiguration( entityTypes []model.EntityTypeType, port int, certificate tls.Certificate, - voltage float64, heartbeatTimeout time.Duration, ) (*Configuration, error) { configuration := &Configuration{ certificate: certificate, port: port, - voltage: voltage, heartbeatTimeout: heartbeatTimeout, mdnsProviderSelection: mdns.MdnsProviderSelectionGoZeroConfOnly, } @@ -242,11 +235,6 @@ func (s *Configuration) SetCertificate(cert tls.Certificate) { s.certificate = cert } -// return the sites predefined grid voltage -func (s *Configuration) Voltage() float64 { - return s.voltage -} - func (s *Configuration) HeartbeatTimeout() time.Duration { return s.heartbeatTimeout } diff --git a/api/configuration_test.go b/api/configuration_test.go index 6b2e388c..5e4bfbaa 100644 --- a/api/configuration_test.go +++ b/api/configuration_test.go @@ -27,54 +27,53 @@ func (s *ConfigurationSuite) Test_Configuration() { model := "model" serial := "serial" port := 4567 - volt := 230.0 heartbeatTimeout := time.Second * 4 entityTypes := []spinemodel.EntityTypeType{spinemodel.EntityTypeTypeCEM} config, err := NewConfiguration("", brand, model, serial, spinemodel.DeviceTypeTypeEnergyManagementSystem, - entityTypes, 0, certificate, volt, heartbeatTimeout) + entityTypes, 0, certificate, heartbeatTimeout) assert.Nil(s.T(), config) assert.NotNil(s.T(), err) config, err = NewConfiguration("", brand, model, serial, spinemodel.DeviceTypeTypeEnergyManagementSystem, - entityTypes, port, certificate, volt, heartbeatTimeout) + entityTypes, port, certificate, heartbeatTimeout) assert.Nil(s.T(), config) assert.NotNil(s.T(), err) config, err = NewConfiguration(vendor, "", model, serial, spinemodel.DeviceTypeTypeEnergyManagementSystem, - entityTypes, port, certificate, 230, heartbeatTimeout) + entityTypes, port, certificate, heartbeatTimeout) assert.Nil(s.T(), config) assert.NotNil(s.T(), err) config, err = NewConfiguration(vendor, brand, "", serial, spinemodel.DeviceTypeTypeEnergyManagementSystem, - entityTypes, port, certificate, 230, heartbeatTimeout) + entityTypes, port, certificate, heartbeatTimeout) assert.Nil(s.T(), config) assert.NotNil(s.T(), err) config, err = NewConfiguration(vendor, brand, model, "", spinemodel.DeviceTypeTypeEnergyManagementSystem, - entityTypes, port, certificate, 230, heartbeatTimeout) + entityTypes, port, certificate, heartbeatTimeout) assert.Nil(s.T(), config) assert.NotNil(s.T(), err) config, err = NewConfiguration(vendor, brand, model, serial, "", - entityTypes, port, certificate, 230, heartbeatTimeout) + entityTypes, port, certificate, heartbeatTimeout) assert.Nil(s.T(), config) assert.NotNil(s.T(), err) config, err = NewConfiguration(vendor, brand, model, serial, spinemodel.DeviceTypeTypeEnergyManagementSystem, - []spinemodel.EntityTypeType{}, port, certificate, 230, heartbeatTimeout) + []spinemodel.EntityTypeType{}, port, certificate, heartbeatTimeout) assert.Nil(s.T(), config) assert.NotNil(s.T(), err) config, err = NewConfiguration(vendor, brand, model, serial, spinemodel.DeviceTypeTypeEnergyManagementSystem, - entityTypes, port, certificate, 230, heartbeatTimeout) + entityTypes, port, certificate, heartbeatTimeout) assert.NotNil(s.T(), config) assert.Nil(s.T(), err) @@ -110,9 +109,6 @@ func (s *ConfigurationSuite) Test_Configuration() { id = config.MdnsServiceName() assert.Equal(s.T(), alternate, id) - voltage := config.Voltage() - assert.Equal(s.T(), volt, voltage) - portValue := config.Port() assert.Equal(s.T(), port, portValue) diff --git a/cmd/controlbox/main.go b/cmd/controlbox/main.go index 77647385..3452e5a2 100644 --- a/cmd/controlbox/main.go +++ b/cmd/controlbox/main.go @@ -78,7 +78,7 @@ func (h *controlbox) run() { "Demo", "Demo", "ControlBox", "123456789", model.DeviceTypeTypeElectricitySupplySystem, []model.EntityTypeType{model.EntityTypeTypeGridGuard}, - port, certificate, 230, time.Second*60) + port, certificate, time.Second*60) if err != nil { log.Fatal(err) } diff --git a/cmd/evse/main.go b/cmd/evse/main.go index b43e0bf2..11a2a8a5 100644 --- a/cmd/evse/main.go +++ b/cmd/evse/main.go @@ -74,7 +74,7 @@ func (h *evse) run() { "Demo", "Demo", "EVSE", "234567890", model.DeviceTypeTypeChargingStation, []model.EntityTypeType{model.EntityTypeTypeEVSE}, - port, certificate, 230, time.Second*4) + port, certificate, time.Second*4) if err != nil { log.Fatal(err) } diff --git a/cmd/hems/main.go b/cmd/hems/main.go index 1afc046f..9d825a85 100644 --- a/cmd/hems/main.go +++ b/cmd/hems/main.go @@ -80,7 +80,7 @@ func (h *hems) run() { "Demo", "Demo", "HEMS", "123456789", model.DeviceTypeTypeEnergyManagementSystem, []model.EntityTypeType{model.EntityTypeTypeCEM}, - port, certificate, 230, time.Second*4) + port, certificate, time.Second*4) if err != nil { log.Fatal(err) } diff --git a/features/server/deviceconfiguration_test.go b/features/server/deviceconfiguration_test.go index 77d96133..576bbe43 100644 --- a/features/server/deviceconfiguration_test.go +++ b/features/server/deviceconfiguration_test.go @@ -42,7 +42,7 @@ func (s *DeviceConfigurationSuite) BeforeTest(suiteName, testName string) { "test", "test", "test", "test", model.DeviceTypeTypeEnergyManagementSystem, []model.EntityTypeType{model.EntityTypeTypeCEM}, - 9999, cert, 230.0, time.Second*4) + 9999, cert, time.Second*4) serviceHandler := mocks.NewServiceReaderInterface(s.T()) serviceHandler.EXPECT().ServicePairingDetailUpdate(mock.Anything, mock.Anything).Return().Maybe() diff --git a/features/server/devicediagnosis_test.go b/features/server/devicediagnosis_test.go index aac1de9d..26ac0afe 100644 --- a/features/server/devicediagnosis_test.go +++ b/features/server/devicediagnosis_test.go @@ -42,7 +42,7 @@ func (s *DeviceDiagnosisSuite) BeforeTest(suiteName, testName string) { "test", "test", "test", "test", model.DeviceTypeTypeEnergyManagementSystem, []model.EntityTypeType{model.EntityTypeTypeCEM}, - 9999, cert, 230.0, time.Second*4) + 9999, cert, time.Second*4) serviceHandler := mocks.NewServiceReaderInterface(s.T()) serviceHandler.EXPECT().ServicePairingDetailUpdate(mock.Anything, mock.Anything).Return().Maybe() diff --git a/features/server/electricalconnection_test.go b/features/server/electricalconnection_test.go index 5488c479..7400fe5b 100644 --- a/features/server/electricalconnection_test.go +++ b/features/server/electricalconnection_test.go @@ -42,7 +42,7 @@ func (s *ElectricalConnectionSuite) BeforeTest(suiteName, testName string) { "test", "test", "test", "test", model.DeviceTypeTypeEnergyManagementSystem, []model.EntityTypeType{model.EntityTypeTypeCEM}, - 9999, cert, 230.0, time.Second*4) + 9999, cert, time.Second*4) serviceHandler := mocks.NewServiceReaderInterface(s.T()) serviceHandler.EXPECT().ServicePairingDetailUpdate(mock.Anything, mock.Anything).Return().Maybe() diff --git a/features/server/feature_test.go b/features/server/feature_test.go index 22b4a0d1..f6643f73 100644 --- a/features/server/feature_test.go +++ b/features/server/feature_test.go @@ -47,7 +47,7 @@ func (s *FeatureSuite) BeforeTest(suiteName, testName string) { "test", "test", "test", "test", model.DeviceTypeTypeEnergyManagementSystem, []model.EntityTypeType{model.EntityTypeTypeCEM}, - 9999, cert, 230.0, time.Second*4) + 9999, cert, time.Second*4) serviceHandler := mocks.NewServiceReaderInterface(s.T()) serviceHandler.EXPECT().ServicePairingDetailUpdate(mock.Anything, mock.Anything).Return().Maybe() diff --git a/features/server/loadcontrol_test.go b/features/server/loadcontrol_test.go index aed2a4ea..2bd071f0 100644 --- a/features/server/loadcontrol_test.go +++ b/features/server/loadcontrol_test.go @@ -42,7 +42,7 @@ func (s *LoadControlSuite) BeforeTest(suiteName, testName string) { "test", "test", "test", "test", model.DeviceTypeTypeEnergyManagementSystem, []model.EntityTypeType{model.EntityTypeTypeCEM}, - 9999, cert, 230.0, time.Second*4) + 9999, cert, time.Second*4) serviceHandler := mocks.NewServiceReaderInterface(s.T()) serviceHandler.EXPECT().ServicePairingDetailUpdate(mock.Anything, mock.Anything).Return().Maybe() diff --git a/features/server/measurement_test.go b/features/server/measurement_test.go index 00fee5f7..3b526b90 100644 --- a/features/server/measurement_test.go +++ b/features/server/measurement_test.go @@ -42,7 +42,7 @@ func (s *MeasurementSuite) BeforeTest(suiteName, testName string) { "test", "test", "test", "test", model.DeviceTypeTypeEnergyManagementSystem, []model.EntityTypeType{model.EntityTypeTypeCEM}, - 9999, cert, 230.0, time.Second*4) + 9999, cert, time.Second*4) serviceHandler := mocks.NewServiceReaderInterface(s.T()) serviceHandler.EXPECT().ServicePairingDetailUpdate(mock.Anything, mock.Anything).Return().Maybe() diff --git a/service/service_test.go b/service/service_test.go index 848c6d6c..62a70bfa 100644 --- a/service/service_test.go +++ b/service/service_test.go @@ -50,7 +50,7 @@ func (s *ServiceSuite) BeforeTest(suiteName, testName string) { var err error s.config, err = api.NewConfiguration( "vendor", "brand", "model", "serial", model.DeviceTypeTypeEnergyManagementSystem, - []model.EntityTypeType{model.EntityTypeTypeCEM}, 4729, certificate, 230.0, time.Second*4) + []model.EntityTypeType{model.EntityTypeTypeCEM}, 4729, certificate, time.Second*4) assert.Nil(s.T(), nil, err) s.sut = NewService(s.config, s.serviceReader) @@ -179,7 +179,7 @@ func (s *ServiceSuite) Test_Setup_IANA() { certificate := tls.Certificate{} s.config, err = api.NewConfiguration( "12345", "brand", "model", "serial", model.DeviceTypeTypeEnergyManagementSystem, - []model.EntityTypeType{model.EntityTypeTypeCEM}, 4729, certificate, 230.0, time.Second*4) + []model.EntityTypeType{model.EntityTypeTypeCEM}, 4729, certificate, time.Second*4) assert.Nil(s.T(), nil, err) s.sut = NewService(s.config, s.serviceReader) @@ -219,7 +219,7 @@ func (s *ServiceSuite) Test_Setup_Error_DeviceName() { "modelmodelmodelmodelmodelmodelmodelmodelmodelmodelmodelmodelmodelmodelmodelmodelmodelmodelmodelmodel", "serialserialserialserialserialserialserialserialserialserialserialserialserialserialserialserialserial", model.DeviceTypeTypeEnergyManagementSystem, - []model.EntityTypeType{model.EntityTypeTypeCEM}, 4729, certificate, 230.0, time.Second*4) + []model.EntityTypeType{model.EntityTypeTypeCEM}, 4729, certificate, time.Second*4) assert.Nil(s.T(), nil, err) s.sut = NewService(s.config, s.serviceReader) diff --git a/usecases/cem/cevc/testhelper_test.go b/usecases/cem/cevc/testhelper_test.go index 63bc0855..1d665f30 100644 --- a/usecases/cem/cevc/testhelper_test.go +++ b/usecases/cem/cevc/testhelper_test.go @@ -48,7 +48,7 @@ func (s *CemCEVCSuite) BeforeTest(suiteName, testName string) { "test", "test", "test", "test", model.DeviceTypeTypeEnergyManagementSystem, []model.EntityTypeType{model.EntityTypeTypeCEM}, - 9999, cert, 230.0, time.Second*4) + 9999, cert, time.Second*4) serviceHandler := mocks.NewServiceReaderInterface(s.T()) serviceHandler.EXPECT().ServicePairingDetailUpdate(mock.Anything, mock.Anything).Return().Maybe() diff --git a/usecases/cem/evcc/testhelper_test.go b/usecases/cem/evcc/testhelper_test.go index 738dd956..b2ee9b21 100644 --- a/usecases/cem/evcc/testhelper_test.go +++ b/usecases/cem/evcc/testhelper_test.go @@ -48,7 +48,7 @@ func (s *CemEVCCSuite) BeforeTest(suiteName, testName string) { "test", "test", "test", "test", model.DeviceTypeTypeEnergyManagementSystem, []model.EntityTypeType{model.EntityTypeTypeCEM}, - 9999, cert, 230.0, time.Second*4) + 9999, cert, time.Second*4) serviceHandler := mocks.NewServiceReaderInterface(s.T()) serviceHandler.EXPECT().ServicePairingDetailUpdate(mock.Anything, mock.Anything).Return().Maybe() diff --git a/usecases/cem/evcem/public.go b/usecases/cem/evcem/public.go index 1371cfac..b7c3f441 100644 --- a/usecases/cem/evcem/public.go +++ b/usecases/cem/evcem/public.go @@ -131,7 +131,6 @@ func (e *EVCEM) PowerPerPhase(entity spineapi.EntityRemoteInterface) ([]float64, var data []model.MeasurementDataType - powerAvailable := true filter := model.MeasurementDescriptionDataType{ MeasurementType: util.Ptr(model.MeasurementTypeTypePower), CommodityType: util.Ptr(model.CommodityTypeTypeElectricity), @@ -140,15 +139,7 @@ func (e *EVCEM) PowerPerPhase(entity spineapi.EntityRemoteInterface) ([]float64, data, err = evMeasurement.GetDataForFilter(filter) // Elli Charger Connect/Pro (Gen1) returns power descriptions, but only measurements without actual values, see test caseTest_EVPowerPerPhase_Current if err != nil || len(data) == 0 || data[0].Value == nil { - powerAvailable = false - - // If power is not provided, fall back to power calculations via currents - filter.MeasurementType = util.Ptr(model.MeasurementTypeTypeCurrent) - filter.ScopeType = util.Ptr(model.ScopeTypeTypeACCurrent) - data, err = evMeasurement.GetDataForFilter(filter) - if err != nil || len(data) == 0 { - return nil, api.ErrDataNotAvailable - } + return nil, api.ErrDataNotAvailable } var result []float64 @@ -169,10 +160,6 @@ func (e *EVCEM) PowerPerPhase(entity spineapi.EntityRemoteInterface) ([]float64, } phaseValue := item.Value.GetValue() - if !powerAvailable { - phaseValue *= e.service.Configuration().Voltage() - } - result = append(result, phaseValue) } } diff --git a/usecases/cem/evcem/public_test.go b/usecases/cem/evcem/public_test.go index 8f32c44c..72c11adf 100644 --- a/usecases/cem/evcem/public_test.go +++ b/usecases/cem/evcem/public_test.go @@ -408,9 +408,8 @@ func (s *CemEVCEMSuite) Test_EVPowerPerPhase_Current() { assert.Nil(s.T(), fErr) data, err = s.sut.PowerPerPhase(s.evEntity) - assert.Nil(s.T(), err) - assert.Equal(s.T(), 3, len(data)) - assert.Equal(s.T(), 1170.7, data[0]) + assert.NotNil(s.T(), err) + assert.Equal(s.T(), 0, len(data)) } func (s *CemEVCEMSuite) Test_EVChargedEnergy() { @@ -457,3 +456,111 @@ func (s *CemEVCEMSuite) Test_EVChargedEnergy() { assert.Nil(s.T(), err) assert.Equal(s.T(), 80.0, data) } + +func (s *CemEVCEMSuite) Test_EVChargedEnergy_ElliGen1() { + data, err := s.sut.EnergyCharged(s.mockRemoteEntity) + assert.NotNil(s.T(), err) + assert.Equal(s.T(), 0.0, data) + + data, err = s.sut.EnergyCharged(s.evEntity) + assert.NotNil(s.T(), err) + assert.Equal(s.T(), 0.0, data) + + measDesc := &model.MeasurementDescriptionListDataType{ + MeasurementDescriptionData: []model.MeasurementDescriptionDataType{ + { + MeasurementId: util.Ptr(model.MeasurementIdType(0)), + MeasurementType: util.Ptr(model.MeasurementTypeTypeCurrent), + CommodityType: util.Ptr(model.CommodityTypeTypeElectricity), + ScopeType: util.Ptr(model.ScopeTypeTypeACCurrent), + Unit: util.Ptr(model.UnitOfMeasurementTypeA), + }, + { + MeasurementId: util.Ptr(model.MeasurementIdType(1)), + MeasurementType: util.Ptr(model.MeasurementTypeTypeCurrent), + CommodityType: util.Ptr(model.CommodityTypeTypeElectricity), + ScopeType: util.Ptr(model.ScopeTypeTypeACCurrent), + Unit: util.Ptr(model.UnitOfMeasurementTypeA), + }, + { + MeasurementId: util.Ptr(model.MeasurementIdType(2)), + MeasurementType: util.Ptr(model.MeasurementTypeTypeCurrent), + CommodityType: util.Ptr(model.CommodityTypeTypeElectricity), + ScopeType: util.Ptr(model.ScopeTypeTypeACCurrent), + Unit: util.Ptr(model.UnitOfMeasurementTypeA), + }, + { + MeasurementId: util.Ptr(model.MeasurementIdType(3)), + MeasurementType: util.Ptr(model.MeasurementTypeTypePower), + CommodityType: util.Ptr(model.CommodityTypeTypeElectricity), + ScopeType: util.Ptr(model.ScopeTypeTypeACPower), + Unit: util.Ptr(model.UnitOfMeasurementTypeW), + }, + { + MeasurementId: util.Ptr(model.MeasurementIdType(4)), + MeasurementType: util.Ptr(model.MeasurementTypeTypePower), + CommodityType: util.Ptr(model.CommodityTypeTypeElectricity), + ScopeType: util.Ptr(model.ScopeTypeTypeACPower), + Unit: util.Ptr(model.UnitOfMeasurementTypeW), + }, + { + MeasurementId: util.Ptr(model.MeasurementIdType(5)), + MeasurementType: util.Ptr(model.MeasurementTypeTypePower), + CommodityType: util.Ptr(model.CommodityTypeTypeElectricity), + ScopeType: util.Ptr(model.ScopeTypeTypeACPower), + Unit: util.Ptr(model.UnitOfMeasurementTypeW), + }, + { + MeasurementId: util.Ptr(model.MeasurementIdType(6)), + MeasurementType: util.Ptr(model.MeasurementTypeTypeEnergy), + CommodityType: util.Ptr(model.CommodityTypeTypeElectricity), + ScopeType: util.Ptr(model.ScopeTypeTypeCharge), + Unit: util.Ptr(model.UnitOfMeasurementTypeWh), + }, + }, + } + + rFeature := s.remoteDevice.FeatureByEntityTypeAndRole(s.evEntity, model.FeatureTypeTypeMeasurement, model.RoleTypeServer) + fErr := rFeature.UpdateData(model.FunctionTypeMeasurementDescriptionListData, measDesc, nil, nil) + assert.Nil(s.T(), fErr) + + data, err = s.sut.EnergyCharged(s.evEntity) + assert.NotNil(s.T(), err) + assert.Equal(s.T(), 0.0, data) + + measData := &model.MeasurementListDataType{ + MeasurementData: []model.MeasurementDataType{ + { + MeasurementId: util.Ptr(model.MeasurementIdType(0)), + Value: model.NewScaledNumberType(5.09), + }, + { + MeasurementId: util.Ptr(model.MeasurementIdType(1)), + Value: model.NewScaledNumberType(4.04), + }, + { + MeasurementId: util.Ptr(model.MeasurementIdType(2)), + Value: model.NewScaledNumberType(5.09), + }, + { + MeasurementId: util.Ptr(model.MeasurementIdType(3)), + }, + { + MeasurementId: util.Ptr(model.MeasurementIdType(4)), + }, + { + MeasurementId: util.Ptr(model.MeasurementIdType(5)), + }, + { + MeasurementId: util.Ptr(model.MeasurementIdType(6)), + }, + }, + } + + fErr = rFeature.UpdateData(model.FunctionTypeMeasurementListData, measData, nil, nil) + assert.Nil(s.T(), fErr) + + data, err = s.sut.EnergyCharged(s.evEntity) + assert.NotNil(s.T(), err) + assert.Equal(s.T(), 0.0, data) +} diff --git a/usecases/cem/evcem/testhelper_test.go b/usecases/cem/evcem/testhelper_test.go index bdd26daa..ad02cdbd 100644 --- a/usecases/cem/evcem/testhelper_test.go +++ b/usecases/cem/evcem/testhelper_test.go @@ -48,7 +48,7 @@ func (s *CemEVCEMSuite) BeforeTest(suiteName, testName string) { "test", "test", "test", "test", model.DeviceTypeTypeEnergyManagementSystem, []model.EntityTypeType{model.EntityTypeTypeCEM}, - 9999, cert, 230.0, time.Second*4) + 9999, cert, time.Second*4) serviceHandler := mocks.NewServiceReaderInterface(s.T()) serviceHandler.EXPECT().ServicePairingDetailUpdate(mock.Anything, mock.Anything).Return().Maybe() diff --git a/usecases/cem/evsecc/testhelper_test.go b/usecases/cem/evsecc/testhelper_test.go index e3a17306..70127455 100644 --- a/usecases/cem/evsecc/testhelper_test.go +++ b/usecases/cem/evsecc/testhelper_test.go @@ -48,7 +48,7 @@ func (s *CemEVSECCSuite) BeforeTest(suiteName, testName string) { "test", "test", "test", "test", model.DeviceTypeTypeEnergyManagementSystem, []model.EntityTypeType{model.EntityTypeTypeCEM}, - 9999, cert, 230.0, time.Second*4) + 9999, cert, time.Second*4) serviceHandler := mocks.NewServiceReaderInterface(s.T()) serviceHandler.EXPECT().ServicePairingDetailUpdate(mock.Anything, mock.Anything).Return().Maybe() diff --git a/usecases/cem/evsoc/testhelper_test.go b/usecases/cem/evsoc/testhelper_test.go index d94b7d8d..f0595c63 100644 --- a/usecases/cem/evsoc/testhelper_test.go +++ b/usecases/cem/evsoc/testhelper_test.go @@ -48,7 +48,7 @@ func (s *CemEVSOCSuite) BeforeTest(suiteName, testName string) { "test", "test", "test", "test", model.DeviceTypeTypeEnergyManagementSystem, []model.EntityTypeType{model.EntityTypeTypeCEM}, - 9999, cert, 230.0, time.Second*4) + 9999, cert, time.Second*4) serviceHandler := mocks.NewServiceReaderInterface(s.T()) serviceHandler.EXPECT().ServicePairingDetailUpdate(mock.Anything, mock.Anything).Return().Maybe() diff --git a/usecases/cem/opev/testhelper_test.go b/usecases/cem/opev/testhelper_test.go index 80ab3c4c..459787da 100644 --- a/usecases/cem/opev/testhelper_test.go +++ b/usecases/cem/opev/testhelper_test.go @@ -48,7 +48,7 @@ func (s *CemOPEVSuite) BeforeTest(suiteName, testName string) { "test", "test", "test", "test", model.DeviceTypeTypeEnergyManagementSystem, []model.EntityTypeType{model.EntityTypeTypeCEM}, - 9999, cert, 230.0, time.Second*4) + 9999, cert, time.Second*4) serviceHandler := mocks.NewServiceReaderInterface(s.T()) serviceHandler.EXPECT().ServicePairingDetailUpdate(mock.Anything, mock.Anything).Return().Maybe() diff --git a/usecases/cem/oscev/testhelper_test.go b/usecases/cem/oscev/testhelper_test.go index 13978e7c..96ca7648 100644 --- a/usecases/cem/oscev/testhelper_test.go +++ b/usecases/cem/oscev/testhelper_test.go @@ -47,7 +47,7 @@ func (s *CemOSCEVSuite) BeforeTest(suiteName, testName string) { "test", "test", "test", "test", model.DeviceTypeTypeEnergyManagementSystem, []model.EntityTypeType{model.EntityTypeTypeCEM}, - 9999, cert, 230.0, time.Second*4) + 9999, cert, time.Second*4) serviceHandler := mocks.NewServiceReaderInterface(s.T()) serviceHandler.EXPECT().ServicePairingDetailUpdate(mock.Anything, mock.Anything).Return().Maybe() diff --git a/usecases/cem/vabd/testhelper_test.go b/usecases/cem/vabd/testhelper_test.go index 856282ba..5fd1f410 100644 --- a/usecases/cem/vabd/testhelper_test.go +++ b/usecases/cem/vabd/testhelper_test.go @@ -48,7 +48,7 @@ func (s *CemVABDSuite) BeforeTest(suiteName, testName string) { "test", "test", "test", "test", model.DeviceTypeTypeEnergyManagementSystem, []model.EntityTypeType{model.EntityTypeTypeCEM}, - 9999, cert, 230.0, time.Second*4) + 9999, cert, time.Second*4) serviceHandler := mocks.NewServiceReaderInterface(s.T()) serviceHandler.EXPECT().ServicePairingDetailUpdate(mock.Anything, mock.Anything).Return().Maybe() diff --git a/usecases/cem/vapd/testhelper_test.go b/usecases/cem/vapd/testhelper_test.go index cc71d100..03cfb358 100644 --- a/usecases/cem/vapd/testhelper_test.go +++ b/usecases/cem/vapd/testhelper_test.go @@ -48,7 +48,7 @@ func (s *CemVAPDSuite) BeforeTest(suiteName, testName string) { "test", "test", "test", "test", model.DeviceTypeTypeEnergyManagementSystem, []model.EntityTypeType{model.EntityTypeTypeCEM}, - 9999, cert, 230.0, time.Second*4) + 9999, cert, time.Second*4) serviceHandler := mocks.NewServiceReaderInterface(s.T()) serviceHandler.EXPECT().ServicePairingDetailUpdate(mock.Anything, mock.Anything).Return().Maybe() diff --git a/usecases/cs/lpc/testhelper_test.go b/usecases/cs/lpc/testhelper_test.go index 1e816430..09ca06f7 100644 --- a/usecases/cs/lpc/testhelper_test.go +++ b/usecases/cs/lpc/testhelper_test.go @@ -51,7 +51,7 @@ func (s *CsLPCSuite) BeforeTest(suiteName, testName string) { "test", "test", "test", "test", model.DeviceTypeTypeEnergyManagementSystem, []model.EntityTypeType{model.EntityTypeTypeCEM}, - 9999, cert, 230.0, time.Second*4) + 9999, cert, time.Second*4) serviceHandler := mocks.NewServiceReaderInterface(s.T()) serviceHandler.EXPECT().ServicePairingDetailUpdate(mock.Anything, mock.Anything).Return().Maybe() diff --git a/usecases/cs/lpp/testhelper_test.go b/usecases/cs/lpp/testhelper_test.go index cd3ac0d0..f2a46b9f 100644 --- a/usecases/cs/lpp/testhelper_test.go +++ b/usecases/cs/lpp/testhelper_test.go @@ -51,7 +51,7 @@ func (s *CsLPPSuite) BeforeTest(suiteName, testName string) { "test", "test", "test", "test", model.DeviceTypeTypeEnergyManagementSystem, []model.EntityTypeType{model.EntityTypeTypeCEM}, - 9999, cert, 230.0, time.Second*4) + 9999, cert, time.Second*4) serviceHandler := mocks.NewServiceReaderInterface(s.T()) serviceHandler.EXPECT().ServicePairingDetailUpdate(mock.Anything, mock.Anything).Return().Maybe() diff --git a/usecases/eg/lpc/testhelper_test.go b/usecases/eg/lpc/testhelper_test.go index 45020781..a6fa5f68 100644 --- a/usecases/eg/lpc/testhelper_test.go +++ b/usecases/eg/lpc/testhelper_test.go @@ -48,7 +48,7 @@ func (s *EgLPCSuite) BeforeTest(suiteName, testName string) { "test", "test", "test", "test", model.DeviceTypeTypeEnergyManagementSystem, []model.EntityTypeType{model.EntityTypeTypeCEM}, - 9999, cert, 230.0, time.Second*4) + 9999, cert, time.Second*4) serviceHandler := mocks.NewServiceReaderInterface(s.T()) serviceHandler.EXPECT().ServicePairingDetailUpdate(mock.Anything, mock.Anything).Return().Maybe() diff --git a/usecases/eg/lpp/testhelper_test.go b/usecases/eg/lpp/testhelper_test.go index ea7cb8b8..e11f62b7 100644 --- a/usecases/eg/lpp/testhelper_test.go +++ b/usecases/eg/lpp/testhelper_test.go @@ -48,7 +48,7 @@ func (s *EgLPPSuite) BeforeTest(suiteName, testName string) { "test", "test", "test", "test", model.DeviceTypeTypeEnergyManagementSystem, []model.EntityTypeType{model.EntityTypeTypeCEM}, - 9999, cert, 230.0, time.Second*4) + 9999, cert, time.Second*4) serviceHandler := mocks.NewServiceReaderInterface(s.T()) serviceHandler.EXPECT().ServicePairingDetailUpdate(mock.Anything, mock.Anything).Return().Maybe() diff --git a/usecases/internal/testhelper_test.go b/usecases/internal/testhelper_test.go index 4bdb7dd3..a74ce91e 100644 --- a/usecases/internal/testhelper_test.go +++ b/usecases/internal/testhelper_test.go @@ -48,7 +48,7 @@ func (s *InternalSuite) BeforeTest(suiteName, testName string) { "test", "test", "test", "test", model.DeviceTypeTypeEnergyManagementSystem, []model.EntityTypeType{model.EntityTypeTypeCEM}, - 9999, cert, 230.0, time.Second*4) + 9999, cert, time.Second*4) serviceHandler := mocks.NewServiceReaderInterface(s.T()) serviceHandler.EXPECT().ServicePairingDetailUpdate(mock.Anything, mock.Anything).Return().Maybe() diff --git a/usecases/ma/mgcp/testhelper_test.go b/usecases/ma/mgcp/testhelper_test.go index a409e481..01778c5c 100644 --- a/usecases/ma/mgcp/testhelper_test.go +++ b/usecases/ma/mgcp/testhelper_test.go @@ -48,7 +48,7 @@ func (s *GcpMGCPSuite) BeforeTest(suiteName, testName string) { "test", "test", "test", "test", model.DeviceTypeTypeEnergyManagementSystem, []model.EntityTypeType{model.EntityTypeTypeCEM}, - 9999, cert, 230.0, time.Second*4) + 9999, cert, time.Second*4) serviceHandler := mocks.NewServiceReaderInterface(s.T()) serviceHandler.EXPECT().ServicePairingDetailUpdate(mock.Anything, mock.Anything).Return().Maybe() diff --git a/usecases/ma/mpc/testhelper_test.go b/usecases/ma/mpc/testhelper_test.go index bb4a8844..adc5fb7c 100644 --- a/usecases/ma/mpc/testhelper_test.go +++ b/usecases/ma/mpc/testhelper_test.go @@ -48,7 +48,7 @@ func (s *MaMPCSuite) BeforeTest(suiteName, testName string) { "test", "test", "test", "test", model.DeviceTypeTypeEnergyManagementSystem, []model.EntityTypeType{model.EntityTypeTypeCEM}, - 9999, cert, 230.0, time.Second*4) + 9999, cert, time.Second*4) serviceHandler := mocks.NewServiceReaderInterface(s.T()) serviceHandler.EXPECT().ServicePairingDetailUpdate(mock.Anything, mock.Anything).Return().Maybe() diff --git a/usecases/usecase/testhelper_test.go b/usecases/usecase/testhelper_test.go index 488c53a6..4e8fe2d0 100644 --- a/usecases/usecase/testhelper_test.go +++ b/usecases/usecase/testhelper_test.go @@ -57,7 +57,7 @@ func (s *UseCaseSuite) BeforeTest(suiteName, testName string) { "test", "test", "test", "test", model.DeviceTypeTypeEnergyManagementSystem, []model.EntityTypeType{model.EntityTypeTypeCEM}, - 9999, cert, 230.0, time.Second*4) + 9999, cert, time.Second*4) serviceHandler := mocks.NewServiceReaderInterface(s.T()) serviceHandler.EXPECT().ServicePairingDetailUpdate(mock.Anything, mock.Anything).Return().Maybe() From 87777c283201d458b730809379a23f67c5a94348 Mon Sep 17 00:00:00 2001 From: Andreas Linde Date: Thu, 11 Jul 2024 22:14:36 +0200 Subject: [PATCH 6/8] Remove refetch logic --- usecases/cem/evcem/public.go | 29 +---------------------------- 1 file changed, 1 insertion(+), 28 deletions(-) diff --git a/usecases/cem/evcem/public.go b/usecases/cem/evcem/public.go index b7c3f441..ff1a9051 100644 --- a/usecases/cem/evcem/public.go +++ b/usecases/cem/evcem/public.go @@ -1,8 +1,6 @@ package evcem import ( - "time" - "github.com/enbility/eebus-go/api" "github.com/enbility/eebus-go/features/client" ucapi "github.com/enbility/eebus-go/usecases/api" @@ -64,8 +62,6 @@ func (e *EVCEM) CurrentPerPhase(entity spineapi.EntityRemoteInterface) ([]float6 } var result []float64 - refetch := true - compare := time.Now().UTC().Add(-1 * time.Minute) for _, phase := range ucapi.PhaseNameMapping { for _, item := range data { @@ -84,32 +80,9 @@ func (e *EVCEM) CurrentPerPhase(entity spineapi.EntityRemoteInterface) ([]float6 phaseValue := item.Value.GetValue() result = append(result, phaseValue) - - if item.Timestamp == nil { - continue - } - - if timestamp, err := item.Timestamp.GetTime(); err == nil { - refetch = timestamp.Before(compare) - } - - // the MEB cars report the wrong NTP time by 1 or 2 hours (depending on DST) - // and PMCC uses NTP from the EV, so check these cases as well - for i := 0; i < 2 && refetch; i++ { - compare = compare.Add(-1 * time.Hour) - if timestamp, err := item.Timestamp.GetTime(); err == nil { - refetch = timestamp.Before(compare) - } - } } } - // if there was no timestamp provided or the time for the last value - // is older than 1 minute, send a read request - if refetch { - _, _ = evMeasurement.RequestData(nil, nil) - } - return result, nil } @@ -137,7 +110,7 @@ func (e *EVCEM) PowerPerPhase(entity spineapi.EntityRemoteInterface) ([]float64, ScopeType: util.Ptr(model.ScopeTypeTypeACPower), } data, err = evMeasurement.GetDataForFilter(filter) - // Elli Charger Connect/Pro (Gen1) returns power descriptions, but only measurements without actual values, see test caseTest_EVPowerPerPhase_Current + // Elli Charger Connect/Pro (Gen1) returns power descriptions, but only measurements without actual values, see test case Test_EVPowerPerPhase_Current if err != nil || len(data) == 0 || data[0].Value == nil { return nil, api.ErrDataNotAvailable } From 444e23e6959c39a7172a6cbbfb77af6c0f6eb3ea Mon Sep 17 00:00:00 2001 From: Andreas Linde Date: Tue, 16 Jul 2024 17:55:33 +0200 Subject: [PATCH 7/8] Update SHIP v0.5.2 and SPINE v0.6.1 --- go.mod | 4 ++-- go.sum | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/go.mod b/go.mod index 53936cf7..c42d1275 100644 --- a/go.mod +++ b/go.mod @@ -3,8 +3,8 @@ module github.com/enbility/eebus-go go 1.21.1 require ( - github.com/enbility/ship-go v0.5.1 - github.com/enbility/spine-go v0.6.0 + github.com/enbility/ship-go v0.5.2 + github.com/enbility/spine-go v0.6.1 github.com/stretchr/testify v1.9.0 ) diff --git a/go.sum b/go.sum index 9656024a..f44f23bc 100644 --- a/go.sum +++ b/go.sum @@ -2,10 +2,10 @@ github.com/ahmetb/go-linq/v3 v3.2.0 h1:BEuMfp+b59io8g5wYzNoFe9pWPalRklhlhbiU3hYZ github.com/ahmetb/go-linq/v3 v3.2.0/go.mod h1:haQ3JfOeWK8HpVxMtHHEMPVgBKiYyQ+f1/kLZh/cj9U= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/enbility/ship-go v0.5.1 h1:8Vax1MpyI/C+kQlMFAzQ7/h/xJ7fuumSLJy9FYgEkcE= -github.com/enbility/ship-go v0.5.1/go.mod h1:jewJWYQ10jNhsnhS1C4jESx3CNmDa5HNWZjBhkTug5Y= -github.com/enbility/spine-go v0.6.0 h1:sd5x9ZckvhI9b07HrdxKEZAcpF1Jt+xMC46o3VpuwoY= -github.com/enbility/spine-go v0.6.0/go.mod h1:1SJ6+ihCkjzVALXXbB3xdjDGp2ITqq9gnJQiPsF3fb0= +github.com/enbility/ship-go v0.5.2 h1:T9+YuP5ZpofKd463PLKq78fAaPAcGMnRAcv8c8aD5yU= +github.com/enbility/ship-go v0.5.2/go.mod h1:jewJWYQ10jNhsnhS1C4jESx3CNmDa5HNWZjBhkTug5Y= +github.com/enbility/spine-go v0.6.1 h1:6NAPE7PmCQsmfiZy/dLpnFZXEw8RK9H4USGniIw9r+Q= +github.com/enbility/spine-go v0.6.1/go.mod h1:pRGS+C5rZ5rhxTAA1whU8fC9p7lH5ixyut++yEZe470= github.com/enbility/zeroconf/v2 v2.0.0-20240210101930-d0004078577b h1:sg3c6LJ4eWffwtt9SW0lgcIX4Oh274vwdJnNFNNrDco= github.com/enbility/zeroconf/v2 v2.0.0-20240210101930-d0004078577b/go.mod h1:BjzRRiYX6mWdOgku1xxDE+NsV8PijTby7Q7BkYVdfDU= github.com/godbus/dbus/v5 v5.1.0 h1:4KLkAxT3aOY8Li4FRJe/KvhoNFFxo0m6fNuFUO8QJUk= From 8db2c887e9dbf3ac48e9ac326457f7236220dd43 Mon Sep 17 00:00:00 2001 From: Andreas Linde Date: Tue, 16 Jul 2024 17:56:21 +0200 Subject: [PATCH 8/8] Update README badges --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 871a5eba..0e66927f 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,8 @@ # eebus-go -[![Build Status](https://github.com/enbility/eebus-go/actions/workflows/default.yml/badge.svg?branch=dev)](https://github.com/enbility/eebus-go/actions/workflows/default.yml/badge.svg?branch=dev) +[![Build Status](https://github.com/enbility/eebus-go/actions/workflows/default.yml/badge.svg?branch=main)](https://github.com/enbility/eebus-go/actions/workflows/default.yml/badge.svg?branch=main) [![GoDoc](https://img.shields.io/badge/godoc-reference-5272B4)](https://godoc.org/github.com/enbility/eebus-go) -[![Coverage Status](https://coveralls.io/repos/github/enbility/eebus-go/badge.svg?branch=dev)](https://coveralls.io/github/enbility/eebus-go?branch=dev) +[![Coverage Status](https://coveralls.io/repos/github/enbility/eebus-go/badge.svg?branch=main)](https://coveralls.io/github/enbility/eebus-go?branch=main) [![Go report](https://goreportcard.com/badge/github.com/enbility/eebus-go)](https://goreportcard.com/report/github.com/enbility/eebus-go) [![CodeFactor](https://www.codefactor.io/repository/github/enbility/eebus-go/badge)](https://www.codefactor.io/repository/github/enbility/eebus-go)