MCPcopy Create free account
hub / github.com/evcc-io/evcc / scalePhases

Method scalePhases

core/loadpoint.go:1313–1338  ·  view source on GitHub ↗

scalePhases adjusts the number of active phases and returns the appropriate charging current. Returns api.ErrNotAvailable if api.PhaseSwitcher is not available.

(phases int)

Source from the content-addressed store, hash-verified

1311// scalePhases adjusts the number of active phases and returns the appropriate charging current.
1312// Returns api.ErrNotAvailable if api.PhaseSwitcher is not available.
1313func (lp *Loadpoint) scalePhases(phases int) error {
1314 cp, ok := api.Cap[api.PhaseSwitcher](lp.charger)
1315 if !ok {
1316 panic("charger does not implement api.PhaseSwitcher")
1317 }
1318
1319 if lp.GetPhases() != phases {
1320 // switch phases
1321 if err := cp.Phases1p3p(phases); err != nil {
1322 return fmt.Errorf("switch phases: %w", err)
1323 }
1324
1325 lp.log.DEBUG.Printf("switched phases: %dp", phases)
1326
1327 // prevent premature measurement of active phases
1328 lp.phasesSwitched = lp.clock.Now()
1329
1330 // update setting and reset timer
1331 lp.SetPhases(phases)
1332
1333 // some vehicles may hang on phase switch
1334 lp.startWakeUpTimer()
1335 }
1336
1337 return nil
1338}
1339
1340// fastCharging scales to 3p if available and sets maximum current
1341func (lp *Loadpoint) fastCharging() error {

Callers 4

pvScalePhasesMethod · 0.95
UpdateMethod · 0.95

Calls 6

GetPhasesMethod · 0.95
SetPhasesMethod · 0.95
startWakeUpTimerMethod · 0.95
PrintfMethod · 0.80
Phases1p3pMethod · 0.65
ErrorfMethod · 0.45

Tested by 1