mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 03:07:37 +00:00
Improve lutron caseta error reporting when bridge is offline (#57832)
This commit is contained in:
parent
f4918b2d9a
commit
378c48da15
@ -1,5 +1,6 @@
|
|||||||
"""Component for interacting with a Lutron Caseta system."""
|
"""Component for interacting with a Lutron Caseta system."""
|
||||||
import asyncio
|
import asyncio
|
||||||
|
import contextlib
|
||||||
import logging
|
import logging
|
||||||
import ssl
|
import ssl
|
||||||
|
|
||||||
@ -106,16 +107,17 @@ async def async_setup_entry(hass, config_entry):
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
timed_out = True
|
timed_out = True
|
||||||
try:
|
with contextlib.suppress(asyncio.TimeoutError):
|
||||||
async with async_timeout.timeout(BRIDGE_TIMEOUT):
|
async with async_timeout.timeout(BRIDGE_TIMEOUT):
|
||||||
await bridge.connect()
|
await bridge.connect()
|
||||||
timed_out = False
|
timed_out = False
|
||||||
except asyncio.TimeoutError:
|
|
||||||
_LOGGER.error("Timeout while trying to connect to bridge at %s", host)
|
|
||||||
|
|
||||||
if timed_out or not bridge.is_connected():
|
if timed_out or not bridge.is_connected():
|
||||||
await bridge.close()
|
await bridge.close()
|
||||||
raise ConfigEntryNotReady
|
if timed_out:
|
||||||
|
raise ConfigEntryNotReady(f"Timed out while trying to connect to {host}")
|
||||||
|
if not bridge.is_connected():
|
||||||
|
raise ConfigEntryNotReady(f"Cannot connect to {host}")
|
||||||
|
|
||||||
_LOGGER.debug("Connected to Lutron Caseta bridge via LEAP at %s", host)
|
_LOGGER.debug("Connected to Lutron Caseta bridge via LEAP at %s", host)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user