1
mirror of https://github.com/home-assistant/core synced 2024-10-04 07:58:43 +02:00

Use US_CUSTOMARY_SYSTEM in components (#80623)

This commit is contained in:
epenet 2022-10-19 18:54:50 +02:00 committed by GitHub
parent 374d46ec09
commit 2b2275dfb3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
16 changed files with 43 additions and 39 deletions

View File

@ -37,7 +37,7 @@ from homeassistant.helpers.event import async_track_time_interval
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
from homeassistant.util import location from homeassistant.util import location
from homeassistant.util.unit_conversion import DistanceConverter from homeassistant.util.unit_conversion import DistanceConverter
from homeassistant.util.unit_system import IMPERIAL_SYSTEM from homeassistant.util.unit_system import US_CUSTOMARY_SYSTEM
_LOGGER = logging.getLogger(__name__) _LOGGER = logging.getLogger(__name__)
@ -171,7 +171,7 @@ async def async_setup_platform(
stations_list = set(config.get(CONF_STATIONS_LIST, [])) stations_list = set(config.get(CONF_STATIONS_LIST, []))
radius = config.get(CONF_RADIUS, 0) radius = config.get(CONF_RADIUS, 0)
name = config[CONF_NAME] name = config[CONF_NAME]
if hass.config.units is IMPERIAL_SYSTEM: if hass.config.units is US_CUSTOMARY_SYSTEM:
radius = DistanceConverter.convert(radius, LENGTH_FEET, LENGTH_METERS) radius = DistanceConverter.convert(radius, LENGTH_FEET, LENGTH_METERS)
# Create a single instance of CityBikesNetworks. # Create a single instance of CityBikesNetworks.

View File

@ -40,7 +40,7 @@ from homeassistant.const import (
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity_platform import AddEntitiesCallback from homeassistant.helpers.entity_platform import AddEntitiesCallback
from homeassistant.helpers.typing import StateType from homeassistant.helpers.typing import StateType
from homeassistant.util.unit_system import IMPERIAL_SYSTEM, METRIC_SYSTEM from homeassistant.util.unit_system import METRIC_SYSTEM, US_CUSTOMARY_SYSTEM
from .const import DOMAIN from .const import DOMAIN
from .entity import EcowittEntity from .entity import EcowittEntity
@ -219,7 +219,7 @@ async def async_setup_entry(
# Ignore metrics that are not supported by the user's locale # Ignore metrics that are not supported by the user's locale
if sensor.stype in _METRIC and hass.config.units is not METRIC_SYSTEM: if sensor.stype in _METRIC and hass.config.units is not METRIC_SYSTEM:
return return
if sensor.stype in _IMPERIAL and hass.config.units is not IMPERIAL_SYSTEM: if sensor.stype in _IMPERIAL and hass.config.units is not US_CUSTOMARY_SYSTEM:
return return
mapping = ECOWITT_SENSORS_MAPPING[sensor.stype] mapping = ECOWITT_SENSORS_MAPPING[sensor.stype]

View File

@ -20,7 +20,7 @@ from homeassistant.helpers.dispatcher import async_dispatcher_send
from homeassistant.helpers.event import async_track_time_interval from homeassistant.helpers.event import async_track_time_interval
from homeassistant.helpers.typing import ConfigType from homeassistant.helpers.typing import ConfigType
from homeassistant.util.unit_conversion import DistanceConverter from homeassistant.util.unit_conversion import DistanceConverter
from homeassistant.util.unit_system import IMPERIAL_SYSTEM from homeassistant.util.unit_system import US_CUSTOMARY_SYSTEM
from .const import ( from .const import (
CONF_CATEGORIES, CONF_CATEGORIES,
@ -88,7 +88,7 @@ async def async_setup_entry(hass: HomeAssistant, config_entry: ConfigEntry) -> b
feeds = hass.data[DOMAIN].setdefault(FEED, {}) feeds = hass.data[DOMAIN].setdefault(FEED, {})
radius = config_entry.data[CONF_RADIUS] radius = config_entry.data[CONF_RADIUS]
if hass.config.units is IMPERIAL_SYSTEM: if hass.config.units is US_CUSTOMARY_SYSTEM:
radius = DistanceConverter.convert(radius, LENGTH_MILES, LENGTH_KILOMETERS) radius = DistanceConverter.convert(radius, LENGTH_MILES, LENGTH_KILOMETERS)
# Create feed entity manager for all platforms. # Create feed entity manager for all platforms.
manager = GdacsFeedEntityManager(hass, config_entry, radius) manager = GdacsFeedEntityManager(hass, config_entry, radius)

View File

@ -16,7 +16,7 @@ from homeassistant.helpers import entity_registry as er
from homeassistant.helpers.dispatcher import async_dispatcher_connect from homeassistant.helpers.dispatcher import async_dispatcher_connect
from homeassistant.helpers.entity_platform import AddEntitiesCallback from homeassistant.helpers.entity_platform import AddEntitiesCallback
from homeassistant.util.unit_conversion import DistanceConverter from homeassistant.util.unit_conversion import DistanceConverter
from homeassistant.util.unit_system import IMPERIAL_SYSTEM from homeassistant.util.unit_system import US_CUSTOMARY_SYSTEM
from . import GdacsFeedEntityManager from . import GdacsFeedEntityManager
from .const import DEFAULT_ICON, DOMAIN, FEED from .const import DEFAULT_ICON, DOMAIN, FEED
@ -107,7 +107,7 @@ class GdacsEvent(GeolocationEvent):
async def async_added_to_hass(self) -> None: async def async_added_to_hass(self) -> None:
"""Call when entity is added to hass.""" """Call when entity is added to hass."""
if self.hass.config.units is IMPERIAL_SYSTEM: if self.hass.config.units is US_CUSTOMARY_SYSTEM:
self._attr_unit_of_measurement = LENGTH_MILES self._attr_unit_of_measurement = LENGTH_MILES
self._remove_signal_delete = async_dispatcher_connect( self._remove_signal_delete = async_dispatcher_connect(
self.hass, f"gdacs_delete_{self._external_id}", self._delete_callback self.hass, f"gdacs_delete_{self._external_id}", self._delete_callback
@ -149,7 +149,7 @@ class GdacsEvent(GeolocationEvent):
event_name = f"{feed_entry.country} ({feed_entry.event_id})" event_name = f"{feed_entry.country} ({feed_entry.event_id})"
self._attr_name = f"{feed_entry.event_type}: {event_name}" self._attr_name = f"{feed_entry.event_type}: {event_name}"
# Convert distance if not metric system. # Convert distance if not metric system.
if self.hass.config.units is IMPERIAL_SYSTEM: if self.hass.config.units is US_CUSTOMARY_SYSTEM:
self._attr_distance = DistanceConverter.convert( self._attr_distance = DistanceConverter.convert(
feed_entry.distance_to_home, LENGTH_KILOMETERS, LENGTH_MILES feed_entry.distance_to_home, LENGTH_KILOMETERS, LENGTH_MILES
) )

View File

@ -20,7 +20,7 @@ from homeassistant.helpers.dispatcher import async_dispatcher_send
from homeassistant.helpers.event import async_track_time_interval from homeassistant.helpers.event import async_track_time_interval
from homeassistant.helpers.typing import ConfigType from homeassistant.helpers.typing import ConfigType
from homeassistant.util.unit_conversion import DistanceConverter from homeassistant.util.unit_conversion import DistanceConverter
from homeassistant.util.unit_system import IMPERIAL_SYSTEM from homeassistant.util.unit_system import US_CUSTOMARY_SYSTEM
from .const import ( from .const import (
CONF_MINIMUM_MAGNITUDE, CONF_MINIMUM_MAGNITUDE,
@ -95,7 +95,7 @@ async def async_setup_entry(hass: HomeAssistant, config_entry: ConfigEntry) -> b
feeds = hass.data[DOMAIN].setdefault(FEED, {}) feeds = hass.data[DOMAIN].setdefault(FEED, {})
radius = config_entry.data[CONF_RADIUS] radius = config_entry.data[CONF_RADIUS]
if hass.config.units is IMPERIAL_SYSTEM: if hass.config.units is US_CUSTOMARY_SYSTEM:
radius = DistanceConverter.convert(radius, LENGTH_MILES, LENGTH_KILOMETERS) radius = DistanceConverter.convert(radius, LENGTH_MILES, LENGTH_KILOMETERS)
# Create feed entity manager for all platforms. # Create feed entity manager for all platforms.
manager = GeonetnzQuakesFeedEntityManager(hass, config_entry, radius) manager = GeonetnzQuakesFeedEntityManager(hass, config_entry, radius)

View File

@ -15,7 +15,7 @@ from homeassistant.helpers import entity_registry as er
from homeassistant.helpers.dispatcher import async_dispatcher_connect from homeassistant.helpers.dispatcher import async_dispatcher_connect
from homeassistant.helpers.entity_platform import AddEntitiesCallback from homeassistant.helpers.entity_platform import AddEntitiesCallback
from homeassistant.util.unit_conversion import DistanceConverter from homeassistant.util.unit_conversion import DistanceConverter
from homeassistant.util.unit_system import IMPERIAL_SYSTEM from homeassistant.util.unit_system import US_CUSTOMARY_SYSTEM
from . import GeonetnzQuakesFeedEntityManager from . import GeonetnzQuakesFeedEntityManager
from .const import DOMAIN, FEED from .const import DOMAIN, FEED
@ -93,7 +93,7 @@ class GeonetnzQuakesEvent(GeolocationEvent):
async def async_added_to_hass(self) -> None: async def async_added_to_hass(self) -> None:
"""Call when entity is added to hass.""" """Call when entity is added to hass."""
if self.hass.config.units is IMPERIAL_SYSTEM: if self.hass.config.units is US_CUSTOMARY_SYSTEM:
self._attr_unit_of_measurement = LENGTH_MILES self._attr_unit_of_measurement = LENGTH_MILES
self._remove_signal_delete = async_dispatcher_connect( self._remove_signal_delete = async_dispatcher_connect(
self.hass, self.hass,
@ -136,7 +136,7 @@ class GeonetnzQuakesEvent(GeolocationEvent):
"""Update the internal state from the provided feed entry.""" """Update the internal state from the provided feed entry."""
self._attr_name = feed_entry.title self._attr_name = feed_entry.title
# Convert distance if not metric system. # Convert distance if not metric system.
if self.hass.config.units is IMPERIAL_SYSTEM: if self.hass.config.units is US_CUSTOMARY_SYSTEM:
self._attr_distance = DistanceConverter.convert( self._attr_distance = DistanceConverter.convert(
feed_entry.distance_to_home, LENGTH_KILOMETERS, LENGTH_MILES feed_entry.distance_to_home, LENGTH_KILOMETERS, LENGTH_MILES
) )

View File

@ -11,7 +11,7 @@ from homeassistant.const import (
) )
from homeassistant.core import callback from homeassistant.core import callback
from homeassistant.helpers import config_validation as cv from homeassistant.helpers import config_validation as cv
from homeassistant.util.unit_system import IMPERIAL_SYSTEM from homeassistant.util.unit_system import US_CUSTOMARY_SYSTEM
from .const import ( from .const import (
DEFAULT_RADIUS, DEFAULT_RADIUS,
@ -62,7 +62,7 @@ class GeonetnzVolcanoFlowHandler(config_entries.ConfigFlow, domain=DOMAIN):
if identifier in configured_instances(self.hass): if identifier in configured_instances(self.hass):
return await self._show_form({"base": "already_configured"}) return await self._show_form({"base": "already_configured"})
if self.hass.config.units is IMPERIAL_SYSTEM: if self.hass.config.units is US_CUSTOMARY_SYSTEM:
user_input[CONF_UNIT_SYSTEM] = IMPERIAL_UNITS user_input[CONF_UNIT_SYSTEM] = IMPERIAL_UNITS
else: else:
user_input[CONF_UNIT_SYSTEM] = METRIC_UNITS user_input[CONF_UNIT_SYSTEM] = METRIC_UNITS

View File

@ -22,7 +22,7 @@ from homeassistant.helpers.entity import DeviceInfo
from homeassistant.helpers.entity_platform import AddEntitiesCallback from homeassistant.helpers.entity_platform import AddEntitiesCallback
from homeassistant.helpers.location import find_coordinates from homeassistant.helpers.location import find_coordinates
import homeassistant.util.dt as dt_util import homeassistant.util.dt as dt_util
from homeassistant.util.unit_system import IMPERIAL_SYSTEM from homeassistant.util.unit_system import US_CUSTOMARY_SYSTEM
from .const import ( from .const import (
ATTRIBUTION, ATTRIBUTION,
@ -66,7 +66,7 @@ async def async_setup_entry(
if CONF_UNITS not in options: if CONF_UNITS not in options:
options[CONF_UNITS] = UNITS_METRIC options[CONF_UNITS] = UNITS_METRIC
if hass.config.units is IMPERIAL_SYSTEM: if hass.config.units is US_CUSTOMARY_SYSTEM:
options[CONF_UNITS] = UNITS_IMPERIAL options[CONF_UNITS] = UNITS_IMPERIAL
if CONF_TRAVEL_MODE in new_data: if CONF_TRAVEL_MODE in new_data:

View File

@ -24,7 +24,7 @@ from homeassistant.helpers.selector import (
LocationSelector, LocationSelector,
TimeSelector, TimeSelector,
) )
from homeassistant.util.unit_system import IMPERIAL_SYSTEM from homeassistant.util.unit_system import US_CUSTOMARY_SYSTEM
from .const import ( from .const import (
CONF_ARRIVAL_TIME, CONF_ARRIVAL_TIME,
@ -98,7 +98,7 @@ def default_options(hass: HomeAssistant) -> dict[str, str | None]:
CONF_DEPARTURE_TIME: None, CONF_DEPARTURE_TIME: None,
CONF_UNIT_SYSTEM: METRIC_UNITS, CONF_UNIT_SYSTEM: METRIC_UNITS,
} }
if hass.config.units is IMPERIAL_SYSTEM: if hass.config.units is US_CUSTOMARY_SYSTEM:
default[CONF_UNIT_SYSTEM] = IMPERIAL_UNITS default[CONF_UNIT_SYSTEM] = IMPERIAL_UNITS
return default return default

View File

@ -21,7 +21,7 @@ from homeassistant.const import (
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity_platform import AddEntitiesCallback from homeassistant.helpers.entity_platform import AddEntitiesCallback
from homeassistant.helpers.typing import StateType from homeassistant.helpers.typing import StateType
from homeassistant.util.unit_system import IMPERIAL_SYSTEM, UnitSystem from homeassistant.util.unit_system import US_CUSTOMARY_SYSTEM, UnitSystem
from . import MazdaEntity from . import MazdaEntity
from .const import DATA_CLIENT, DATA_COORDINATOR, DOMAIN from .const import DATA_CLIENT, DATA_COORDINATOR, DOMAIN
@ -51,7 +51,7 @@ class MazdaSensorEntityDescription(
def _get_distance_unit(unit_system: UnitSystem) -> str: def _get_distance_unit(unit_system: UnitSystem) -> str:
"""Return the distance unit for the given unit system.""" """Return the distance unit for the given unit system."""
if unit_system is IMPERIAL_SYSTEM: if unit_system is US_CUSTOMARY_SYSTEM:
return LENGTH_MILES return LENGTH_MILES
return LENGTH_KILOMETERS return LENGTH_KILOMETERS

View File

@ -13,7 +13,7 @@ from homeassistant.helpers.entity_platform import AddEntitiesCallback
from homeassistant.helpers.icon import icon_for_battery_level from homeassistant.helpers.icon import icon_for_battery_level
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
from homeassistant.util.unit_conversion import DistanceConverter from homeassistant.util.unit_conversion import DistanceConverter
from homeassistant.util.unit_system import IMPERIAL_SYSTEM from homeassistant.util.unit_system import US_CUSTOMARY_SYSTEM
from . import LeafEntity from . import LeafEntity
from .const import ( from .const import (
@ -123,7 +123,7 @@ class LeafRangeSensor(LeafEntity, SensorEntity):
if ret is None: if ret is None:
return None return None
if self.car.hass.config.units is IMPERIAL_SYSTEM or self.car.force_miles: if self.car.hass.config.units is US_CUSTOMARY_SYSTEM or self.car.force_miles:
ret = DistanceConverter.convert(ret, LENGTH_KILOMETERS, LENGTH_MILES) ret = DistanceConverter.convert(ret, LENGTH_KILOMETERS, LENGTH_MILES)
return round(ret) return round(ret)
@ -131,7 +131,7 @@ class LeafRangeSensor(LeafEntity, SensorEntity):
@property @property
def native_unit_of_measurement(self) -> str: def native_unit_of_measurement(self) -> str:
"""Battery range unit.""" """Battery range unit."""
if self.car.hass.config.units is IMPERIAL_SYSTEM or self.car.force_miles: if self.car.hass.config.units is US_CUSTOMARY_SYSTEM or self.car.force_miles:
return LENGTH_MILES return LENGTH_MILES
return LENGTH_KILOMETERS return LENGTH_KILOMETERS

View File

@ -23,7 +23,7 @@ from homeassistant.util.unit_conversion import (
PressureConverter, PressureConverter,
SpeedConverter, SpeedConverter,
) )
from homeassistant.util.unit_system import IMPERIAL_SYSTEM from homeassistant.util.unit_system import US_CUSTOMARY_SYSTEM
from . import base_unique_id, device_info from . import base_unique_id, device_info
from .const import ( from .const import (
@ -81,7 +81,7 @@ class NWSSensor(CoordinatorEntity, SensorEntity):
self.entity_description = description self.entity_description = description
self._attr_name = f"{station} {description.name}" self._attr_name = f"{station} {description.name}"
if hass.config.units is IMPERIAL_SYSTEM: if hass.config.units is US_CUSTOMARY_SYSTEM:
self._attr_native_unit_of_measurement = description.unit_convert self._attr_native_unit_of_measurement = description.unit_convert
@property @property

View File

@ -11,7 +11,7 @@ from homeassistant.core import HomeAssistant, callback
from homeassistant.exceptions import HomeAssistantError from homeassistant.exceptions import HomeAssistantError
from homeassistant.helpers.entity import EntityCategory from homeassistant.helpers.entity import EntityCategory
from homeassistant.helpers.entity_platform import AddEntitiesCallback from homeassistant.helpers.entity_platform import AddEntitiesCallback
from homeassistant.util.unit_system import IMPERIAL_SYSTEM, UnitSystem from homeassistant.util.unit_system import US_CUSTOMARY_SYSTEM, UnitSystem
from . import RainMachineData, RainMachineEntity from . import RainMachineData, RainMachineEntity
from .const import DATA_RESTRICTIONS_UNIVERSAL, DOMAIN from .const import DATA_RESTRICTIONS_UNIVERSAL, DOMAIN
@ -130,7 +130,7 @@ class FreezeProtectionTemperatureSelect(RainMachineEntity, SelectEntity):
self._label_to_api_value_map = {} self._label_to_api_value_map = {}
for option in description.extended_options: for option in description.extended_options:
if unit_system is IMPERIAL_SYSTEM: if unit_system is US_CUSTOMARY_SYSTEM:
label = option.imperial_label label = option.imperial_label
else: else:
label = option.metric_label label = option.metric_label

View File

@ -30,7 +30,11 @@ from homeassistant.helpers.update_coordinator import (
DataUpdateCoordinator, DataUpdateCoordinator,
) )
from homeassistant.util.unit_conversion import DistanceConverter, VolumeConverter from homeassistant.util.unit_conversion import DistanceConverter, VolumeConverter
from homeassistant.util.unit_system import IMPERIAL_SYSTEM, LENGTH_UNITS, PRESSURE_UNITS from homeassistant.util.unit_system import (
LENGTH_UNITS,
PRESSURE_UNITS,
US_CUSTOMARY_SYSTEM,
)
from . import get_device_info from . import get_device_info
from .const import ( from .const import (
@ -223,7 +227,7 @@ class SubaruSensor(
if unit in LENGTH_UNITS: if unit in LENGTH_UNITS:
return round(unit_system.length(current_value, unit), 1) return round(unit_system.length(current_value, unit), 1)
if unit in PRESSURE_UNITS and unit_system == IMPERIAL_SYSTEM: if unit in PRESSURE_UNITS and unit_system == US_CUSTOMARY_SYSTEM:
return round( return round(
unit_system.pressure(current_value, unit), unit_system.pressure(current_value, unit),
1, 1,
@ -235,7 +239,7 @@ class SubaruSensor(
FUEL_CONSUMPTION_LITERS_PER_HUNDRED_KILOMETERS, FUEL_CONSUMPTION_LITERS_PER_HUNDRED_KILOMETERS,
FUEL_CONSUMPTION_MILES_PER_GALLON, FUEL_CONSUMPTION_MILES_PER_GALLON,
] ]
and unit_system == IMPERIAL_SYSTEM and unit_system == US_CUSTOMARY_SYSTEM
): ):
return round((100.0 * L_PER_GAL) / (KM_PER_MI * current_value), 1) return round((100.0 * L_PER_GAL) / (KM_PER_MI * current_value), 1)
@ -250,14 +254,14 @@ class SubaruSensor(
return self.hass.config.units.length_unit return self.hass.config.units.length_unit
if unit in PRESSURE_UNITS: if unit in PRESSURE_UNITS:
if self.hass.config.units == IMPERIAL_SYSTEM: if self.hass.config.units == US_CUSTOMARY_SYSTEM:
return self.hass.config.units.pressure_unit return self.hass.config.units.pressure_unit
if unit in [ if unit in [
FUEL_CONSUMPTION_LITERS_PER_HUNDRED_KILOMETERS, FUEL_CONSUMPTION_LITERS_PER_HUNDRED_KILOMETERS,
FUEL_CONSUMPTION_MILES_PER_GALLON, FUEL_CONSUMPTION_MILES_PER_GALLON,
]: ]:
if self.hass.config.units == IMPERIAL_SYSTEM: if self.hass.config.units == US_CUSTOMARY_SYSTEM:
return FUEL_CONSUMPTION_MILES_PER_GALLON return FUEL_CONSUMPTION_MILES_PER_GALLON
return unit return unit

View File

@ -38,7 +38,7 @@ from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity_platform import AddEntitiesCallback from homeassistant.helpers.entity_platform import AddEntitiesCallback
from homeassistant.util import slugify from homeassistant.util import slugify
from homeassistant.util.unit_conversion import DistanceConverter, SpeedConverter from homeassistant.util.unit_conversion import DistanceConverter, SpeedConverter
from homeassistant.util.unit_system import IMPERIAL_SYSTEM from homeassistant.util.unit_system import US_CUSTOMARY_SYSTEM
from . import TomorrowioDataUpdateCoordinator, TomorrowioEntity from . import TomorrowioDataUpdateCoordinator, TomorrowioEntity
from .const import ( from .const import (
@ -327,7 +327,7 @@ class BaseTomorrowioSensorEntity(TomorrowioEntity, SensorEntity):
) )
if self.entity_description.native_unit_of_measurement is None: if self.entity_description.native_unit_of_measurement is None:
self._attr_native_unit_of_measurement = description.unit_metric self._attr_native_unit_of_measurement = description.unit_metric
if hass.config.units is IMPERIAL_SYSTEM: if hass.config.units is US_CUSTOMARY_SYSTEM:
self._attr_native_unit_of_measurement = description.unit_imperial self._attr_native_unit_of_measurement = description.unit_imperial
@property @property
@ -356,7 +356,7 @@ class BaseTomorrowioSensorEntity(TomorrowioEntity, SensorEntity):
desc.imperial_conversion desc.imperial_conversion
and desc.unit_imperial is not None and desc.unit_imperial is not None
and desc.unit_imperial != desc.unit_metric and desc.unit_imperial != desc.unit_metric
and self.hass.config.units is IMPERIAL_SYSTEM and self.hass.config.units is US_CUSTOMARY_SYSTEM
): ):
return handle_conversion(state, desc.imperial_conversion) return handle_conversion(state, desc.imperial_conversion)

View File

@ -26,7 +26,7 @@ from homeassistant.helpers.entity import DeviceInfo
from homeassistant.helpers.entity_platform import AddEntitiesCallback from homeassistant.helpers.entity_platform import AddEntitiesCallback
from homeassistant.helpers.location import find_coordinates from homeassistant.helpers.location import find_coordinates
from homeassistant.util.unit_conversion import DistanceConverter from homeassistant.util.unit_conversion import DistanceConverter
from homeassistant.util.unit_system import IMPERIAL_SYSTEM from homeassistant.util.unit_system import US_CUSTOMARY_SYSTEM
from .const import ( from .const import (
CONF_AVOID_FERRIES, CONF_AVOID_FERRIES,
@ -69,7 +69,7 @@ async def async_setup_entry(
CONF_AVOID_SUBSCRIPTION_ROADS: DEFAULT_AVOID_SUBSCRIPTION_ROADS, CONF_AVOID_SUBSCRIPTION_ROADS: DEFAULT_AVOID_SUBSCRIPTION_ROADS,
CONF_AVOID_TOLL_ROADS: DEFAULT_AVOID_TOLL_ROADS, CONF_AVOID_TOLL_ROADS: DEFAULT_AVOID_TOLL_ROADS,
} }
if hass.config.units is IMPERIAL_SYSTEM: if hass.config.units is US_CUSTOMARY_SYSTEM:
defaults[CONF_UNITS] = IMPERIAL_UNITS defaults[CONF_UNITS] = IMPERIAL_UNITS
if not config_entry.options: if not config_entry.options: