diff --git a/API Server/internal/api/vehicleproviders.go b/API Server/internal/api/vehicleproviders.go index 8e46e87..657bb7e 100644 --- a/API Server/internal/api/vehicleproviders.go +++ b/API Server/internal/api/vehicleproviders.go @@ -642,7 +642,12 @@ func headlineMetrics(trees []any) []providerMetric { {key: "fuelLevel", keys: []string{"fuelLevel", "fuelPercentage", "fuelRemainingPercent"}, unit: "%"}, {key: "fuelRange", keys: []string{"fuelRange", "rangeRemaining", "drivingRange", "fuelRangeTotal"}, unit: "km", distance: true}, {key: "batteryLevel", keys: []string{"batteryLevel", "chargeRemainingAmount", "stateOfCharge", "socLevel"}, unit: "%"}, - {key: "evRange", keys: []string{"evRange", "electricRange", "batteryRange", "evRangeWithAc"}, unit: "km", distance: true}, + {key: "evRange", keys: []string{"evRange", "electricRange", "batteryRange"}, unit: "km", distance: true}, + // Range with the climate control running, which Toyota reports beside the + // plain one. Its own reading rather than a fallback for evRange: the two + // are different numbers and the gap between them is the point — a driver + // deciding whether to run the A/C wants to see both. + {key: "evRangeWithAc", keys: []string{"evRangeWithAc"}, unit: "km", distance: true}, } out := []providerMetric{} diff --git a/API Server/internal/api/vehicleproviders_test.go b/API Server/internal/api/vehicleproviders_test.go index c45f49c..639e1fd 100644 --- a/API Server/internal/api/vehicleproviders_test.go +++ b/API Server/internal/api/vehicleproviders_test.go @@ -160,7 +160,8 @@ func TestFlattenJSONTruncates(t *testing.T) { func TestHeadlineMetrics(t *testing.T) { trees := []any{ decode(t, `{"payload": {"odometer": {"value": 270185, "unit": "km"}, "fuelLevel": 62}}`), - decode(t, `{"payload": {"batteryLevel": 80, "chargingStatus": "charging"}}`), + decode(t, `{"payload": {"batteryLevel": 80, "chargingStatus": "charging", + "evRange": {"value": 412, "unit": "km"}, "evRangeWithAc": {"value": 389, "unit": "km"}}}`), decode(t, `{"payload": {"vehicleLocation": {"latitude": 52.2297, "longitude": 21.0122}}}`), } got := map[string]providerMetric{} @@ -180,6 +181,14 @@ func TestHeadlineMetrics(t *testing.T) { if got["chargingStatus"].Value != "charging" { t.Errorf("chargingStatus = %+v", got["chargingStatus"]) } + // Range with the climate control on is its own reading, so a payload that + // reports both shows both rather than one standing in for the other. + if got["evRange"].Value != "412" || got["evRange"].Unit != "km" { + t.Errorf("evRange = %+v", got["evRange"]) + } + if got["evRangeWithAc"].Value != "389" || got["evRangeWithAc"].Unit != "km" { + t.Errorf("evRangeWithAc = %+v", got["evRangeWithAc"]) + } if got["location"].Value != "52.22970, 21.01220" { t.Errorf("location = %+v", got["location"]) } diff --git a/Web App/web/src/i18n/da.json b/Web App/web/src/i18n/da.json index f7278d8..674edd6 100644 --- a/Web App/web/src/i18n/da.json +++ b/Web App/web/src/i18n/da.json @@ -324,7 +324,8 @@ "fuelLevel": "Brændstofniveau", "fuelRange": "Rækkevidde", "batteryLevel": "Batteri", - "evRange": "Elektrisk rækkevidde", + "evRange": "Elektrisk rækkevidde (uden aircon)", + "evRangeWithAc": "Elektrisk rækkevidde (med aircon)", "chargingStatus": "Opladning", "location": "Position" } diff --git a/Web App/web/src/i18n/en.json b/Web App/web/src/i18n/en.json index 09082d4..e5c56ae 100644 --- a/Web App/web/src/i18n/en.json +++ b/Web App/web/src/i18n/en.json @@ -399,7 +399,8 @@ "fuelLevel": "Fuel level", "fuelRange": "Range", "batteryLevel": "Battery", - "evRange": "Electric range", + "evRange": "Electric range (A/C off)", + "evRangeWithAc": "Electric range (A/C on)", "chargingStatus": "Charging", "location": "Position" } diff --git a/Web App/web/src/i18n/pl.json b/Web App/web/src/i18n/pl.json index fe695b9..f2f9c7d 100644 --- a/Web App/web/src/i18n/pl.json +++ b/Web App/web/src/i18n/pl.json @@ -328,7 +328,8 @@ "fuelLevel": "Poziom paliwa", "fuelRange": "Zasięg", "batteryLevel": "Akumulator", - "evRange": "Zasięg elektryczny", + "evRange": "Zasięg elektryczny (bez klimatyzacji)", + "evRangeWithAc": "Zasięg elektryczny (z klimatyzacją)", "chargingStatus": "Ładowanie", "location": "Pozycja" }