Revert "Add blog post about use of cached_property in Entity (#1907)" (#1925)

This reverts commit 3e8358d4386beb1bf507989fdfc4febc1f7cce35.
This commit is contained in:
Erik Montnemery 2023-09-15 11:48:24 +02:00 committed by GitHub
parent 2e9064010c
commit 59e72e4a30
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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)