diff --git a/homeassistant/components/citybikes/sensor.py b/homeassistant/components/citybikes/sensor.py index 25716b67464..5da74167a0b 100644 --- a/homeassistant/components/citybikes/sensor.py +++ b/homeassistant/components/citybikes/sensor.py @@ -37,7 +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 +from homeassistant.util.unit_system import US_CUSTOMARY_SYSTEM _LOGGER = logging.getLogger(__name__) @@ -171,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 hass.config.units is IMPERIAL_SYSTEM: + if hass.config.units is US_CUSTOMARY_SYSTEM: radius = DistanceConverter.convert(radius, LENGTH_FEET, LENGTH_METERS) # Create a single instance of CityBikesNetworks. diff --git a/homeassistant/components/ecowitt/sensor.py b/homeassistant/components/ecowitt/sensor.py index 172561d7125..8c55c8bf801 100644 --- a/homeassistant/components/ecowitt/sensor.py +++ b/homeassistant/components/ecowitt/sensor.py @@ -40,7 +40,7 @@ from homeassistant.const import ( from homeassistant.core import HomeAssistant from homeassistant.helpers.entity_platform import AddEntitiesCallback 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 .entity import EcowittEntity @@ -219,7 +219,7 @@ async def async_setup_entry( # Ignore metrics that are not supported by the user's locale if sensor.stype in _METRIC and hass.config.units is not METRIC_SYSTEM: 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 mapping = ECOWITT_SENSORS_MAPPING[sensor.stype] diff --git a/homeassistant/components/gdacs/__init__.py b/homeassistant/components/gdacs/__init__.py index 71c06033469..269da061b58 100644 --- a/homeassistant/components/gdacs/__init__.py +++ b/homeassistant/components/gdacs/__init__.py @@ -20,7 +20,7 @@ from homeassistant.helpers.dispatcher import async_dispatcher_send from homeassistant.helpers.event import async_track_time_interval from homeassistant.helpers.typing import ConfigType 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 ( CONF_CATEGORIES, @@ -88,7 +88,7 @@ async def async_setup_entry(hass: HomeAssistant, config_entry: ConfigEntry) -> b feeds = hass.data[DOMAIN].setdefault(FEED, {}) 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) # Create feed entity manager for all platforms. manager = GdacsFeedEntityManager(hass, config_entry, radius) diff --git a/homeassistant/components/gdacs/geo_location.py b/homeassistant/components/gdacs/geo_location.py index b6083f2aa71..5d3b8f3375b 100644 --- a/homeassistant/components/gdacs/geo_location.py +++ b/homeassistant/components/gdacs/geo_location.py @@ -16,7 +16,7 @@ from homeassistant.helpers import entity_registry as er from homeassistant.helpers.dispatcher import async_dispatcher_connect from homeassistant.helpers.entity_platform import AddEntitiesCallback 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 .const import DEFAULT_ICON, DOMAIN, FEED @@ -107,7 +107,7 @@ class GdacsEvent(GeolocationEvent): async def async_added_to_hass(self) -> None: """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._remove_signal_delete = async_dispatcher_connect( 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})" self._attr_name = f"{feed_entry.event_type}: {event_name}" # 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( feed_entry.distance_to_home, LENGTH_KILOMETERS, LENGTH_MILES ) diff --git a/homeassistant/components/geonetnz_quakes/__init__.py b/homeassistant/components/geonetnz_quakes/__init__.py index bef0ee4c1fd..e09b4e720e3 100644 --- a/homeassistant/components/geonetnz_quakes/__init__.py +++ b/homeassistant/components/geonetnz_quakes/__init__.py @@ -20,7 +20,7 @@ from homeassistant.helpers.dispatcher import async_dispatcher_send from homeassistant.helpers.event import async_track_time_interval from homeassistant.helpers.typing import ConfigType 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 ( CONF_MINIMUM_MAGNITUDE, @@ -95,7 +95,7 @@ async def async_setup_entry(hass: HomeAssistant, config_entry: ConfigEntry) -> b feeds = hass.data[DOMAIN].setdefault(FEED, {}) 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) # Create feed entity manager for all platforms. manager = GeonetnzQuakesFeedEntityManager(hass, config_entry, radius) diff --git a/homeassistant/components/geonetnz_quakes/geo_location.py b/homeassistant/components/geonetnz_quakes/geo_location.py index bd382f1767d..a530c2d8fdb 100644 --- a/homeassistant/components/geonetnz_quakes/geo_location.py +++ b/homeassistant/components/geonetnz_quakes/geo_location.py @@ -15,7 +15,7 @@ from homeassistant.helpers import entity_registry as er from homeassistant.helpers.dispatcher import async_dispatcher_connect from homeassistant.helpers.entity_platform import AddEntitiesCallback 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 .const import DOMAIN, FEED @@ -93,7 +93,7 @@ class GeonetnzQuakesEvent(GeolocationEvent): async def async_added_to_hass(self) -> None: """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._remove_signal_delete = async_dispatcher_connect( self.hass, @@ -136,7 +136,7 @@ class GeonetnzQuakesEvent(GeolocationEvent): """Update the internal state from the provided feed entry.""" self._attr_name = feed_entry.title # 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( feed_entry.distance_to_home, LENGTH_KILOMETERS, LENGTH_MILES ) diff --git a/homeassistant/components/geonetnz_volcano/config_flow.py b/homeassistant/components/geonetnz_volcano/config_flow.py index d095aefab01..34e16970d4f 100644 --- a/homeassistant/components/geonetnz_volcano/config_flow.py +++ b/homeassistant/components/geonetnz_volcano/config_flow.py @@ -11,7 +11,7 @@ from homeassistant.const import ( ) from homeassistant.core import callback 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 ( DEFAULT_RADIUS, @@ -62,7 +62,7 @@ class GeonetnzVolcanoFlowHandler(config_entries.ConfigFlow, domain=DOMAIN): if identifier in configured_instances(self.hass): 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 else: user_input[CONF_UNIT_SYSTEM] = METRIC_UNITS diff --git a/homeassistant/components/google_travel_time/sensor.py b/homeassistant/components/google_travel_time/sensor.py index 3ea38af1f27..412f1738294 100644 --- a/homeassistant/components/google_travel_time/sensor.py +++ b/homeassistant/components/google_travel_time/sensor.py @@ -22,7 +22,7 @@ from homeassistant.helpers.entity import DeviceInfo from homeassistant.helpers.entity_platform import AddEntitiesCallback from homeassistant.helpers.location import find_coordinates 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 ( ATTRIBUTION, @@ -66,7 +66,7 @@ async def async_setup_entry( if CONF_UNITS not in options: 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 if CONF_TRAVEL_MODE in new_data: diff --git a/homeassistant/components/here_travel_time/config_flow.py b/homeassistant/components/here_travel_time/config_flow.py index a0f1fbbeb8c..38bd1742c91 100644 --- a/homeassistant/components/here_travel_time/config_flow.py +++ b/homeassistant/components/here_travel_time/config_flow.py @@ -24,7 +24,7 @@ from homeassistant.helpers.selector import ( LocationSelector, TimeSelector, ) -from homeassistant.util.unit_system import IMPERIAL_SYSTEM +from homeassistant.util.unit_system import US_CUSTOMARY_SYSTEM from .const import ( CONF_ARRIVAL_TIME, @@ -98,7 +98,7 @@ def default_options(hass: HomeAssistant) -> dict[str, str | None]: CONF_DEPARTURE_TIME: None, 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 return default diff --git a/homeassistant/components/mazda/sensor.py b/homeassistant/components/mazda/sensor.py index b322c80b6e6..212d646051c 100644 --- a/homeassistant/components/mazda/sensor.py +++ b/homeassistant/components/mazda/sensor.py @@ -21,7 +21,7 @@ from homeassistant.const import ( from homeassistant.core import HomeAssistant from homeassistant.helpers.entity_platform import AddEntitiesCallback 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 .const import DATA_CLIENT, DATA_COORDINATOR, DOMAIN @@ -51,7 +51,7 @@ class MazdaSensorEntityDescription( def _get_distance_unit(unit_system: UnitSystem) -> str: """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_KILOMETERS diff --git a/homeassistant/components/nissan_leaf/sensor.py b/homeassistant/components/nissan_leaf/sensor.py index 4543467f932..c92ed2300a4 100644 --- a/homeassistant/components/nissan_leaf/sensor.py +++ b/homeassistant/components/nissan_leaf/sensor.py @@ -13,7 +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 homeassistant.util.unit_system import US_CUSTOMARY_SYSTEM from . import LeafEntity from .const import ( @@ -123,7 +123,7 @@ class LeafRangeSensor(LeafEntity, SensorEntity): if ret is 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) return round(ret) @@ -131,7 +131,7 @@ class LeafRangeSensor(LeafEntity, SensorEntity): @property def native_unit_of_measurement(self) -> str: """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_KILOMETERS diff --git a/homeassistant/components/nws/sensor.py b/homeassistant/components/nws/sensor.py index ab34781f209..2e7495701a9 100644 --- a/homeassistant/components/nws/sensor.py +++ b/homeassistant/components/nws/sensor.py @@ -23,7 +23,7 @@ from homeassistant.util.unit_conversion import ( PressureConverter, 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 .const import ( @@ -81,7 +81,7 @@ class NWSSensor(CoordinatorEntity, SensorEntity): self.entity_description = description 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 @property diff --git a/homeassistant/components/rainmachine/select.py b/homeassistant/components/rainmachine/select.py index 12860e59e79..9010b9b4fed 100644 --- a/homeassistant/components/rainmachine/select.py +++ b/homeassistant/components/rainmachine/select.py @@ -11,7 +11,7 @@ from homeassistant.core import HomeAssistant, callback from homeassistant.exceptions import HomeAssistantError from homeassistant.helpers.entity import EntityCategory 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 .const import DATA_RESTRICTIONS_UNIVERSAL, DOMAIN @@ -130,7 +130,7 @@ class FreezeProtectionTemperatureSelect(RainMachineEntity, SelectEntity): self._label_to_api_value_map = {} for option in description.extended_options: - if unit_system is IMPERIAL_SYSTEM: + if unit_system is US_CUSTOMARY_SYSTEM: label = option.imperial_label else: label = option.metric_label diff --git a/homeassistant/components/subaru/sensor.py b/homeassistant/components/subaru/sensor.py index 672fe6b0dcc..bb467fc77de 100644 --- a/homeassistant/components/subaru/sensor.py +++ b/homeassistant/components/subaru/sensor.py @@ -30,7 +30,11 @@ from homeassistant.helpers.update_coordinator import ( DataUpdateCoordinator, ) 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 .const import ( @@ -223,7 +227,7 @@ class SubaruSensor( if unit in LENGTH_UNITS: 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( unit_system.pressure(current_value, unit), 1, @@ -235,7 +239,7 @@ class SubaruSensor( FUEL_CONSUMPTION_LITERS_PER_HUNDRED_KILOMETERS, 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) @@ -250,14 +254,14 @@ class SubaruSensor( return self.hass.config.units.length_unit 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 if unit in [ FUEL_CONSUMPTION_LITERS_PER_HUNDRED_KILOMETERS, 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 unit diff --git a/homeassistant/components/tomorrowio/sensor.py b/homeassistant/components/tomorrowio/sensor.py index 78c973fd80b..07b922e72ed 100644 --- a/homeassistant/components/tomorrowio/sensor.py +++ b/homeassistant/components/tomorrowio/sensor.py @@ -38,7 +38,7 @@ from homeassistant.core import HomeAssistant from homeassistant.helpers.entity_platform import AddEntitiesCallback from homeassistant.util import slugify 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 .const import ( @@ -327,7 +327,7 @@ class BaseTomorrowioSensorEntity(TomorrowioEntity, SensorEntity): ) if self.entity_description.native_unit_of_measurement is None: 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 @property @@ -356,7 +356,7 @@ class BaseTomorrowioSensorEntity(TomorrowioEntity, SensorEntity): desc.imperial_conversion and desc.unit_imperial is not None 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) diff --git a/homeassistant/components/waze_travel_time/sensor.py b/homeassistant/components/waze_travel_time/sensor.py index 67081aeab5f..d9916ae7df1 100644 --- a/homeassistant/components/waze_travel_time/sensor.py +++ b/homeassistant/components/waze_travel_time/sensor.py @@ -26,7 +26,7 @@ from homeassistant.helpers.entity import DeviceInfo from homeassistant.helpers.entity_platform import AddEntitiesCallback from homeassistant.helpers.location import find_coordinates 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 ( CONF_AVOID_FERRIES, @@ -69,7 +69,7 @@ async def async_setup_entry( CONF_AVOID_SUBSCRIPTION_ROADS: DEFAULT_AVOID_SUBSCRIPTION_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 if not config_entry.options: