mirror of
https://github.com/home-assistant/core.git
synced 2025-04-24 17:27:52 +00:00
Avoid clearing the attr cache in setter when nothing has changed (#106384)
This commit is contained in:
parent
50f64e053e
commit
eb3fde7261
@ -227,6 +227,9 @@ class EntityPlatformState(Enum):
|
|||||||
REMOVED = auto()
|
REMOVED = auto()
|
||||||
|
|
||||||
|
|
||||||
|
_SENTINEL = object()
|
||||||
|
|
||||||
|
|
||||||
class EntityDescription(metaclass=FrozenOrThawed, frozen_or_thawed=True):
|
class EntityDescription(metaclass=FrozenOrThawed, frozen_or_thawed=True):
|
||||||
"""A class that describes Home Assistant entities."""
|
"""A class that describes Home Assistant entities."""
|
||||||
|
|
||||||
@ -346,6 +349,8 @@ class CachedProperties(type):
|
|||||||
Also invalidates the corresponding cached_property by calling
|
Also invalidates the corresponding cached_property by calling
|
||||||
delattr on it.
|
delattr on it.
|
||||||
"""
|
"""
|
||||||
|
if getattr(o, private_attr_name, _SENTINEL) == val:
|
||||||
|
return
|
||||||
setattr(o, private_attr_name, val)
|
setattr(o, private_attr_name, val)
|
||||||
try: # noqa: SIM105 suppress is much slower
|
try: # noqa: SIM105 suppress is much slower
|
||||||
delattr(o, name)
|
delattr(o, name)
|
||||||
|
@ -706,7 +706,7 @@ async def test_state_updates_zone(
|
|||||||
resp = await client.post(
|
resp = await client.post(
|
||||||
"/api/konnected/device/112233445566",
|
"/api/konnected/device/112233445566",
|
||||||
headers={"Authorization": "Bearer abcdefgh"},
|
headers={"Authorization": "Bearer abcdefgh"},
|
||||||
json={"zone": "5", "temp": 32, "addr": 1},
|
json={"zone": "5", "temp": 32.0, "addr": 1},
|
||||||
)
|
)
|
||||||
assert resp.status == HTTPStatus.OK
|
assert resp.status == HTTPStatus.OK
|
||||||
result = await resp.json()
|
result = await resp.json()
|
||||||
@ -863,7 +863,7 @@ async def test_state_updates_pin(
|
|||||||
resp = await client.post(
|
resp = await client.post(
|
||||||
"/api/konnected/device/112233445566",
|
"/api/konnected/device/112233445566",
|
||||||
headers={"Authorization": "Bearer abcdefgh"},
|
headers={"Authorization": "Bearer abcdefgh"},
|
||||||
json={"pin": "7", "temp": 32, "addr": 1},
|
json={"pin": "7", "temp": 32.0, "addr": 1},
|
||||||
)
|
)
|
||||||
assert resp.status == HTTPStatus.OK
|
assert resp.status == HTTPStatus.OK
|
||||||
result = await resp.json()
|
result = await resp.json()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user