Skip to content

Commit

Permalink
Non-blocking call to load MyT (#293)
Browse files Browse the repository at this point in the history
* Non-blocking call to load MyT

Load MyT using a non-blocking call in accordance with https://developers.home-assistant.io/docs/asyncio_blocking_operations/#open.

* linting

* linting v2 using poetry

---------

Co-authored-by: Simon Hörrle <7945681+CM000n@users.noreply.github.com>
  • Loading branch information
ajain-93 and CM000n authored Aug 23, 2024
1 parent 4d65ef0 commit ce06bf8
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions custom_components/toyota/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import asyncio.exceptions as asyncioexceptions
import logging
from datetime import timedelta
from functools import partial
from typing import Optional, TypedDict

import httpcore
Expand Down Expand Up @@ -53,9 +54,12 @@ async def async_setup_entry( # pylint: disable=too-many-statements
email = entry.data[CONF_EMAIL]
password = entry.data[CONF_PASSWORD]

client = MyT(
username=email,
password=password,
client = await hass.async_add_executor_job(
partial(
MyT,
username=email,
password=password,
)
)

try:
Expand Down

0 comments on commit ce06bf8

Please sign in to comment.