Bluelink: add soc limit (#4452)

This commit is contained in:
Tobias Bayer 2022-09-15 11:46:41 +02:00 • committed by GitHub
parent d8ac684020
commit d5ba6797d6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 30 additions and 1 deletions

View file

@ -168,3 +168,20 @@ func (v *Provider) Odometer() (float64, error) {
res, err := v.statusLG()
return res.ResMsg.VehicleStatusInfo.Odometer.Value, err
}
var _ api.SocLimiter = (*Provider)(nil)
// TargetSoC implements the api.SocLimiter interface
func (v *Provider) TargetSoC() (float64, error) {
res, err := v.statusG()
if err == nil {
for _, targetSOC := range res.EvStatus.ReservChargeInfos.TargetSocList {
if targetSOC.PlugType == plugTypeAC {
return float64(targetSOC.TargetSocLevel), nil
}
}
}
return 0, err
}

View file

@ -38,7 +38,8 @@ type VehicleStatus struct {
Value, Unit int
}
}
DrvDistance []DrivingDistance
DrvDistance []DrivingDistance
ReservChargeInfos ReservChargeInfo
}
Vehicles []Vehicle
}
@ -58,6 +59,8 @@ type Odometer struct {
const (
timeFormat = "20060102150405 -0700" // Note: must add timeOffset
timeOffset = " +0100"
plugTypeAC = 1
)
func (d *VehicleStatus) Updated() (time.Time, error) {
@ -71,3 +74,12 @@ type DrivingDistance struct {
}
}
}
type ReservChargeInfo struct {
TargetSocList []TargetSoc
}
type TargetSoc struct {
TargetSocLevel int
PlugType int
}