diff --git a/custom_components/ingv_centro_nazionale_terremoti/__init__.py b/custom_components/ingv_centro_nazionale_terremoti/__init__.py old mode 100644 new mode 100755 index d18f9d8..4d5ac23 --- a/custom_components/ingv_centro_nazionale_terremoti/__init__.py +++ b/custom_components/ingv_centro_nazionale_terremoti/__init__.py @@ -15,7 +15,6 @@ CONF_LONGITUDE, CONF_RADIUS, CONF_SCAN_INTERVAL, - CONF_UNIT_SYSTEM_IMPERIAL, LENGTH_MILES, Platform, ) @@ -25,7 +24,7 @@ from homeassistant.helpers.dispatcher import async_dispatcher_send from homeassistant.helpers.typing import ConfigType from homeassistant.helpers.update_coordinator import DataUpdateCoordinator -from homeassistant.util.unit_system import METRIC_SYSTEM +from homeassistant.util.unit_system import IMPERIAL_SYSTEM, METRIC_SYSTEM from .const import ( CONF_MINIMUM_MAGNITUDE, @@ -80,7 +79,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: hass.data.setdefault(DOMAIN, {}) feeds = hass.data[DOMAIN].setdefault(FEED, {}) radius = entry.options[CONF_RADIUS] - if hass.config.units.name == CONF_UNIT_SYSTEM_IMPERIAL: + if hass.config.units is IMPERIAL_SYSTEM: radius = METRIC_SYSTEM.length(radius, LENGTH_MILES) # Create feed entity coordinator for all platforms. coordinator = IngvDataUpdateCoordinator(hass=hass, entry=entry, radius_in_km=radius) diff --git a/custom_components/ingv_centro_nazionale_terremoti/geo_location.py b/custom_components/ingv_centro_nazionale_terremoti/geo_location.py old mode 100644 new mode 100755 index dee92d0..2be259a --- a/custom_components/ingv_centro_nazionale_terremoti/geo_location.py +++ b/custom_components/ingv_centro_nazionale_terremoti/geo_location.py @@ -9,11 +9,9 @@ from homeassistant.components.geo_location import PLATFORM_SCHEMA, GeolocationEvent from homeassistant.config_entries import SOURCE_IMPORT, ConfigEntry from homeassistant.const import ( - ATTR_TIME, CONF_LATITUDE, CONF_LONGITUDE, CONF_RADIUS, - CONF_UNIT_SYSTEM_IMPERIAL, LENGTH_KILOMETERS, LENGTH_MILES, ) @@ -176,7 +174,7 @@ def _update_internal_state(self) -> None: self._depth = round((feed_entry.origin.depth / 1000), 1) self._distance = feed_entry.distance_to_home # Convert distance and depth if not metric system. - if self.hass.config.units.name == CONF_UNIT_SYSTEM_IMPERIAL: + if self.hass.config.units is IMPERIAL_SYSTEM: self._depth = IMPERIAL_SYSTEM.length(self._depth, LENGTH_KILOMETERS) self._distance = IMPERIAL_SYSTEM.length(self._distance, LENGTH_KILOMETERS) self._attr_unit_of_measurement = LENGTH_MILES diff --git a/hacs.json b/hacs.json index a3870fd..301b4a2 100644 --- a/hacs.json +++ b/hacs.json @@ -4,5 +4,5 @@ "filename": "ingv_centro_nazionale_terremoti.zip", "country": ["IT"], "render_readme": true, - "homeassistant": "2022.6.0" + "homeassistant": "2022.11.0" }