Skip to content

Commit dfbe42f

Browse files
authored
Use device id instead of archetype to check for Hue bridge (home-assistant#151097)
1 parent c9876e2 commit dfbe42f

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

homeassistant/components/hue/v2/device.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
from aiohue.v2 import HueBridgeV2
88
from aiohue.v2.controllers.events import EventType
99
from aiohue.v2.controllers.groups import Room, Zone
10-
from aiohue.v2.models.device import Device, DeviceArchetypes
10+
from aiohue.v2.models.device import Device
1111
from aiohue.v2.models.resource import ResourceTypes
1212

1313
from homeassistant.const import (
@@ -66,7 +66,7 @@ def add_device(hue_resource: Device | Room | Zone) -> dr.DeviceEntry:
6666
}
6767
if room := dev_controller.get_room(hue_resource.id):
6868
params[ATTR_SUGGESTED_AREA] = room.metadata.name
69-
if hue_resource.metadata.archetype == DeviceArchetypes.BRIDGE_V2:
69+
if hue_resource.id == api.config.bridge_device.id:
7070
params[ATTR_IDENTIFIERS].add((DOMAIN, api.config.bridge_id))
7171
else:
7272
params[ATTR_VIA_DEVICE] = (DOMAIN, api.config.bridge_device.id)
@@ -97,9 +97,7 @@ def handle_device_event(
9797
# create/update all current devices found in controllers
9898
# sort the devices to ensure bridges are added first
9999
hue_devices = list(dev_controller)
100-
hue_devices.sort(
101-
key=lambda dev: dev.metadata.archetype != DeviceArchetypes.BRIDGE_V2
102-
)
100+
hue_devices.sort(key=lambda dev: dev.id != api.config.bridge_device.id)
103101
known_devices = [add_device(hue_device) for hue_device in hue_devices]
104102
known_devices += [add_device(hue_room) for hue_room in api.groups.room]
105103
known_devices += [add_device(hue_zone) for hue_zone in api.groups.zone]

0 commit comments

Comments
 (0)