mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 13:17:32 +00:00
Fix roomba doing I/O in the event loop (#69339)
This commit is contained in:
parent
caa5b8f96c
commit
e5c1cc35e1
@ -1,5 +1,6 @@
|
|||||||
"""The roomba component."""
|
"""The roomba component."""
|
||||||
import asyncio
|
import asyncio
|
||||||
|
from functools import partial
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
import async_timeout
|
import async_timeout
|
||||||
@ -42,13 +43,16 @@ async def async_setup_entry(hass: HomeAssistant, config_entry: ConfigEntry) -> b
|
|||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
roomba = RoombaFactory.create_roomba(
|
roomba = await hass.async_add_executor_job(
|
||||||
|
partial(
|
||||||
|
RoombaFactory.create_roomba,
|
||||||
address=config_entry.data[CONF_HOST],
|
address=config_entry.data[CONF_HOST],
|
||||||
blid=config_entry.data[CONF_BLID],
|
blid=config_entry.data[CONF_BLID],
|
||||||
password=config_entry.data[CONF_PASSWORD],
|
password=config_entry.data[CONF_PASSWORD],
|
||||||
continuous=config_entry.options[CONF_CONTINUOUS],
|
continuous=config_entry.options[CONF_CONTINUOUS],
|
||||||
delay=config_entry.options[CONF_DELAY],
|
delay=config_entry.options[CONF_DELAY],
|
||||||
)
|
)
|
||||||
|
)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
if not await async_connect_or_timeout(hass, roomba):
|
if not await async_connect_or_timeout(hass, roomba):
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
"""Config flow to configure roomba component."""
|
"""Config flow to configure roomba component."""
|
||||||
|
|
||||||
import asyncio
|
import asyncio
|
||||||
|
from functools import partial
|
||||||
|
|
||||||
from roombapy import RoombaFactory
|
from roombapy import RoombaFactory
|
||||||
from roombapy.discovery import RoombaDiscovery
|
from roombapy.discovery import RoombaDiscovery
|
||||||
@ -41,13 +42,16 @@ async def validate_input(hass: core.HomeAssistant, data):
|
|||||||
|
|
||||||
Data has the keys from DATA_SCHEMA with values provided by the user.
|
Data has the keys from DATA_SCHEMA with values provided by the user.
|
||||||
"""
|
"""
|
||||||
roomba = RoombaFactory.create_roomba(
|
roomba = await hass.async_add_executor_job(
|
||||||
|
partial(
|
||||||
|
RoombaFactory.create_roomba,
|
||||||
address=data[CONF_HOST],
|
address=data[CONF_HOST],
|
||||||
blid=data[CONF_BLID],
|
blid=data[CONF_BLID],
|
||||||
password=data[CONF_PASSWORD],
|
password=data[CONF_PASSWORD],
|
||||||
continuous=False,
|
continuous=False,
|
||||||
delay=data[CONF_DELAY],
|
delay=data[CONF_DELAY],
|
||||||
)
|
)
|
||||||
|
)
|
||||||
|
|
||||||
info = await async_connect_or_timeout(hass, roomba)
|
info = await async_connect_or_timeout(hass, roomba)
|
||||||
if info:
|
if info:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user