mirror of
https://github.com/home-assistant/core.git
synced 2025-04-24 17:27:52 +00:00
Reduce overhead to clear cache in button state (#113895)
Same optimization as #113136
This commit is contained in:
parent
1e54595084
commit
b311fe2a0f
@ -123,10 +123,8 @@ class ButtonEntity(RestoreEntity, cached_properties=CACHED_PROPERTIES_WITH_ATTR_
|
||||
|
||||
def __set_state(self, state: str | None) -> None:
|
||||
"""Set the entity state."""
|
||||
try: # noqa: SIM105 suppress is much slower
|
||||
del self.state
|
||||
except AttributeError:
|
||||
pass
|
||||
# Invalidate the cache of the cached property
|
||||
self.__dict__.pop("state", None)
|
||||
self.__last_pressed_isoformat = state
|
||||
|
||||
@final
|
||||
|
Loading…
x
Reference in New Issue
Block a user