Loadpoint: fix limit soc not published for integrated devices (v2) (#19546)
This commit is contained in:
parent
4e2b946e34
commit
763464586d
2 changed files with 27 additions and 28 deletions
|
|
@ -1596,31 +1596,38 @@ func (lp *Loadpoint) publishChargeProgress() {
|
|||
}
|
||||
|
||||
// publish state of charge, remaining charge duration and range
|
||||
//
|
||||
// - online vehicle connected: this allows estimating remaining energy/duration
|
||||
// - either charger or vehicle provides soc
|
||||
// - estimator is responsible for querying both
|
||||
//
|
||||
// - offline or no vehicle connected (e.g. integrated device): missing capacity, hence no estimate
|
||||
// - charger may still provide soc
|
||||
// - no estimator
|
||||
func (lp *Loadpoint) publishSocAndRange() {
|
||||
soc, err := lp.chargerSoc()
|
||||
if err == nil {
|
||||
lp.vehicleSoc = soc
|
||||
lp.publish(keys.VehicleSoc, lp.vehicleSoc)
|
||||
|
||||
if limit, err := lp.chargerSocLimit(); err == nil {
|
||||
lp.log.DEBUG.Printf("charger soc limit: %d%%", limit)
|
||||
// https://github.com/evcc-io/evcc/issues/13349
|
||||
lp.publish(keys.VehicleLimitSoc, float64(limit))
|
||||
} else if !errors.Is(err, api.ErrNotAvailable) {
|
||||
lp.log.ERROR.Printf("charger soc limit: %v", err)
|
||||
}
|
||||
|
||||
return
|
||||
} else if !errors.Is(err, api.ErrNotAvailable) {
|
||||
lp.log.ERROR.Printf("charger soc: %v", err)
|
||||
}
|
||||
|
||||
// guard for socEstimator removed by api and keep a local copy in order to avoid race conditions
|
||||
// https://github.com/evcc-io/evcc/issues/16180
|
||||
socEstimator := lp.socEstimator
|
||||
|
||||
// soc not available
|
||||
// capacity not available
|
||||
if socEstimator == nil || !lp.vehicleHasSoc() {
|
||||
if soc, err := lp.chargerSoc(); err == nil {
|
||||
lp.vehicleSoc = soc
|
||||
lp.publish(keys.VehicleSoc, lp.vehicleSoc)
|
||||
|
||||
if vs, ok := lp.charger.(api.SocLimiter); ok {
|
||||
if limit, err := vs.GetLimitSoc(); err == nil {
|
||||
lp.log.DEBUG.Printf("charger soc limit: %d%%", limit)
|
||||
// https://github.com/evcc-io/evcc/issues/13349
|
||||
lp.publish(keys.VehicleLimitSoc, float64(limit))
|
||||
} else if !errors.Is(err, api.ErrNotAvailable) {
|
||||
lp.log.ERROR.Printf("charger soc limit: %v", err)
|
||||
}
|
||||
}
|
||||
} else if !errors.Is(err, api.ErrNotAvailable) {
|
||||
lp.log.ERROR.Printf("charger soc: %v", err)
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
|
|
@ -1654,7 +1661,7 @@ func (lp *Loadpoint) publishSocAndRange() {
|
|||
lp.log.DEBUG.Printf("vehicle soc limit: %d%%", limit)
|
||||
// https://github.com/evcc-io/evcc/issues/13349
|
||||
lp.publish(keys.VehicleLimitSoc, float64(limit))
|
||||
} else if !errors.Is(err, api.ErrNotAvailable) {
|
||||
} else if !loadpoint.AcceptableError(err) {
|
||||
lp.log.ERROR.Printf("vehicle soc limit: %v", err)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,11 +26,3 @@ func (lp *Loadpoint) chargerSoc() (float64, error) {
|
|||
}
|
||||
return 0, api.ErrNotAvailable
|
||||
}
|
||||
|
||||
// chargerSocLimit returns charger soc limit if available
|
||||
func (lp *Loadpoint) chargerSocLimit() (int64, error) {
|
||||
if c, ok := lp.charger.(api.SocLimiter); ok {
|
||||
return c.GetLimitSoc()
|
||||
}
|
||||
return 0, api.ErrNotAvailable
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue