1
0
mirror of https://github.com/home-assistant/core.git synced 2025-12-24 21:06:19 +00:00

Only fire device_registry_updated for suggested_area if the suggestion results in an area change (#69215)

This commit is contained in:
J. Nick Koston
2022-04-04 01:51:39 -06:00
committed by GitHub
parent 514e08c8fe
commit c2c6d12d73
2 changed files with 21 additions and 0 deletions

View File

@@ -43,6 +43,8 @@ CONNECTION_ZIGBEE = "zigbee"
ORPHANED_DEVICE_KEEP_SECONDS = 86400 * 30
RUNTIME_ONLY_ATTRS = {"suggested_area"}
class _DeviceIndex(NamedTuple):
identifiers: dict[tuple[str, str], str]
@@ -509,6 +511,15 @@ class DeviceRegistry:
new = attr.evolve(old, **new_values)
self._update_device(old, new)
# If its only run time attributes (suggested_area)
# that do not get saved we do not want to write
# to disk or fire an event as we would end up
# firing events for data we have nothing to compare
# against since its never saved on disk
if RUNTIME_ONLY_ATTRS.issuperset(new_values):
return new
self.async_schedule_save()
data: dict[str, Any] = {