mirror of
https://github.com/home-assistant/core.git
synced 2025-07-15 09:17:10 +00:00
Fix Habitica doing blocking I/O in the event loop (#117647)
This commit is contained in:
parent
3efdeaaa77
commit
2b195cab72
@ -151,12 +151,13 @@ async def async_setup_entry(hass: HomeAssistant, entry: HabiticaConfigEntry) ->
|
|||||||
username = entry.data[CONF_API_USER]
|
username = entry.data[CONF_API_USER]
|
||||||
password = entry.data[CONF_API_KEY]
|
password = entry.data[CONF_API_KEY]
|
||||||
|
|
||||||
api = HAHabitipyAsync(
|
api = await hass.async_add_executor_job(
|
||||||
|
HAHabitipyAsync,
|
||||||
{
|
{
|
||||||
"url": url,
|
"url": url,
|
||||||
"login": username,
|
"login": username,
|
||||||
"password": password,
|
"password": password,
|
||||||
}
|
},
|
||||||
)
|
)
|
||||||
try:
|
try:
|
||||||
user = await api.user.get(userFields="profile")
|
user = await api.user.get(userFields="profile")
|
||||||
|
@ -33,12 +33,13 @@ async def validate_input(hass: HomeAssistant, data: dict[str, str]) -> dict[str,
|
|||||||
"""Validate the user input allows us to connect."""
|
"""Validate the user input allows us to connect."""
|
||||||
|
|
||||||
websession = async_get_clientsession(hass)
|
websession = async_get_clientsession(hass)
|
||||||
api = HabitipyAsync(
|
api = await hass.async_add_executor_job(
|
||||||
conf={
|
HabitipyAsync,
|
||||||
|
{
|
||||||
"login": data[CONF_API_USER],
|
"login": data[CONF_API_USER],
|
||||||
"password": data[CONF_API_KEY],
|
"password": data[CONF_API_KEY],
|
||||||
"url": data[CONF_URL] or DEFAULT_URL,
|
"url": data[CONF_URL] or DEFAULT_URL,
|
||||||
}
|
},
|
||||||
)
|
)
|
||||||
try:
|
try:
|
||||||
await api.user.get(session=websession)
|
await api.user.get(session=websession)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user