Loadpoint: honor welcome charge for default vehicles (#24334)
This commit is contained in:
parent
4bd04f9e56
commit
207423e6f1
4 changed files with 10 additions and 8 deletions
|
|
@ -2,6 +2,7 @@ package core
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"slices"
|
||||
|
||||
"github.com/evcc-io/evcc/api"
|
||||
"github.com/evcc-io/evcc/util/config"
|
||||
|
|
@ -47,6 +48,12 @@ func ptrValueEqual[T comparable](a, b *T) bool {
|
|||
return a == nil && b == nil || (*a) == (*b)
|
||||
}
|
||||
|
||||
// hasFeature returns true if features are supported and given feature present
|
||||
func hasFeature(a any, f api.Feature) bool {
|
||||
c, ok := a.(api.FeatureDescriber)
|
||||
return ok && slices.Contains(c.Features(), f)
|
||||
}
|
||||
|
||||
// deviceProperties returns the common device data for the given reference
|
||||
func deviceProperties[T any](dev config.Device[T]) config.Properties {
|
||||
if d, ok := dev.(config.ConfigurableDevice[T]); ok {
|
||||
|
|
|
|||
|
|
@ -1092,7 +1092,7 @@ func (lp *Loadpoint) updateChargerStatus() (bool, error) {
|
|||
if prevStatus != api.StatusNone {
|
||||
switch ev {
|
||||
case evVehicleConnect:
|
||||
welcomeCharge = lp.chargerHasFeature(api.WelcomeCharge)
|
||||
welcomeCharge = lp.chargerHasFeature(api.WelcomeCharge) || hasFeature(lp.defaultVehicle, api.WelcomeCharge)
|
||||
|
||||
// Enable charging on connect if any available vehicle requires it.
|
||||
// We're using the PV timer to disable after the welcome
|
||||
|
|
|
|||
|
|
@ -1,8 +1,6 @@
|
|||
package core
|
||||
|
||||
import (
|
||||
"slices"
|
||||
|
||||
"github.com/evcc-io/evcc/api"
|
||||
"github.com/evcc-io/evcc/core/keys"
|
||||
"github.com/evcc-io/evcc/core/soc"
|
||||
|
|
@ -10,8 +8,7 @@ import (
|
|||
|
||||
// chargerHasFeature checks availability of charger feature
|
||||
func (lp *Loadpoint) chargerHasFeature(f api.Feature) bool {
|
||||
c, ok := lp.charger.(api.FeatureDescriber)
|
||||
return ok && slices.Contains(c.Features(), f)
|
||||
return hasFeature(lp.charger, f)
|
||||
}
|
||||
|
||||
// publishChargerFeature publishes availability of charger features
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@ package core
|
|||
import (
|
||||
"errors"
|
||||
"regexp"
|
||||
"slices"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
|
|
@ -219,8 +218,7 @@ func (lp *Loadpoint) unpublishVehicle() {
|
|||
|
||||
// vehicleHasFeature checks availability of vehicle feature
|
||||
func (lp *Loadpoint) vehicleHasFeature(f api.Feature) bool {
|
||||
v, ok := lp.GetVehicle().(api.FeatureDescriber)
|
||||
return ok && slices.Contains(v.Features(), f)
|
||||
return hasFeature(lp.GetVehicle(), f)
|
||||
}
|
||||
|
||||
// vehicleUnidentified returns true if there are associated vehicles and detection is running.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue