Skip to content

Commit

Permalink
Non-blocking call to load MyT
Browse files Browse the repository at this point in the history
Load MyT using a non-blocking call in accordance with https://developers.home-assistant.io/docs/asyncio_blocking_operations/#open.
  • Loading branch information
ajain-93 authored Aug 21, 2024
1 parent 56ad0d0 commit fc5f8cb
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions custom_components/toyota/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

import asyncio
import asyncio.exceptions as asyncioexceptions
from functools import partial
import logging
from datetime import timedelta
from typing import Optional, TypedDict
Expand Down Expand Up @@ -53,10 +54,11 @@ async def async_setup_entry( # pylint: disable=too-many-statements
email = entry.data[CONF_EMAIL]
password = entry.data[CONF_PASSWORD]

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

try:
await client.login()
Expand Down

0 comments on commit fc5f8cb

Please sign in to comment.