mirror of
https://github.com/home-assistant/core.git
synced 2025-08-04 05:05:09 +02:00
Add try except in get_hostname_id function
This commit is contained in:
@@ -407,10 +407,14 @@ class PlenticoreDataFormatter:
|
|||||||
return PlenticoreDataFormatter.EM_STATES.get(value)
|
return PlenticoreDataFormatter.EM_STATES.get(value)
|
||||||
|
|
||||||
|
|
||||||
async def get_hostname_id(client: ApiClient) -> str:
|
async def get_hostname_id(client: ApiClient) -> str | None:
|
||||||
"""Check for known existing hostname ids."""
|
"""Check for known existing hostname ids."""
|
||||||
all_settings = await client.get_settings()
|
try:
|
||||||
for entry in all_settings["scb:network"]:
|
all_settings = await client.get_settings()
|
||||||
if entry.id in KNOWN_HOSTNAME_IDS:
|
for entry in all_settings["scb:network"]:
|
||||||
return entry.id
|
if entry.id in KNOWN_HOSTNAME_IDS:
|
||||||
raise ApiException("Hostname identifier not found in KNOWN_HOSTNAME_IDS")
|
return entry.id
|
||||||
|
except (TypeError, ValueError):
|
||||||
|
return "Network:Hostname"
|
||||||
|
|
||||||
|
return None
|
||||||
|
Reference in New Issue
Block a user