Change monoprice config flow to sync (#75306)
parent
a3950937e0
commit
ec4835ef04
|
@ -3,7 +3,7 @@ from __future__ import annotations
|
|||
|
||||
import logging
|
||||
|
||||
from pymonoprice import get_async_monoprice
|
||||
from pymonoprice import get_monoprice
|
||||
from serial import SerialException
|
||||
import voluptuous as vol
|
||||
|
||||
|
@ -56,7 +56,7 @@ async def validate_input(hass: core.HomeAssistant, data):
|
|||
Data has the keys from DATA_SCHEMA with values provided by the user.
|
||||
"""
|
||||
try:
|
||||
await get_async_monoprice(data[CONF_PORT], hass.loop)
|
||||
await hass.async_add_executor_job(get_monoprice, data[CONF_PORT])
|
||||
except SerialException as err:
|
||||
_LOGGER.error("Error connecting to Monoprice controller")
|
||||
raise CannotConnect from err
|
||||
|
|
|
@ -33,7 +33,7 @@ async def test_form(hass):
|
|||
assert result["errors"] == {}
|
||||
|
||||
with patch(
|
||||
"homeassistant.components.monoprice.config_flow.get_async_monoprice",
|
||||
"homeassistant.components.monoprice.config_flow.get_monoprice",
|
||||
return_value=True,
|
||||
), patch(
|
||||
"homeassistant.components.monoprice.async_setup_entry",
|
||||
|
@ -60,7 +60,7 @@ async def test_form_cannot_connect(hass):
|
|||
)
|
||||
|
||||
with patch(
|
||||
"homeassistant.components.monoprice.config_flow.get_async_monoprice",
|
||||
"homeassistant.components.monoprice.config_flow.get_monoprice",
|
||||
side_effect=SerialException,
|
||||
):
|
||||
result2 = await hass.config_entries.flow.async_configure(
|
||||
|
@ -78,7 +78,7 @@ async def test_generic_exception(hass):
|
|||
)
|
||||
|
||||
with patch(
|
||||
"homeassistant.components.monoprice.config_flow.get_async_monoprice",
|
||||
"homeassistant.components.monoprice.config_flow.get_monoprice",
|
||||
side_effect=Exception,
|
||||
):
|
||||
result2 = await hass.config_entries.flow.async_configure(
|
||||
|
|
Loading…
Reference in New Issue