Add Huawei SCharger-7KS-S0 / 22KT-S0 (#19001)

This commit is contained in:
premultiply 2025-03-23 11:33:03 +01:00 • committed by GitHub
parent 9f87106b40
commit 6e8761ebba
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 26 additions and 15 deletions

View file

@ -71,6 +71,7 @@ func NewOCPPFromConfig(ctx context.Context, other map[string]interface{}) (api.C
AutoStart bool // TODO deprecated
NoStop bool // TODO deprecated
ForcePowerCtrl bool
StackLevelZero *bool
RemoteStart bool
}{
@ -88,7 +89,7 @@ func NewOCPPFromConfig(ctx context.Context, other map[string]interface{}) (api.C
c, err := NewOCPP(ctx,
cc.StationId, cc.Connector, cc.IdTag,
cc.MeterValues, cc.MeterInterval,
stackLevelZero, cc.RemoteStart,
cc.ForcePowerCtrl, stackLevelZero, cc.RemoteStart,
cc.ConnectTimeout)
if err != nil {
return c, err
@ -142,7 +143,7 @@ func NewOCPPFromConfig(ctx context.Context, other map[string]interface{}) (api.C
func NewOCPP(ctx context.Context,
id string, connector int, idTag string,
meterValues string, meterInterval time.Duration,
stackLevelZero, remoteStart bool,
forcePowerCtrl, stackLevelZero, remoteStart bool,
connectTimeout time.Duration,
) (*OCPP, error) {
log := util.NewLogger(fmt.Sprintf("%s-%d", lo.CoalesceOrEmpty(id, "ocpp"), connector))
@ -162,7 +163,7 @@ func NewOCPP(ctx context.Context,
case <-cp.HasConnected():
}
return cp.Setup(ctx, meterValues, meterInterval)
return cp.Setup(ctx, meterValues, meterInterval, forcePowerCtrl)
},
)
if err != nil {
@ -315,13 +316,6 @@ func (c *OCPP) createTxDefaultChargingProfile(current float64) *types.ChargingPr
period := types.NewChargingSchedulePeriod(0, current)
if c.cp.ChargingRateUnit == types.ChargingRateUnitWatts {
// get (expectedly) active phases from loadpoint
if c.lp != nil {
phases = c.lp.GetPhases()
}
if phases == 0 {
phases = 3
}
period = types.NewChargingSchedulePeriod(0, math.Trunc(230.0*current*float64(phases)))
} else {
// OCPP assumes phases == 3 if not set

View file

@ -13,7 +13,7 @@ import (
"github.com/samber/lo"
)
func (cp *CP) Setup(ctx context.Context, meterValues string, meterInterval time.Duration) error {
func (cp *CP) Setup(ctx context.Context, meterValues string, meterInterval time.Duration, forcePowerCtrl bool) error {
if err := cp.ChangeAvailabilityRequest(0, core.AvailabilityTypeOperative); err != nil {
cp.log.DEBUG.Printf("failed configuring availability: %v", err)
}
@ -159,6 +159,11 @@ func (cp *CP) Setup(ctx context.Context, meterValues string, meterInterval time.
cp.log.DEBUG.Printf("failed configuring %s: %v", KeyWebSocketPingInterval, err)
}
if forcePowerCtrl {
cp.ChargingRateUnit = types.ChargingRateUnitWatts
cp.PhaseSwitching = true // assume phase switching is available for power-based charging
}
return nil
}

View file

@ -113,7 +113,7 @@ func (suite *ocppTestSuite) TestConnect() {
suite.Require().True(cp1.IsConnected())
// 1st charge point- local
c1, err := NewOCPP(context.TODO(), "test-1", 1, "", "", 0, false, true, ocppTestConnectTimeout)
c1, err := NewOCPP(context.TODO(), "test-1", 1, "", "", 0, false, false, true, ocppTestConnectTimeout)
suite.Require().NoError(err)
// status and meter values
@ -162,7 +162,7 @@ func (suite *ocppTestSuite) TestConnect() {
suite.Require().True(cp2.IsConnected())
// 2nd charge point - local
c2, err := NewOCPP(context.TODO(), "test-2", 1, "", "", 0, false, true, ocppTestConnectTimeout)
c2, err := NewOCPP(context.TODO(), "test-2", 1, "", "", 0, false, false, true, ocppTestConnectTimeout)
suite.Require().NoError(err)
{
@ -204,7 +204,7 @@ func (suite *ocppTestSuite) TestAutoStart() {
suite.Require().True(cp1.IsConnected())
// 1st charge point- local
c1, err := NewOCPP(context.TODO(), "test-3", 1, "", "", 0, false, false, ocppTestConnectTimeout)
c1, err := NewOCPP(context.TODO(), "test-3", 1, "", "", 0, false, false, false, ocppTestConnectTimeout)
suite.Require().NoError(err)
// status and meter values
@ -251,7 +251,7 @@ func (suite *ocppTestSuite) TestTimeout() {
})
// 1st charge point- local
_, err := NewOCPP(context.TODO(), "test-4", 1, "", "", 0, false, false, ocppTestConnectTimeout)
_, err := NewOCPP(context.TODO(), "test-4", 1, "", "", 0, false, false, false, ocppTestConnectTimeout)
suite.Require().NoError(err)
}

View file

@ -0,0 +1,12 @@
template: ocpp-huawei
products:
- brand: Huawei
description:
generic: SCharger-7KS-S0 / 22KT-S0
requirements:
evcc: ["sponsorship", "skiptest"]
params:
- preset: ocpp
render: |
{{ include "ocpp" . }}
forcepowerctrl: true