mirror of
https://github.com/home-assistant/core.git
synced 2025-08-02 10:08:23 +00:00
Make _EventDeviceRegistryUpdatedData_Remove JSON serializable (#149734)
This commit is contained in:
parent
f7c8cdb3a7
commit
3d744f032f
@ -156,7 +156,7 @@ class _EventDeviceRegistryUpdatedData_Remove(TypedDict):
|
|||||||
|
|
||||||
action: Literal["remove"]
|
action: Literal["remove"]
|
||||||
device_id: str
|
device_id: str
|
||||||
device: DeviceEntry
|
device: dict[str, Any]
|
||||||
|
|
||||||
|
|
||||||
class _EventDeviceRegistryUpdatedData_Update(TypedDict):
|
class _EventDeviceRegistryUpdatedData_Update(TypedDict):
|
||||||
@ -1319,7 +1319,7 @@ class DeviceRegistry(BaseRegistry[dict[str, list[dict[str, Any]]]]):
|
|||||||
self.hass.bus.async_fire_internal(
|
self.hass.bus.async_fire_internal(
|
||||||
EVENT_DEVICE_REGISTRY_UPDATED,
|
EVENT_DEVICE_REGISTRY_UPDATED,
|
||||||
_EventDeviceRegistryUpdatedData_Remove(
|
_EventDeviceRegistryUpdatedData_Remove(
|
||||||
action="remove", device_id=device_id, device=device
|
action="remove", device_id=device_id, device=device.dict_repr
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
self.async_schedule_save()
|
self.async_schedule_save()
|
||||||
|
@ -1103,13 +1103,13 @@ class EntityRegistry(BaseRegistry):
|
|||||||
entities = async_entries_for_device(
|
entities = async_entries_for_device(
|
||||||
self, event.data["device_id"], include_disabled_entities=True
|
self, event.data["device_id"], include_disabled_entities=True
|
||||||
)
|
)
|
||||||
removed_device = event.data["device"]
|
removed_device_dict = event.data["device"]
|
||||||
for entity in entities:
|
for entity in entities:
|
||||||
config_entry_id = entity.config_entry_id
|
config_entry_id = entity.config_entry_id
|
||||||
if (
|
if (
|
||||||
config_entry_id in removed_device.config_entries
|
config_entry_id in removed_device_dict["config_entries"]
|
||||||
and entity.config_subentry_id
|
and entity.config_subentry_id
|
||||||
in removed_device.config_entries_subentries[config_entry_id]
|
in removed_device_dict["config_entries_subentries"][config_entry_id]
|
||||||
):
|
):
|
||||||
self.async_remove(entity.entity_id)
|
self.async_remove(entity.entity_id)
|
||||||
else:
|
else:
|
||||||
|
@ -1652,7 +1652,7 @@ async def test_removing_config_entries(
|
|||||||
assert update_events[4].data == {
|
assert update_events[4].data == {
|
||||||
"action": "remove",
|
"action": "remove",
|
||||||
"device_id": entry3.id,
|
"device_id": entry3.id,
|
||||||
"device": entry3,
|
"device": entry3.dict_repr,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1725,12 +1725,12 @@ async def test_deleted_device_removing_config_entries(
|
|||||||
assert update_events[3].data == {
|
assert update_events[3].data == {
|
||||||
"action": "remove",
|
"action": "remove",
|
||||||
"device_id": entry.id,
|
"device_id": entry.id,
|
||||||
"device": entry2,
|
"device": entry2.dict_repr,
|
||||||
}
|
}
|
||||||
assert update_events[4].data == {
|
assert update_events[4].data == {
|
||||||
"action": "remove",
|
"action": "remove",
|
||||||
"device_id": entry3.id,
|
"device_id": entry3.id,
|
||||||
"device": entry3,
|
"device": entry3.dict_repr,
|
||||||
}
|
}
|
||||||
|
|
||||||
device_registry.async_clear_config_entry(config_entry_1.entry_id)
|
device_registry.async_clear_config_entry(config_entry_1.entry_id)
|
||||||
@ -1976,7 +1976,7 @@ async def test_removing_config_subentries(
|
|||||||
assert update_events[7].data == {
|
assert update_events[7].data == {
|
||||||
"action": "remove",
|
"action": "remove",
|
||||||
"device_id": entry.id,
|
"device_id": entry.id,
|
||||||
"device": entry,
|
"device": entry.dict_repr,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -2106,7 +2106,7 @@ async def test_deleted_device_removing_config_subentries(
|
|||||||
assert update_events[4].data == {
|
assert update_events[4].data == {
|
||||||
"action": "remove",
|
"action": "remove",
|
||||||
"device_id": entry.id,
|
"device_id": entry.id,
|
||||||
"device": entry4,
|
"device": entry4.dict_repr,
|
||||||
}
|
}
|
||||||
|
|
||||||
device_registry.async_clear_config_subentry(config_entry_1.entry_id, None)
|
device_registry.async_clear_config_subentry(config_entry_1.entry_id, None)
|
||||||
@ -2930,7 +2930,7 @@ async def test_update_remove_config_entries(
|
|||||||
assert update_events[6].data == {
|
assert update_events[6].data == {
|
||||||
"action": "remove",
|
"action": "remove",
|
||||||
"device_id": entry3.id,
|
"device_id": entry3.id,
|
||||||
"device": entry3,
|
"device": entry3.dict_repr,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -3208,7 +3208,7 @@ async def test_update_remove_config_subentries(
|
|||||||
assert update_events[7].data == {
|
assert update_events[7].data == {
|
||||||
"action": "remove",
|
"action": "remove",
|
||||||
"device_id": entry_id,
|
"device_id": entry_id,
|
||||||
"device": entry_before_remove,
|
"device": entry_before_remove.dict_repr,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -3551,7 +3551,7 @@ async def test_restore_device(
|
|||||||
assert update_events[2].data == {
|
assert update_events[2].data == {
|
||||||
"action": "remove",
|
"action": "remove",
|
||||||
"device_id": entry.id,
|
"device_id": entry.id,
|
||||||
"device": entry,
|
"device": entry.dict_repr,
|
||||||
}
|
}
|
||||||
assert update_events[3].data == {
|
assert update_events[3].data == {
|
||||||
"action": "create",
|
"action": "create",
|
||||||
@ -3874,7 +3874,7 @@ async def test_restore_shared_device(
|
|||||||
assert update_events[3].data == {
|
assert update_events[3].data == {
|
||||||
"action": "remove",
|
"action": "remove",
|
||||||
"device_id": entry.id,
|
"device_id": entry.id,
|
||||||
"device": updated_device,
|
"device": updated_device.dict_repr,
|
||||||
}
|
}
|
||||||
assert update_events[4].data == {
|
assert update_events[4].data == {
|
||||||
"action": "create",
|
"action": "create",
|
||||||
@ -3883,7 +3883,7 @@ async def test_restore_shared_device(
|
|||||||
assert update_events[5].data == {
|
assert update_events[5].data == {
|
||||||
"action": "remove",
|
"action": "remove",
|
||||||
"device_id": entry.id,
|
"device_id": entry.id,
|
||||||
"device": entry2,
|
"device": entry2.dict_repr,
|
||||||
}
|
}
|
||||||
assert update_events[6].data == {
|
assert update_events[6].data == {
|
||||||
"action": "create",
|
"action": "create",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user