Add guard for empty mac address in Hue integration (#61037)
parent
5fdcbbe0e1
commit
86e8034ea0
|
@ -95,13 +95,12 @@ async def handle_v2_migration(hass: core.HomeAssistant, entry: ConfigEntry) -> N
|
|||
# handle entities attached to device
|
||||
for hue_dev in api.devices:
|
||||
zigbee = api.devices.get_zigbee_connectivity(hue_dev.id)
|
||||
if not zigbee:
|
||||
# not a zigbee device
|
||||
if not zigbee or not zigbee.mac_address:
|
||||
# not a zigbee device or invalid mac
|
||||
continue
|
||||
mac = zigbee.mac_address
|
||||
# get/update existing device by V1 identifier (mac address)
|
||||
# the device will now have both the old and the new identifier
|
||||
identifiers = {(DOMAIN, hue_dev.id), (DOMAIN, mac)}
|
||||
identifiers = {(DOMAIN, hue_dev.id), (DOMAIN, zigbee.mac_address)}
|
||||
hass_dev = dev_reg.async_get_or_create(
|
||||
config_entry_id=entry.entry_id, identifiers=identifiers
|
||||
)
|
||||
|
|
|
@ -49,7 +49,8 @@ async def async_setup_devices(bridge: "HueBridge"):
|
|||
params[ATTR_IDENTIFIERS].add((DOMAIN, api.config.bridge_id))
|
||||
else:
|
||||
params[ATTR_VIA_DEVICE] = (DOMAIN, api.config.bridge_device.id)
|
||||
if zigbee := dev_controller.get_zigbee_connectivity(hue_device.id):
|
||||
zigbee = dev_controller.get_zigbee_connectivity(hue_device.id)
|
||||
if zigbee and zigbee.mac_address:
|
||||
params[ATTR_CONNECTIONS] = {
|
||||
(device_registry.CONNECTION_NETWORK_MAC, zigbee.mac_address)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue