From 686449cef605eabfa00a34c1c25defdd6d54c284 Mon Sep 17 00:00:00 2001 From: rikroe <42204099+rikroe@users.noreply.github.com> Date: Sat, 16 Jul 2022 17:00:42 +0200 Subject: [PATCH] Force `_attr_native_value` to metric in bmw_connected_drive (#75225) Co-authored-by: rikroe --- .../components/bmw_connected_drive/coordinator.py | 3 ++- homeassistant/components/bmw_connected_drive/sensor.py | 7 ++----- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/homeassistant/components/bmw_connected_drive/coordinator.py b/homeassistant/components/bmw_connected_drive/coordinator.py index e5a968b47fd..08e90d3c4e0 100644 --- a/homeassistant/components/bmw_connected_drive/coordinator.py +++ b/homeassistant/components/bmw_connected_drive/coordinator.py @@ -33,7 +33,8 @@ class BMWDataUpdateCoordinator(DataUpdateCoordinator): entry.data[CONF_PASSWORD], get_region_from_name(entry.data[CONF_REGION]), observer_position=GPSPosition(hass.config.latitude, hass.config.longitude), - use_metric_units=hass.config.units.is_metric, + # Force metric system as BMW API apparently only returns metric values now + use_metric_units=True, ) self.read_only = entry.options[CONF_READ_ONLY] self._entry = entry diff --git a/homeassistant/components/bmw_connected_drive/sensor.py b/homeassistant/components/bmw_connected_drive/sensor.py index 9f19673c398..f1046881ed3 100644 --- a/homeassistant/components/bmw_connected_drive/sensor.py +++ b/homeassistant/components/bmw_connected_drive/sensor.py @@ -16,7 +16,6 @@ from homeassistant.components.sensor import ( ) from homeassistant.config_entries import ConfigEntry from homeassistant.const import ( - CONF_UNIT_SYSTEM_IMPERIAL, LENGTH_KILOMETERS, LENGTH_MILES, PERCENTAGE, @@ -183,10 +182,8 @@ class BMWSensor(BMWBaseEntity, SensorEntity): self._attr_name = f"{vehicle.name} {description.key}" self._attr_unique_id = f"{vehicle.vin}-{description.key}" - if unit_system.name == CONF_UNIT_SYSTEM_IMPERIAL: - self._attr_native_unit_of_measurement = description.unit_imperial - else: - self._attr_native_unit_of_measurement = description.unit_metric + # Force metric system as BMW API apparently only returns metric values now + self._attr_native_unit_of_measurement = description.unit_metric @callback def _handle_coordinator_update(self) -> None: