vw/eudataact: fall back to battery care mode field for target SoC (#32242)

This commit is contained in:
github-actions[bot] 2026-07-28 20:02:17 +00:00 • committed by GitHub
parent 614c91080b
commit 19ed27fa54
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 14 additions and 2 deletions

View file

@ -237,6 +237,17 @@ func TestSocBatteryStateReportOnlyFallbackField(t *testing.T) {
assert.Equal(t, 40.0, soc)
}
// TestGetLimitSocBcamThreshold reproduces issue #32241: the Audi Q4 e-tron
// reports its battery care mode SoC limit only under the battery care mode
// field, not under the generic target soc field.
func TestGetLimitSocBcamThreshold(t *testing.T) {
data := []point{{Name: FieldChargeBcamThreshold, Value: "80"}}
limit, err := testProvider(data).GetLimitSoc()
require.NoError(t, err)
assert.Equal(t, int64(80), limit)
}
// TestPoints guards that a data point with a generic field name ("value") is
// stored once yet found by both its unique key and its name.
func TestPoints(t *testing.T) {

View file

@ -188,7 +188,7 @@ func (v *Provider) GetLimitSoc() (int64, error) {
return 0, err
}
if p := lookup(data, FieldTargetSoc); p != nil {
if p := lookup(data, FieldTargetSoc, FieldChargeBcamThreshold); p != nil {
f, err := strconv.ParseFloat(p.Value, 64)
return int64(f), err
}

View file

@ -130,7 +130,8 @@ const (
FieldHvBatteryLevelValue = "battery_level_HV.value"
// target soc
FieldTargetSoc = "settings.target_soc"
FieldTargetSoc = "settings.target_soc"
FieldChargeBcamThreshold = "battery_care_mode.charge_bcam_threshold" // Audi Q4 e-tron battery care mode target soc
// range
FieldRangeCombined = "cruising_range_combined"