Skip to content

Commit

Permalink
Force _attr_native_value to metric in bmw_connected_drive (#75225)
Browse files Browse the repository at this point in the history
Co-authored-by: rikroe <[email protected]>
  • Loading branch information
rikroe and rikroe authored Jul 16, 2022
1 parent c52d4c6 commit 686449c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
3 changes: 2 additions & 1 deletion homeassistant/components/bmw_connected_drive/coordinator.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ def __init__(self, hass: HomeAssistant, *, entry: ConfigEntry) -> None:
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
Expand Down
7 changes: 2 additions & 5 deletions homeassistant/components/bmw_connected_drive/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
)
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import (
CONF_UNIT_SYSTEM_IMPERIAL,
LENGTH_KILOMETERS,
LENGTH_MILES,
PERCENTAGE,
Expand Down Expand Up @@ -183,10 +182,8 @@ def __init__(
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:
Expand Down

0 comments on commit 686449c

Please sign in to comment.