Skip to content

Commit

Permalink
fixed some sync/async problems
Browse files Browse the repository at this point in the history
  • Loading branch information
rine77 committed Nov 27, 2024
1 parent e5950d5 commit 93ece01
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 1 addition & 3 deletions custom_components/homeassistantedupage/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
coordinator = None

try:
await hass.async_add_executor_job(
edupage.login, username, password, subdomain
)
await edupage.login(username, password, subdomain)
_LOGGER.debug("INIT login_success")

except BadCredentialsException as e:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,14 @@ async def login(self, username: str, password: str, subdomain: str):
try:
result = True
login = Login(self.api)
await asyncio.to_thread(
await self.hass.async_add_executor_job(
login.reload_data, subdomain, self.sessionid, username
)
if not self.api.is_logged_in:
#TODO: how to handle 2FA at this point?!
result = await asyncio.to_thread(self.api.login, username, password, subdomain)
result = await self.hass.async_add_executor_job(
self.api.login, username, password, subdomain
)
_LOGGER.debug(f"EDUPAGE Login successful, result: {result}")
return result
except BadCredentialsException as e:
Expand Down

0 comments on commit 93ece01

Please sign in to comment.