From 4769ec8c76b91fad5178518b4433dea63bed50f5 Mon Sep 17 00:00:00 2001 From: epenet <6771947+epenet@users.noreply.github.com> Date: Fri, 14 Oct 2022 12:51:47 +0200 Subject: [PATCH] Replace `not is_metric` with `is IMPERIAL_SYSTEM` (#80266) --- homeassistant/components/citybikes/sensor.py | 3 ++- homeassistant/components/nissan_leaf/sensor.py | 5 +++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/homeassistant/components/citybikes/sensor.py b/homeassistant/components/citybikes/sensor.py index 5074378adca..25716b67464 100644 --- a/homeassistant/components/citybikes/sensor.py +++ b/homeassistant/components/citybikes/sensor.py @@ -37,6 +37,7 @@ from homeassistant.helpers.event import async_track_time_interval from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType from homeassistant.util import location from homeassistant.util.unit_conversion import DistanceConverter +from homeassistant.util.unit_system import IMPERIAL_SYSTEM _LOGGER = logging.getLogger(__name__) @@ -170,7 +171,7 @@ async def async_setup_platform( stations_list = set(config.get(CONF_STATIONS_LIST, [])) radius = config.get(CONF_RADIUS, 0) name = config[CONF_NAME] - if not hass.config.units.is_metric: + if hass.config.units is IMPERIAL_SYSTEM: radius = DistanceConverter.convert(radius, LENGTH_FEET, LENGTH_METERS) # Create a single instance of CityBikesNetworks. diff --git a/homeassistant/components/nissan_leaf/sensor.py b/homeassistant/components/nissan_leaf/sensor.py index 0e7cc0c00cd..4543467f932 100644 --- a/homeassistant/components/nissan_leaf/sensor.py +++ b/homeassistant/components/nissan_leaf/sensor.py @@ -13,6 +13,7 @@ from homeassistant.helpers.entity_platform import AddEntitiesCallback from homeassistant.helpers.icon import icon_for_battery_level from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType from homeassistant.util.unit_conversion import DistanceConverter +from homeassistant.util.unit_system import IMPERIAL_SYSTEM from . import LeafEntity from .const import ( @@ -122,7 +123,7 @@ class LeafRangeSensor(LeafEntity, SensorEntity): if ret is None: return None - if not self.car.hass.config.units.is_metric or self.car.force_miles: + if self.car.hass.config.units is IMPERIAL_SYSTEM or self.car.force_miles: ret = DistanceConverter.convert(ret, LENGTH_KILOMETERS, LENGTH_MILES) return round(ret) @@ -130,7 +131,7 @@ class LeafRangeSensor(LeafEntity, SensorEntity): @property def native_unit_of_measurement(self) -> str: """Battery range unit.""" - if not self.car.hass.config.units.is_metric or self.car.force_miles: + if self.car.hass.config.units is IMPERIAL_SYSTEM or self.car.force_miles: return LENGTH_MILES return LENGTH_KILOMETERS