Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Mar 23, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 4 additions & 10 deletions charger/ocpp.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}{
Expand All @@ -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
Expand Down Expand Up @@ -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))
Expand All @@ -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 {
Expand Down Expand Up @@ -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
Expand Down
7 changes: 6 additions & 1 deletion charger/ocpp/cp_setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down Expand Up @@ -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
}

Expand Down
8 changes: 4 additions & 4 deletions charger/ocpp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)

{
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
}
12 changes: 12 additions & 0 deletions templates/definition/charger/ocpp-huawei.yaml
Original file line number Diff line number Diff line change
@@ -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
Loading