Skip to content
Snippets Groups Projects
Commit cd6c9231 authored by David F. Mulcahey's avatar David F. Mulcahey Committed by Charles Garwood
Browse files

fix exception (#21571)

parent b8ec74cc
No related branches found
No related tags found
No related merge requests found
...@@ -82,19 +82,23 @@ async def websocket_get_devices(hass, connection, msg): ...@@ -82,19 +82,23 @@ async def websocket_get_devices(hass, connection, msg):
"""Get ZHA devices.""" """Get ZHA devices."""
zha_gateway = hass.data[DATA_ZHA][DATA_ZHA_GATEWAY] zha_gateway = hass.data[DATA_ZHA][DATA_ZHA_GATEWAY]
ha_device_registry = await async_get_registry(hass) ha_device_registry = await async_get_registry(hass)
devices = [
{ devices = []
**device.device_info, for device in zha_gateway.devices.values():
'user_given_name': ha_device_registry.async_get_device( ret_device = {}
{(DOMAIN, str(device.ieee))}, set()).name_by_user, ret_device.update(device.device_info)
'device_reg_id': ha_device_registry.async_get_device( ret_device['entities'] = [{
{(DOMAIN, str(device.ieee))}, set()).id, 'entity_id': entity_ref.reference_id,
'entities': [{ NAME: entity_ref.device_info[NAME]
'entity_id': entity_ref.reference_id, } for entity_ref in zha_gateway.device_registry[device.ieee]]
NAME: entity_ref.device_info[NAME]
} for entity_ref in zha_gateway.device_registry[device.ieee]] reg_device = ha_device_registry.async_get_device(
} for device in zha_gateway.devices.values() {(DOMAIN, str(device.ieee))}, set())
] if reg_device is not None:
ret_device['user_given_name'] = reg_device.name_by_user
ret_device['device_reg_id'] = reg_device.id
devices.append(ret_device)
connection.send_result(msg[ID], devices) connection.send_result(msg[ID], devices)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment