scalePhases adjusts the number of active phases and returns the appropriate charging current. Returns api.ErrNotAvailable if api.PhaseSwitcher is not available.
(phases int)
| 1311 | // scalePhases adjusts the number of active phases and returns the appropriate charging current. |
| 1312 | // Returns api.ErrNotAvailable if api.PhaseSwitcher is not available. |
| 1313 | func (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 |
| 1341 | func (lp *Loadpoint) fastCharging() error { |