Skip to content

Commit

Permalink
Updates units.py for the new api (#32)
Browse files Browse the repository at this point in the history
* Updates units.py for the new api

mrk-its/homeassistant-blitzortung#66 as described here.

* Update units.py

Fix the import

* Update to avoid imperial system being on deprecation list

Going for the last version of the named setting
  • Loading branch information
xdecock authored Mar 14, 2023
1 parent 7a1a325 commit 5f467ab
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions custom_components/weatherlink/units.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import voluptuous as vol
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import CONF_UNIT_SYSTEM_IMPERIAL
from homeassistant.util.unit_system import US_CUSTOMARY_SYSTEM
from homeassistant.core import HomeAssistant

from .units_db import (
Expand Down Expand Up @@ -210,7 +210,7 @@ def get_unit_config(hass: HomeAssistant, entry: ConfigEntry) -> UnitConfig:
except Exception:
logger.exception(f"failed to load unit config: {entry.options!r}")

if hass.config.units.name == CONF_UNIT_SYSTEM_IMPERIAL:
if hass.config.units == US_CUSTOMARY_SYSTEM:
return UnitConfig.default_imperial()

return UnitConfig.default_metric()

0 comments on commit 5f467ab

Please sign in to comment.