Skip to content

Commit d332142

Browse files
committed
Bug fix for #28
1 parent e308945 commit d332142

File tree

1 file changed

+15
-12
lines changed

1 file changed

+15
-12
lines changed

custom_components/wemportal/coordinator.py

+15-12
Original file line numberDiff line numberDiff line change
@@ -41,18 +41,19 @@ async def _async_update_data(self):
4141
try:
4242
return await self.hass.async_add_executor_job(self.api.fetch_data)
4343
except WemPortalError as exc:
44+
# if isinstance(exc.__cause__, (ServerError, ForbiddenError)):
45+
_LOGGER.error("Creating new wemportal api instance")
46+
# TODO: This is a temporary solution and should be removed when api cause from #28 is resolved
47+
try:
48+
new_api = WemPortalApi(
49+
self.config_entry.data.get(CONF_USERNAME),
50+
self.config_entry.data.get(CONF_PASSWORD),
51+
self.config_entry.options,
52+
)
53+
self.api = new_api
54+
except Exception as exc2:
55+
raise UpdateFailed from exc2
4456
if isinstance(exc.__cause__, (ServerError, ForbiddenError)):
45-
_LOGGER.error("Creating new wemportal api instance")
46-
# TODO: This is a temporary solution and should be removed when api cause from #28 is resolved
47-
try:
48-
new_api = WemPortalApi(
49-
self.config_entry.data.get(CONF_USERNAME),
50-
self.config_entry.data.get(CONF_PASSWORD),
51-
self.config_entry.options,
52-
)
53-
self.api = new_api
54-
except Exception as exc2:
55-
raise UpdateFailed from exc2
5657
try:
5758
return await self.hass.async_add_executor_job(
5859
self.api.fetch_data
@@ -63,5 +64,7 @@ async def _async_update_data(self):
6364
)
6465
raise UpdateFailed from exc2
6566
else:
66-
_LOGGER.error("Error fetching data from wemportal", exc_info=exc)
6767
raise UpdateFailed from exc
68+
# else:
69+
# _LOGGER.error("Error fetching data from wemportal", exc_info=exc)
70+
# raise UpdateFailed from exc

0 commit comments

Comments
 (0)