Cache homekit_controller supported features (#106702)
This commit is contained in:
parent
f2514c0bde
commit
bc26377c16
19 changed files with 4588 additions and 192 deletions
|
@ -1,6 +1,7 @@
|
|||
"""Homekit Controller entities."""
|
||||
from __future__ import annotations
|
||||
|
||||
import contextlib
|
||||
from typing import Any
|
||||
|
||||
from aiohomekit.model.characteristics import (
|
||||
|
@ -74,6 +75,16 @@ class HomeKitEntity(Entity):
|
|||
if not self._async_remove_entity_if_accessory_or_service_disappeared():
|
||||
self._async_reconfigure()
|
||||
|
||||
@callback
|
||||
def _async_clear_property_cache(self, properties: tuple[str, ...]) -> None:
|
||||
"""Clear the cache of properties."""
|
||||
for prop in properties:
|
||||
# suppress is slower than try-except-pass, but
|
||||
# we do not expect to have many properties to clear
|
||||
# or this to be called often.
|
||||
with contextlib.suppress(AttributeError):
|
||||
delattr(self, prop)
|
||||
|
||||
@callback
|
||||
def _async_reconfigure(self) -> None:
|
||||
"""Reconfigure the entity."""
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue