dsg: add soc via battery_state_report.soc key (#31340)
This commit is contained in:
parent
1d24da13eb
commit
38a5dfd9da
3 changed files with 25 additions and 5 deletions
|
|
@ -204,6 +204,25 @@ func TestSocFreshestField(t *testing.T) {
|
|||
assert.Equal(t, 61.0, soc, "the still-updating field wins over the stale higher-priority field")
|
||||
}
|
||||
|
||||
func TestSocBatteryStateReportField(t *testing.T) {
|
||||
data := []point{{Key: KeyBatteryStateReportSoc, Name: "battery_state_report.soc", Value: "36"}}
|
||||
|
||||
soc, err := testProvider(data).Soc()
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, 36.0, soc)
|
||||
}
|
||||
|
||||
func TestSocBatteryStateReportOnlyFallbackField(t *testing.T) {
|
||||
data := []point{
|
||||
{Key: KeyBatteryStateReportSoc, Name: "battery_state_report.soc", Value: "36"},
|
||||
{Name: FieldHvBatteryLevelValue, Value: "40"},
|
||||
}
|
||||
|
||||
soc, err := testProvider(data).Soc()
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, 40.0, soc)
|
||||
}
|
||||
|
||||
// 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) {
|
||||
|
|
|
|||
|
|
@ -81,7 +81,7 @@ func (v *Provider) Soc() (float64, error) {
|
|||
return 0, err
|
||||
}
|
||||
|
||||
if p := lookup(data, FieldHvBatteryLevelValue, FieldSoc, FieldHvSoc); p != nil {
|
||||
if p := lookup(data, FieldHvBatteryLevelValue, FieldSoc, FieldHvSoc, KeyBatteryStateReportSoc); p != nil {
|
||||
return strconv.ParseFloat(p.Value, 64)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -127,10 +127,11 @@ const (
|
|||
FieldTargetSoc = "settings.target_soc"
|
||||
|
||||
// range
|
||||
FieldRangeCombined = "cruising_range_combined"
|
||||
FieldRangePrimary = "cruising_range_primary_engine"
|
||||
FieldRangeSecondary = "cruising_range_secondary_engine"
|
||||
KeyRangeID3 = "0ca40e18-0564-3eda-bcc0-7aee9ef44f04" // VW ID.3 cruising range, delivered as "value"
|
||||
FieldRangeCombined = "cruising_range_combined"
|
||||
FieldRangePrimary = "cruising_range_primary_engine"
|
||||
FieldRangeSecondary = "cruising_range_secondary_engine"
|
||||
KeyRangeID3 = "0ca40e18-0564-3eda-bcc0-7aee9ef44f04" // VW ID.3 range
|
||||
KeyBatteryStateReportSoc = "506cb83e-f99f-3af3-bbeb-0429b69a78d9" // VW ID.3 soc
|
||||
|
||||
// odo
|
||||
FieldOdometer = "mileage"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue