Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 2fb1e40

Browse files
agnersballoob
andcommitted
Convert disabled_by to DeviceEntryDisabler on load (home-assistant#63944)
Co-authored-by: Paulus Schoutsen <balloob@gmail.com>
1 parent 7320904 commit 2fb1e40

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

‎homeassistant/helpers/device_registry.py‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -584,7 +584,9 @@ async def async_load(self) -> None:
584584
configuration_url=device["configuration_url"],
585585
# type ignores (if tuple arg was cast): likely https://github.com/python/mypy/issues/8625
586586
connections={tuple(conn) for conn in device["connections"]}, # type: ignore[misc]
587-
disabled_by=device["disabled_by"],
587+
disabled_by=DeviceEntryDisabler(device["disabled_by"])
588+
if device["disabled_by"]
589+
else None,
588590
entry_type=DeviceEntryType(device["entry_type"])
589591
if device["entry_type"]
590592
else None,

‎tests/helpers/test_device_registry.py‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -640,6 +640,7 @@ async def test_loading_saving_data(hass, registry, area_registry):
640640
identifiers={("hue", "abc")},
641641
manufacturer="manufacturer",
642642
model="light",
643+
entry_type=device_registry.DeviceEntryType.SERVICE,
643644
)
644645

645646
assert orig_light4.id == orig_light3.id
@@ -679,6 +680,15 @@ async def test_loading_saving_data(hass, registry, area_registry):
679680
assert orig_light == new_light
680681
assert orig_light4 == new_light4
681682

683+
# Ensure enums converted
684+
for (old, new) in (
685+
(orig_via, new_via),
686+
(orig_light, new_light),
687+
(orig_light4, new_light4),
688+
):
689+
assert old.disabled_by is new.disabled_by
690+
assert old.entry_type is new.entry_type
691+
682692
# Ensure a save/load cycle does not keep suggested area
683693
new_kitchen_light = registry2.async_get_device({("hue", "999")})
684694
assert orig_kitchen_light.suggested_area == "Kitchen"

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /