mirror of
https://github.com/home-assistant/developers.home-assistant.git
synced 2025-05-09 12:38:38 +00:00
Blog post for deprecated unit system features
Blog post for deprecated unit system features
This commit is contained in:
commit
41cbae2d62
25
blog/2022-10-14-deprecate-unit-system.md
Normal file
25
blog/2022-10-14-deprecate-unit-system.md
Normal file
@ -0,0 +1,25 @@
|
||||
---
|
||||
author: epenet
|
||||
authorURL: https://github.com/epenet
|
||||
title: "Deprecate Unit System constants and properties"
|
||||
---
|
||||
|
||||
As of Home Assistant Core 2022.11, the `is_metric` and `name` properties of a unit system are deprecated
|
||||
and should not be used.
|
||||
|
||||
Custom integrations referencing these properties will need to be adjusted to use instance checks instead.
|
||||
|
||||
Correct:
|
||||
```python
|
||||
if hass.config.units is IMPERIAL_SYSTEM:
|
||||
pass
|
||||
|
||||
if hass.config.units is METRIC_SYSTEM:
|
||||
pass
|
||||
```
|
||||
|
||||
To avoid confusion with future unit systems, the constants `CONF_UNIT_SYSTEM_IMPERIAL`
|
||||
and `CONF_UNIT_SYSTEM_METRIC` are also deprecated and should no longer be referenced:
|
||||
- if they were used to compare against the `name` of a unit system,
|
||||
then this is no longer needed.
|
||||
- if they were used for another reason, then local constants should be created instead.
|
Loading…
x
Reference in New Issue
Block a user