Remove blocking I/O from the event loop (#28305)
This commit is contained in:
parent
0e4331e922
commit
a0f764cf6d
5 changed files with 5 additions and 5 deletions
|
@ -445,7 +445,7 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info=
|
||||||
if model is None:
|
if model is None:
|
||||||
try:
|
try:
|
||||||
miio_device = Device(host, token)
|
miio_device = Device(host, token)
|
||||||
device_info = miio_device.info()
|
device_info = await hass.async_add_executor_job(miio_device.info)
|
||||||
model = device_info.model
|
model = device_info.model
|
||||||
unique_id = f"{model}-{device_info.mac_address}"
|
unique_id = f"{model}-{device_info.mac_address}"
|
||||||
_LOGGER.info(
|
_LOGGER.info(
|
||||||
|
|
|
@ -134,7 +134,7 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info=
|
||||||
if model is None:
|
if model is None:
|
||||||
try:
|
try:
|
||||||
miio_device = Device(host, token)
|
miio_device = Device(host, token)
|
||||||
device_info = miio_device.info()
|
device_info = await hass.async_add_executor_job(miio_device.info)
|
||||||
model = device_info.model
|
model = device_info.model
|
||||||
unique_id = f"{model}-{device_info.mac_address}"
|
unique_id = f"{model}-{device_info.mac_address}"
|
||||||
_LOGGER.info(
|
_LOGGER.info(
|
||||||
|
|
|
@ -88,7 +88,7 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info=
|
||||||
|
|
||||||
# Check that we can communicate with device.
|
# Check that we can communicate with device.
|
||||||
try:
|
try:
|
||||||
device_info = device.info()
|
device_info = await hass.async_add_executor_job(device.info)
|
||||||
model = device_info.model
|
model = device_info.model
|
||||||
unique_id = f"{model}-{device_info.mac_address}"
|
unique_id = f"{model}-{device_info.mac_address}"
|
||||||
_LOGGER.info(
|
_LOGGER.info(
|
||||||
|
|
|
@ -50,7 +50,7 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info=
|
||||||
|
|
||||||
try:
|
try:
|
||||||
air_quality_monitor = AirQualityMonitor(host, token)
|
air_quality_monitor = AirQualityMonitor(host, token)
|
||||||
device_info = air_quality_monitor.info()
|
device_info = await hass.async_add_executor_job(air_quality_monitor.info)
|
||||||
model = device_info.model
|
model = device_info.model
|
||||||
unique_id = f"{model}-{device_info.mac_address}"
|
unique_id = f"{model}-{device_info.mac_address}"
|
||||||
_LOGGER.info(
|
_LOGGER.info(
|
||||||
|
|
|
@ -120,7 +120,7 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info=
|
||||||
if model is None:
|
if model is None:
|
||||||
try:
|
try:
|
||||||
miio_device = Device(host, token)
|
miio_device = Device(host, token)
|
||||||
device_info = miio_device.info()
|
device_info = await hass.async_add_executor_job(miio_device.info)
|
||||||
model = device_info.model
|
model = device_info.model
|
||||||
unique_id = f"{model}-{device_info.mac_address}"
|
unique_id = f"{model}-{device_info.mac_address}"
|
||||||
_LOGGER.info(
|
_LOGGER.info(
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue