caiosweet / Home-Assistant-custom-components-INGV

INGV - National Institute of Geophysics and Volcanology [Istituto Nazionale di Geofisica e Vulcanologia] Terremoti Italia.
http://www.ingv.it/it/
MIT License
23 stars 7 forks source link

The name property of the Unit System is deprecated #21

Closed epenet closed 2 years ago

epenet commented 2 years ago

As per https://github.com/home-assistant/core/pull/80257

The name of a unit system should never be used for checking its type. Instance checks should be used instead:

Correct:

if hass.config.units is IMPERIAL_SYSTEM:
    pass

if hass.config.units is METRIC_SYSTEM:
    pass

Incorrect:

if hass.config.units.name == CONF_UNIT_SYSTEM_IMPERIAL:
    pass

if hass.config.units.name == CONF_UNIT_SYSTEM_METRIC:
    pass
epenet commented 2 years ago

Note: the name property of the IMPERIAL_SYSTEM is likely to get adjusted as soon as 2022.11 so this is an advance warning

caiosweet commented 2 years ago

Fixed thanks @epenet 👍