diff --git a/homeassistant/components/gdacs/__init__.py b/homeassistant/components/gdacs/__init__.py index d4fe4177aed..71c06033469 100644 --- a/homeassistant/components/gdacs/__init__.py +++ b/homeassistant/components/gdacs/__init__.py @@ -11,7 +11,6 @@ from homeassistant.const import ( CONF_LONGITUDE, CONF_RADIUS, CONF_SCAN_INTERVAL, - CONF_UNIT_SYSTEM_IMPERIAL, LENGTH_KILOMETERS, LENGTH_MILES, ) @@ -21,6 +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 .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.name == CONF_UNIT_SYSTEM_IMPERIAL: + if hass.config.units is IMPERIAL_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 7e48cf0aa3a..b6083f2aa71 100644 --- a/homeassistant/components/gdacs/geo_location.py +++ b/homeassistant/components/gdacs/geo_location.py @@ -10,16 +10,13 @@ from aio_georss_gdacs.feed_entry import GdacsFeedEntry from homeassistant.components.geo_location import GeolocationEvent from homeassistant.config_entries import ConfigEntry -from homeassistant.const import ( - CONF_UNIT_SYSTEM_IMPERIAL, - LENGTH_KILOMETERS, - LENGTH_MILES, -) +from homeassistant.const import LENGTH_KILOMETERS, LENGTH_MILES from homeassistant.core import HomeAssistant, callback 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 . import GdacsFeedEntityManager from .const import DEFAULT_ICON, DOMAIN, FEED @@ -110,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.name == CONF_UNIT_SYSTEM_IMPERIAL: + if self.hass.config.units is IMPERIAL_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 @@ -152,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.name == CONF_UNIT_SYSTEM_IMPERIAL: + if self.hass.config.units is IMPERIAL_SYSTEM: self._attr_distance = DistanceConverter.convert( feed_entry.distance_to_home, LENGTH_KILOMETERS, LENGTH_MILES )