From 3fab21ebc7f171a68a2abaecd93d24a16aa60e7b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ville=20Skytt=C3=A4?= Date: Mon, 10 May 2021 18:27:09 +0300 Subject: [PATCH] Skip Huawei LTE device registry setup with no identifiers or connections (#50261) Closes https://github.com/home-assistant/core/issues/50182 --- .../components/huawei_lte/__init__.py | 43 ++++++++++--------- 1 file changed, 23 insertions(+), 20 deletions(-) diff --git a/homeassistant/components/huawei_lte/__init__.py b/homeassistant/components/huawei_lte/__init__.py index f36ae97840b..ebb54ab75c6 100644 --- a/homeassistant/components/huawei_lte/__init__.py +++ b/homeassistant/components/huawei_lte/__init__.py @@ -393,26 +393,29 @@ async def async_setup_entry(hass: HomeAssistant, config_entry: ConfigEntry) -> b router.subscriptions.clear() # Set up device registry - device_data = {} - sw_version = None - if router.data.get(KEY_DEVICE_INFORMATION): - device_info = router.data[KEY_DEVICE_INFORMATION] - sw_version = device_info.get("SoftwareVersion") - if device_info.get("DeviceName"): - device_data["model"] = device_info["DeviceName"] - if not sw_version and router.data.get(KEY_DEVICE_BASIC_INFORMATION): - sw_version = router.data[KEY_DEVICE_BASIC_INFORMATION].get("SoftwareVersion") - if sw_version: - device_data["sw_version"] = sw_version - device_registry = await dr.async_get_registry(hass) - device_registry.async_get_or_create( - config_entry_id=config_entry.entry_id, - connections=router.device_connections, - identifiers=router.device_identifiers, - name=router.device_name, - manufacturer="Huawei", - **device_data, - ) + if router.device_identifiers or router.device_connections: + device_data = {} + sw_version = None + if router.data.get(KEY_DEVICE_INFORMATION): + device_info = router.data[KEY_DEVICE_INFORMATION] + sw_version = device_info.get("SoftwareVersion") + if device_info.get("DeviceName"): + device_data["model"] = device_info["DeviceName"] + if not sw_version and router.data.get(KEY_DEVICE_BASIC_INFORMATION): + sw_version = router.data[KEY_DEVICE_BASIC_INFORMATION].get( + "SoftwareVersion" + ) + if sw_version: + device_data["sw_version"] = sw_version + device_registry = await dr.async_get_registry(hass) + device_registry.async_get_or_create( + config_entry_id=config_entry.entry_id, + connections=router.device_connections, + identifiers=router.device_identifiers, + name=router.device_name, + manufacturer="Huawei", + **device_data, + ) # Forward config entry setup to platforms hass.config_entries.async_setup_platforms(config_entry, CONFIG_ENTRY_PLATFORMS)