Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The name property of the Unit System is deprecated #21

Closed
epenet opened this issue Oct 14, 2022 · 2 comments
Closed

The name property of the Unit System is deprecated #21

epenet opened this issue Oct 14, 2022 · 2 comments

Comments

@epenet
Copy link

epenet commented Oct 14, 2022

As per home-assistant/core#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
Copy link
Author

epenet commented Oct 14, 2022

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 added a commit that referenced this issue Nov 13, 2022
The name property of the Unit System is deprecated #21
@caiosweet
Copy link
Owner

Fixed thanks @epenet 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants