Home Assistant Unofficial Reference 2024.12.1
homeassistant.helpers.entity.CachedProperties Class Reference
Inheritance diagram for homeassistant.helpers.entity.CachedProperties:
[legend]
Collaboration diagram for homeassistant.helpers.entity.CachedProperties:
[legend]

Public Member Functions

None __init__ (cls, str name, tuple[type,...] bases, dict[Any, Any] namespace, **Any kwargs)
 
Any __new__ (mcs, str name, tuple[type,...] bases, dict[Any, Any] namespace, set[str]|None cached_properties=None, **Any kwargs)
 

Detailed Description

Metaclass which invalidates cached entity properties on write to _attr_.

A class which has CachedProperties can optionally have a list of cached
properties, passed as cached_properties, which must be a set of strings.
- Each item in the cached_property set must be the name of a method decorated
  with @cached_property
- For each item in the cached_property set, a property function with the
  same name, prefixed with _attr_, will be created
- The property _attr_-property functions allow setting, getting and deleting
  data, which will be stored in an attribute prefixed with __attr_
- The _attr_-property setter will invalidate the @cached_property by calling
  delattr on it

Definition at line 268 of file entity.py.

Constructor & Destructor Documentation

◆ __init__()

None homeassistant.helpers.entity.CachedProperties.__init__ (   cls,
str  name,
tuple[type, ...]  bases,
dict[Any, Any]  namespace,
**Any  kwargs 
)
Finish creating a new CachedProperties.

Wrap _attr_ for cached properties in property objects.

Definition at line 298 of file entity.py.

Member Function Documentation

◆ __new__()

Any homeassistant.helpers.entity.CachedProperties.__new__ (   mcs,
str  name,
tuple[type, ...]  bases,
dict[Any, Any]  namespace,
set[str] | None   cached_properties = None,
**Any  kwargs 
)
Start creating a new CachedProperties.

Pop cached_properties and store it in the namespace.

Definition at line 283 of file entity.py.


The documentation for this class was generated from the following file: