diff --git a/homeassistant/components/monoprice/config_flow.py b/homeassistant/components/monoprice/config_flow.py index 4065b003ba3..9c659d4f733 100644 --- a/homeassistant/components/monoprice/config_flow.py +++ b/homeassistant/components/monoprice/config_flow.py @@ -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 diff --git a/tests/components/monoprice/test_config_flow.py b/tests/components/monoprice/test_config_flow.py index 0ed4ac35eaa..98275b052e4 100644 --- a/tests/components/monoprice/test_config_flow.py +++ b/tests/components/monoprice/test_config_flow.py @@ -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(