1
0
mirror of https://github.com/home-assistant/core.git synced 2025-05-10 00:49:17 +00:00

Reduce overhead to clear cache in button state ()

Same optimization as 
This commit is contained in:
J. Nick Koston 2024-03-20 13:41:24 -10:00 committed by GitHub
parent 1e54595084
commit b311fe2a0f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -123,10 +123,8 @@ class ButtonEntity(RestoreEntity, cached_properties=CACHED_PROPERTIES_WITH_ATTR_
def __set_state(self, state: str | None) -> None: def __set_state(self, state: str | None) -> None:
"""Set the entity state.""" """Set the entity state."""
try: # noqa: SIM105 suppress is much slower # Invalidate the cache of the cached property
del self.state self.__dict__.pop("state", None)
except AttributeError:
pass
self.__last_pressed_isoformat = state self.__last_pressed_isoformat = state
@final @final