diff --git a/homeassistant/components/gdacs/geo_location.py b/homeassistant/components/gdacs/geo_location.py index 715ac779668..7e48cf0aa3a 100644 --- a/homeassistant/components/gdacs/geo_location.py +++ b/homeassistant/components/gdacs/geo_location.py @@ -19,7 +19,7 @@ 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_system import IMPERIAL_SYSTEM +from homeassistant.util.unit_conversion import DistanceConverter from . import GdacsFeedEntityManager from .const import DEFAULT_ICON, DOMAIN, FEED @@ -153,8 +153,8 @@ class GdacsEvent(GeolocationEvent): 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: - self._attr_distance = IMPERIAL_SYSTEM.length( - feed_entry.distance_to_home, LENGTH_KILOMETERS + self._attr_distance = DistanceConverter.convert( + feed_entry.distance_to_home, LENGTH_KILOMETERS, LENGTH_MILES ) else: self._attr_distance = feed_entry.distance_to_home diff --git a/homeassistant/components/geonetnz_quakes/geo_location.py b/homeassistant/components/geonetnz_quakes/geo_location.py index 26ad780d098..c6c872ba828 100644 --- a/homeassistant/components/geonetnz_quakes/geo_location.py +++ b/homeassistant/components/geonetnz_quakes/geo_location.py @@ -19,7 +19,7 @@ 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_system import IMPERIAL_SYSTEM +from homeassistant.util.unit_conversion import DistanceConverter from . import GeonetnzQuakesFeedEntityManager from .const import DOMAIN, FEED @@ -141,8 +141,8 @@ class GeonetnzQuakesEvent(GeolocationEvent): self._attr_name = feed_entry.title # Convert distance if not metric system. if self.hass.config.units.name == CONF_UNIT_SYSTEM_IMPERIAL: - self._attr_distance = IMPERIAL_SYSTEM.length( - feed_entry.distance_to_home, LENGTH_KILOMETERS + self._attr_distance = DistanceConverter.convert( + feed_entry.distance_to_home, LENGTH_KILOMETERS, LENGTH_MILES ) else: self._attr_distance = feed_entry.distance_to_home