audi_connect_ha icon indicating copy to clipboard operation
audi_connect_ha copied to clipboard

The name property of the Unit System is deprecated

Open epenet opened this issue 3 years ago • 1 comments

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 avatar Oct 14 '22 05:10 epenet

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

epenet avatar Oct 14 '22 05:10 epenet

PR created and awaiting merge: https://github.com/arjenvrh/audi_connect_ha/pull/160

titiviking avatar Nov 03 '22 10:11 titiviking