Fix applying phase configuration at startup (#3762)

This commit is contained in:
andig 2022-07-03 12:26:19 +02:00 • committed by GitHub
parent 85ef96c574
commit 22c7db9263
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -214,11 +214,15 @@ func NewLoadPointFromConfig(log *util.Logger, cp configProvider, other map[strin
lp.charger = cp.Charger(lp.ChargerRef)
lp.configureChargerType(lp.charger)
// setup fixed phases
if _, ok := lp.charger.(api.ChargePhases); ok && lp.GetPhases() != 0 {
lp.log.WARN.Printf("locking phase config to %dp for switchable charger", lp.GetPhases())
// set to unknown since we don't know the charger's setting yet and don't want to interrupt charging
lp.setPhases(0)
// setup fixed phases:
// - simple charger starts with phases config if specified
// - switchable charger starts at 0p since we don't know the current setting
if _, ok := lp.charger.(api.ChargePhases); !ok {
if lp.DefaultPhases != 0 {
lp.phases = lp.DefaultPhases
}
} else if lp.DefaultPhases != 0 {
lp.log.WARN.Printf("locking phase config to %dp for switchable charger", lp.DefaultPhases)
}
// allow target charge handler to access loadpoint