Skip to content

Commit ab7abd2

Browse files
authored
Handle login error (#158)
- Bump connectlife to 0.5.3 - Increase timeout for fetching data - Version 0.20.2
1 parent b0fbce4 commit ab7abd2

File tree

3 files changed

+9
-5
lines changed

3 files changed

+9
-5
lines changed

custom_components/connectlife/__init__.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@
22

33
from __future__ import annotations
44

5+
from homeassistant.exceptions import ConfigEntryError
56
from homeassistant.config_entries import ConfigEntry
67
from homeassistant.const import Platform, CONF_USERNAME, CONF_PASSWORD
78
from homeassistant.core import HomeAssistant
8-
from connectlife.api import ConnectLifeApi
9+
from connectlife.api import ConnectLifeApi, LifeConnectAuthError
910

1011
from .const import CONF_DEVELOPMENT_MODE, CONF_TEST_SERVER_URL, DOMAIN
1112
from .coordinator import ConnectLifeCoordinator
@@ -31,7 +32,10 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
3132
else None
3233
)
3334
api = ConnectLifeApi(entry.data[CONF_USERNAME], entry.data[CONF_PASSWORD], test_server_url)
34-
await api.login()
35+
try:
36+
await api.login()
37+
except LifeConnectAuthError as ex:
38+
raise ConfigEntryError from ex
3539
coordinator = ConnectLifeCoordinator(hass, api)
3640
await coordinator.async_config_entry_first_refresh()
3741
hass.data[DOMAIN][entry.entry_id] = coordinator

custom_components/connectlife/coordinator.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ async def _async_update_data(self):
3939
try:
4040
# Note: asyncio.TimeoutError and aiohttp.ClientError are already
4141
# handled by the data update coordinator.
42-
async with async_timeout.timeout(10):
42+
async with async_timeout.timeout(30):
4343
await self.api.get_appliances()
4444
self.error_count = 0
4545
except LifeConnectAuthError as err:

custom_components/connectlife/manifest.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@
55
"config_flow": true,
66
"documentation": "https://github.com/oyvindwe/connectlife-ha",
77
"iot_class": "cloud_polling",
8-
"requirements": ["connectlife==0.5.2"],
9-
"version": "0.20.1"
8+
"requirements": ["connectlife==0.5.3"],
9+
"version": "0.20.2"
1010
}

0 commit comments

Comments
 (0)