mirror of
https://github.com/home-assistant/core.git
synced 2025-07-22 20:57:21 +00:00
Add guard for empty mac address in Hue integration (#61037)
This commit is contained in:
parent
5fdcbbe0e1
commit
86e8034ea0
@ -95,13 +95,12 @@ async def handle_v2_migration(hass: core.HomeAssistant, entry: ConfigEntry) -> N
|
|||||||
# handle entities attached to device
|
# handle entities attached to device
|
||||||
for hue_dev in api.devices:
|
for hue_dev in api.devices:
|
||||||
zigbee = api.devices.get_zigbee_connectivity(hue_dev.id)
|
zigbee = api.devices.get_zigbee_connectivity(hue_dev.id)
|
||||||
if not zigbee:
|
if not zigbee or not zigbee.mac_address:
|
||||||
# not a zigbee device
|
# not a zigbee device or invalid mac
|
||||||
continue
|
continue
|
||||||
mac = zigbee.mac_address
|
|
||||||
# get/update existing device by V1 identifier (mac address)
|
# get/update existing device by V1 identifier (mac address)
|
||||||
# the device will now have both the old and the new identifier
|
# 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(
|
hass_dev = dev_reg.async_get_or_create(
|
||||||
config_entry_id=entry.entry_id, identifiers=identifiers
|
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))
|
params[ATTR_IDENTIFIERS].add((DOMAIN, api.config.bridge_id))
|
||||||
else:
|
else:
|
||||||
params[ATTR_VIA_DEVICE] = (DOMAIN, api.config.bridge_device.id)
|
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] = {
|
params[ATTR_CONNECTIONS] = {
|
||||||
(device_registry.CONNECTION_NETWORK_MAC, zigbee.mac_address)
|
(device_registry.CONNECTION_NETWORK_MAC, zigbee.mac_address)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user