mirror of
https://github.com/home-assistant/core.git
synced 2025-08-07 06:35:10 +02:00
Replace not is_metric
with is IMPERIAL_SYSTEM
(#80266)
This commit is contained in:
@@ -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.
|
||||
|
@@ -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
|
||||
|
||||
|
Reference in New Issue
Block a user