diff --git a/homeassistant/components/sense/__init__.py b/homeassistant/components/sense/__init__.py index 316cbb841ed..57cc748d7b2 100644 --- a/homeassistant/components/sense/__init__.py +++ b/homeassistant/components/sense/__init__.py @@ -5,7 +5,6 @@ import logging from sense_energy import ( ASyncSenseable, - SenseAPIException, SenseAuthenticationException, SenseMFARequiredException, ) @@ -27,13 +26,14 @@ from homeassistant.helpers.update_coordinator import DataUpdateCoordinator from .const import ( ACTIVE_UPDATE_RATE, DOMAIN, + SENSE_CONNECT_EXCEPTIONS, SENSE_DATA, SENSE_DEVICE_UPDATE, SENSE_DEVICES_DATA, SENSE_DISCOVERED_DEVICES_DATA, - SENSE_EXCEPTIONS, SENSE_TIMEOUT_EXCEPTIONS, SENSE_TRENDS_COORDINATOR, + SENSE_WEBSOCKET_EXCEPTIONS, ) _LOGGER = logging.getLogger(__name__) @@ -88,7 +88,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: raise ConfigEntryNotReady( str(err) or "Timed out during authentication" ) from err - except SenseAPIException as err: + except SENSE_CONNECT_EXCEPTIONS as err: raise ConfigEntryNotReady(str(err)) from err sense_devices_data = SenseDevicesData() @@ -99,7 +99,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: raise ConfigEntryNotReady( str(err) or "Timed out during realtime update" ) from err - except SENSE_EXCEPTIONS as err: + except SENSE_WEBSOCKET_EXCEPTIONS as err: raise ConfigEntryNotReady(str(err) or "Error during realtime update") from err async def _async_update_trend(): @@ -141,7 +141,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: await gateway.update_realtime() except SENSE_TIMEOUT_EXCEPTIONS as ex: _LOGGER.error("Timeout retrieving data: %s", ex) - except SENSE_EXCEPTIONS as ex: + except SENSE_WEBSOCKET_EXCEPTIONS as ex: _LOGGER.error("Failed to update data: %s", ex) data = gateway.get_realtime() diff --git a/homeassistant/components/sense/const.py b/homeassistant/components/sense/const.py index 1b7fdd8fabc..049b86e1064 100644 --- a/homeassistant/components/sense/const.py +++ b/homeassistant/components/sense/const.py @@ -40,8 +40,9 @@ SOLAR_POWERED_NAME = "Solar Powered Percentage" SOLAR_POWERED_ID = "solar_powered" SENSE_TIMEOUT_EXCEPTIONS = (asyncio.TimeoutError, SenseAPITimeoutException) -SENSE_EXCEPTIONS = (socket.gaierror, SenseWebsocketException) +SENSE_WEBSOCKET_EXCEPTIONS = (socket.gaierror, SenseWebsocketException) SENSE_CONNECT_EXCEPTIONS = ( + socket.gaierror, asyncio.TimeoutError, SenseAPITimeoutException, SenseAPIException,