Skip to content

Commit

Permalink
Add executor calls
Browse files Browse the repository at this point in the history
  • Loading branch information
drc38 authored Jun 9, 2024
1 parent 15ef13b commit af967c0
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions custom_components/evnex/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry):
password = entry.data[CONF_PASSWORD]

# Load tokens from storage
evnex_auth_tokens = retrieve_evnex_auth_tokens(hass, entry)
evnex_auth_tokens = await hass.async_add_executor_job(retrieve_evnex_auth_tokens, hass, entry)
evnex_auth_tokens = {} if evnex_auth_tokens is None else evnex_auth_tokens

httpx_client = get_async_client(hass)
Expand Down Expand Up @@ -147,7 +147,8 @@ async def async_update_data(is_retry: bool = False):

account: EvnexUserDetail = await evnex_client.get_user_detail()

persist_evnex_auth_tokens(
await hass.async_add_executor_job(
persist_evnex_auth_tokens,
hass,
entry,
evnex_client.id_token,
Expand Down Expand Up @@ -226,7 +227,8 @@ async def async_update_data(is_retry: bool = False):
if not is_retry:
_LOGGER.debug("Refreshing auth and trying again")
await hass.async_add_executor_job(evnex_client.authenticate)
persist_evnex_auth_tokens(
await hass.async_add_executor_job(
persist_evnex_auth_tokens,
hass,
entry,
evnex_client.id_token,
Expand Down

0 comments on commit af967c0

Please sign in to comment.