1
0
mirror of https://github.com/home-assistant/core.git synced 2025-12-26 14:08:21 +00:00

Final clean up of helpers accessed via hass (#72032)

* Final clean up of helpers accessed via hass

* Fix circular dep

* Fix import
This commit is contained in:
Franck Nijhof
2022-05-17 22:42:37 +02:00
committed by GitHub
parent d1d6c6b923
commit bfb47eb212
17 changed files with 75 additions and 82 deletions

View File

@@ -420,6 +420,10 @@ class DeviceRegistry:
via_device_id: str | None | UndefinedType = UNDEFINED,
) -> DeviceEntry | None:
"""Update device attributes."""
# Circular dep
# pylint: disable=import-outside-toplevel
from . import area_registry as ar
old = self.devices[device_id]
new_values: dict[str, Any] = {} # Dict with new key/value pairs
@@ -442,13 +446,13 @@ class DeviceRegistry:
disabled_by = DeviceEntryDisabler(disabled_by)
if (
suggested_area not in (UNDEFINED, None, "")
suggested_area is not None
and suggested_area is not UNDEFINED
and suggested_area != ""
and area_id is UNDEFINED
and old.area_id is None
):
area = self.hass.helpers.area_registry.async_get(
self.hass
).async_get_or_create(suggested_area)
area = ar.async_get(self.hass).async_get_or_create(suggested_area)
area_id = area.id
if (