From 59e72e4a3075e9f871026c6bdce85b803f09b5ef Mon Sep 17 00:00:00 2001 From: Erik Montnemery Date: Fri, 15 Sep 2023 11:48:24 +0200 Subject: [PATCH] Revert "Add blog post about use of cached_property in Entity (#1907)" (#1925) This reverts commit 3e8358d4386beb1bf507989fdfc4febc1f7cce35. --- blog/2023-09-14-entity_cached_property.md | 11 ----------- 1 file changed, 11 deletions(-) delete mode 100644 blog/2023-09-14-entity_cached_property.md diff --git a/blog/2023-09-14-entity_cached_property.md b/blog/2023-09-14-entity_cached_property.md deleted file mode 100644 index ac992adb..00000000 --- a/blog/2023-09-14-entity_cached_property.md +++ /dev/null @@ -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) \ No newline at end of file