diff --git a/homeassistant/components/lutron_caseta/__init__.py b/homeassistant/components/lutron_caseta/__init__.py index 144a9a74c55..44e6e8761b1 100644 --- a/homeassistant/components/lutron_caseta/__init__.py +++ b/homeassistant/components/lutron_caseta/__init__.py @@ -1,5 +1,6 @@ """Component for interacting with a Lutron Caseta system.""" import asyncio +import contextlib import logging import ssl @@ -106,16 +107,17 @@ async def async_setup_entry(hass, config_entry): return False timed_out = True - try: + with contextlib.suppress(asyncio.TimeoutError): async with async_timeout.timeout(BRIDGE_TIMEOUT): await bridge.connect() 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(): 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)