Ocpp: support phase switching (#10183)

This commit is contained in:
Thomas Vandahl 2023-10-05 20:33:41 +02:00 • committed by GitHub
parent b43b759ecf
commit 94aeaa6edc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -92,12 +92,10 @@ func NewOCPPFromConfig(other map[string]interface{}) (api.Charger, error) {
currentsG = c.currents
}
// removed to avoid sending phases when updating currents
var phasesS func(int) error
// if c.phaseSwitching {
// phasesS = c.phases1p3p
// }
_ = c.phases1p3p
if c.phaseSwitching {
phasesS = c.phases1p3p
}
return decorateOCPP(c, powerG, totalEnergyG, currentsG, phasesS), nil
}
@ -398,9 +396,9 @@ func (c *OCPP) updatePeriod(current float64) error {
}
func (c *OCPP) getTxChargingProfile(current float64, transactionId int) *types.ChargingProfile {
phases := c.phases
period := types.NewChargingSchedulePeriod(0, current)
if c.chargingRateUnit == types.ChargingRateUnitWatts {
var phases int
// get (expectedly) active phases from loadpoint
if c.lp != nil {
phases = c.lp.GetPhases()
@ -411,6 +409,11 @@ func (c *OCPP) getTxChargingProfile(current float64, transactionId int) *types.C
period = types.NewChargingSchedulePeriod(0, math.Trunc(230.0*current*float64(phases)))
}
// OCPP assumes phases == 3 if not set
if phases != 0 {
period.NumberPhases = &phases
}
return &types.ChargingProfile{
ChargingProfileId: 1,
TransactionId: transactionId,