mirror of
https://github.com/home-assistant/developers.home-assistant.git
synced 2025-07-09 18:36:29 +00:00
This reverts commit 3e8358d4386beb1bf507989fdfc4febc1f7cce35.
This commit is contained in:
parent
2e9064010c
commit
59e72e4a30
@ -1,11 +0,0 @@
|
||||
---
|
||||
author: J. Nick Koston
|
||||
authorURL: https://github.com/bdraco
|
||||
title: Entities with dynamic `device_class` or `attribution`
|
||||
---
|
||||
|
||||
The `Entity` base class now caches `device_class` and `attribution` using the `@cached_property` decorator. The cache allows Home Assistant to avoid recalculating the device class and attribution each time the state for the entity is written to the state machine since these values are not normally expected to change.
|
||||
|
||||
If your custom integration defines `device_class` or `attribution` using a `@property`, it should switch to using `@cached_property` instead unless these values can change at run time. Integrations should avoid changing `device_class` at run time since anything that consumes the state may be unable to handle the `device_class` unexpectedly changing.
|
||||
|
||||
The `@cached_property` decorator should be imported from `homeassistant.backports.functools` since the built-in `@cached_property` contains undocumented locking functionality that is not desirable and has been removed in cpython 3.12. For more information, see [cached_property](https://docs.python.org/3.12/library/functools.html#functools.cached_property)
|
Loading…
x
Reference in New Issue
Block a user