Skip to content

Commit

Permalink
Fixed issue #21
Browse files Browse the repository at this point in the history
The name property of the Unit System is deprecated #21
  • Loading branch information
caiosweet committed Nov 13, 2022
1 parent 9205696 commit 96e837e
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 7 deletions.
5 changes: 2 additions & 3 deletions custom_components/ingv_centro_nazionale_terremoti/__init__.py
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
CONF_LONGITUDE,
CONF_RADIUS,
CONF_SCAN_INTERVAL,
CONF_UNIT_SYSTEM_IMPERIAL,
LENGTH_MILES,
Platform,
)
Expand All @@ -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,
Expand Down Expand Up @@ -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)
Expand Down
4 changes: 1 addition & 3 deletions custom_components/ingv_centro_nazionale_terremoti/geo_location.py
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion hacs.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@
"filename": "ingv_centro_nazionale_terremoti.zip",
"country": ["IT"],
"render_readme": true,
"homeassistant": "2022.6.0"
"homeassistant": "2022.11.0"
}

0 comments on commit 96e837e

Please sign in to comment.