Change monoprice config flow to sync (#75306)

pull/75758/head
On Freund 2022-07-26 07:24:39 +03:00 committed by Franck Nijhof
parent a3950937e0
commit ec4835ef04
No known key found for this signature in database
GPG Key ID: D62583BA8AB11CA3
2 changed files with 5 additions and 5 deletions

View File

@ -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

View File

@ -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(