Skip Huawei LTE device registry setup with no identifiers or connections (#50261)
Closes https://github.com/home-assistant/core/issues/50182
This commit is contained in:
parent
fca56993c6
commit
3fab21ebc7
1 changed files with 23 additions and 20 deletions
|
@ -393,26 +393,29 @@ async def async_setup_entry(hass: HomeAssistant, config_entry: ConfigEntry) -> b
|
||||||
router.subscriptions.clear()
|
router.subscriptions.clear()
|
||||||
|
|
||||||
# Set up device registry
|
# Set up device registry
|
||||||
device_data = {}
|
if router.device_identifiers or router.device_connections:
|
||||||
sw_version = None
|
device_data = {}
|
||||||
if router.data.get(KEY_DEVICE_INFORMATION):
|
sw_version = None
|
||||||
device_info = router.data[KEY_DEVICE_INFORMATION]
|
if router.data.get(KEY_DEVICE_INFORMATION):
|
||||||
sw_version = device_info.get("SoftwareVersion")
|
device_info = router.data[KEY_DEVICE_INFORMATION]
|
||||||
if device_info.get("DeviceName"):
|
sw_version = device_info.get("SoftwareVersion")
|
||||||
device_data["model"] = device_info["DeviceName"]
|
if device_info.get("DeviceName"):
|
||||||
if not sw_version and router.data.get(KEY_DEVICE_BASIC_INFORMATION):
|
device_data["model"] = device_info["DeviceName"]
|
||||||
sw_version = router.data[KEY_DEVICE_BASIC_INFORMATION].get("SoftwareVersion")
|
if not sw_version and router.data.get(KEY_DEVICE_BASIC_INFORMATION):
|
||||||
if sw_version:
|
sw_version = router.data[KEY_DEVICE_BASIC_INFORMATION].get(
|
||||||
device_data["sw_version"] = sw_version
|
"SoftwareVersion"
|
||||||
device_registry = await dr.async_get_registry(hass)
|
)
|
||||||
device_registry.async_get_or_create(
|
if sw_version:
|
||||||
config_entry_id=config_entry.entry_id,
|
device_data["sw_version"] = sw_version
|
||||||
connections=router.device_connections,
|
device_registry = await dr.async_get_registry(hass)
|
||||||
identifiers=router.device_identifiers,
|
device_registry.async_get_or_create(
|
||||||
name=router.device_name,
|
config_entry_id=config_entry.entry_id,
|
||||||
manufacturer="Huawei",
|
connections=router.device_connections,
|
||||||
**device_data,
|
identifiers=router.device_identifiers,
|
||||||
)
|
name=router.device_name,
|
||||||
|
manufacturer="Huawei",
|
||||||
|
**device_data,
|
||||||
|
)
|
||||||
|
|
||||||
# Forward config entry setup to platforms
|
# Forward config entry setup to platforms
|
||||||
hass.config_entries.async_setup_platforms(config_entry, CONFIG_ENTRY_PLATFORMS)
|
hass.config_entries.async_setup_platforms(config_entry, CONFIG_ENTRY_PLATFORMS)
|
||||||
|
|
Loading…
Add table
Reference in a new issue