Skip to content

Commit

Permalink
Handle login error
Browse files Browse the repository at this point in the history
- Bump connectlife to 0.5.3
- Increase timeout for fetching data
- Version 0.20.2
  • Loading branch information
oyvindwe committed Nov 12, 2024
1 parent b0fbce4 commit a7c74fc
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
8 changes: 6 additions & 2 deletions custom_components/connectlife/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@

from __future__ import annotations

from homeassistant.exceptions import ConfigEntryError
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import Platform, CONF_USERNAME, CONF_PASSWORD
from homeassistant.core import HomeAssistant
from connectlife.api import ConnectLifeApi
from connectlife.api import ConnectLifeApi, LifeConnectAuthError

from .const import CONF_DEVELOPMENT_MODE, CONF_TEST_SERVER_URL, DOMAIN
from .coordinator import ConnectLifeCoordinator
Expand All @@ -31,7 +32,10 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
else None
)
api = ConnectLifeApi(entry.data[CONF_USERNAME], entry.data[CONF_PASSWORD], test_server_url)
await api.login()
try:
await api.login()
except LifeConnectAuthError as ex:
raise ConfigEntryError from ex
coordinator = ConnectLifeCoordinator(hass, api)
await coordinator.async_config_entry_first_refresh()
hass.data[DOMAIN][entry.entry_id] = coordinator
Expand Down
2 changes: 1 addition & 1 deletion custom_components/connectlife/coordinator.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ async def _async_update_data(self):
try:
# Note: asyncio.TimeoutError and aiohttp.ClientError are already
# handled by the data update coordinator.
async with async_timeout.timeout(10):
async with async_timeout.timeout(30):
await self.api.get_appliances()
self.error_count = 0
except LifeConnectAuthError as err:
Expand Down
4 changes: 2 additions & 2 deletions custom_components/connectlife/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@
"config_flow": true,
"documentation": "https://github.com/oyvindwe/connectlife-ha",
"iot_class": "cloud_polling",
"requirements": ["connectlife==0.5.2"],
"version": "0.20.1"
"requirements": ["connectlife==0.5.3"],
"version": "0.20.2"
}

0 comments on commit a7c74fc

Please sign in to comment.