diff --git a/homeassistant/components/opentherm_gw/__init__.py b/homeassistant/components/opentherm_gw/__init__.py index 5ec8c6420d5..0d01550df22 100644 --- a/homeassistant/components/opentherm_gw/__init__.py +++ b/homeassistant/components/opentherm_gw/__init__.py @@ -416,7 +416,7 @@ class OpenThermGatewayDevice: self.status = {} self.update_signal = f"{DATA_OPENTHERM_GW}_{self.gw_id}_update" self.options_update_signal = f"{DATA_OPENTHERM_GW}_{self.gw_id}_options_update" - self.gateway = pyotgw.pyotgw() + self.gateway = pyotgw.OpenThermGateway() self.gw_version = None async def cleanup(self, event=None): @@ -427,7 +427,7 @@ class OpenThermGatewayDevice: async def connect_and_subscribe(self): """Connect to serial device and subscribe report handler.""" - self.status = await self.gateway.connect(self.hass.loop, self.device_path) + self.status = await self.gateway.connect(self.device_path) version_string = self.status[gw_vars.OTGW].get(gw_vars.OTGW_ABOUT) self.gw_version = version_string[18:] if version_string else None _LOGGER.debug( diff --git a/homeassistant/components/opentherm_gw/config_flow.py b/homeassistant/components/opentherm_gw/config_flow.py index 1d66d6e2069..3f91496adab 100644 --- a/homeassistant/components/opentherm_gw/config_flow.py +++ b/homeassistant/components/opentherm_gw/config_flow.py @@ -59,8 +59,8 @@ class OpenThermGwConfigFlow(config_entries.ConfigFlow, domain=DOMAIN): async def test_connection(): """Try to connect to the OpenTherm Gateway.""" - otgw = pyotgw.pyotgw() - status = await otgw.connect(self.hass.loop, device) + otgw = pyotgw.OpenThermGateway() + status = await otgw.connect(device) await otgw.disconnect() return status[gw_vars.OTGW].get(gw_vars.OTGW_ABOUT) diff --git a/homeassistant/components/opentherm_gw/manifest.json b/homeassistant/components/opentherm_gw/manifest.json index 7aa19224020..dfb60413721 100644 --- a/homeassistant/components/opentherm_gw/manifest.json +++ b/homeassistant/components/opentherm_gw/manifest.json @@ -2,7 +2,7 @@ "domain": "opentherm_gw", "name": "OpenTherm Gateway", "documentation": "https://www.home-assistant.io/integrations/opentherm_gw", - "requirements": ["pyotgw==1.1b1"], + "requirements": ["pyotgw==2.0.0"], "codeowners": ["@mvn23"], "config_flow": true, "iot_class": "local_push", diff --git a/requirements_all.txt b/requirements_all.txt index 23b672581e8..db0107a90cc 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -1715,7 +1715,7 @@ pyopnsense==0.2.0 pyoppleio==1.0.5 # homeassistant.components.opentherm_gw -pyotgw==1.1b1 +pyotgw==2.0.0 # homeassistant.auth.mfa_modules.notify # homeassistant.auth.mfa_modules.totp diff --git a/requirements_test_all.txt b/requirements_test_all.txt index 8540cf41520..66dae65c33e 100644 --- a/requirements_test_all.txt +++ b/requirements_test_all.txt @@ -1167,7 +1167,7 @@ pyopenuv==2022.04.0 pyopnsense==0.2.0 # homeassistant.components.opentherm_gw -pyotgw==1.1b1 +pyotgw==2.0.0 # homeassistant.auth.mfa_modules.notify # homeassistant.auth.mfa_modules.totp diff --git a/tests/components/opentherm_gw/test_config_flow.py b/tests/components/opentherm_gw/test_config_flow.py index 99133cf17c3..344b21e4471 100644 --- a/tests/components/opentherm_gw/test_config_flow.py +++ b/tests/components/opentherm_gw/test_config_flow.py @@ -43,10 +43,12 @@ async def test_form_user(hass): "homeassistant.components.opentherm_gw.async_setup_entry", return_value=True, ) as mock_setup_entry, patch( - "pyotgw.pyotgw.connect", return_value=MINIMAL_STATUS + "pyotgw.OpenThermGateway.connect", return_value=MINIMAL_STATUS ) as mock_pyotgw_connect, patch( - "pyotgw.pyotgw.disconnect", return_value=None - ) as mock_pyotgw_disconnect: + "pyotgw.OpenThermGateway.disconnect", return_value=None + ) as mock_pyotgw_disconnect, patch( + "pyotgw.status.StatusManager._process_updates", return_value=None + ): result2 = await hass.config_entries.flow.async_configure( result["flow_id"], {CONF_NAME: "Test Entry 1", CONF_DEVICE: "/dev/ttyUSB0"} ) @@ -75,10 +77,12 @@ async def test_form_import(hass): "homeassistant.components.opentherm_gw.async_setup_entry", return_value=True, ) as mock_setup_entry, patch( - "pyotgw.pyotgw.connect", return_value=MINIMAL_STATUS + "pyotgw.OpenThermGateway.connect", return_value=MINIMAL_STATUS ) as mock_pyotgw_connect, patch( - "pyotgw.pyotgw.disconnect", return_value=None - ) as mock_pyotgw_disconnect: + "pyotgw.OpenThermGateway.disconnect", return_value=None + ) as mock_pyotgw_disconnect, patch( + "pyotgw.status.StatusManager._process_updates", return_value=None + ): result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": config_entries.SOURCE_IMPORT}, @@ -117,10 +121,12 @@ async def test_form_duplicate_entries(hass): "homeassistant.components.opentherm_gw.async_setup_entry", return_value=True, ) as mock_setup_entry, patch( - "pyotgw.pyotgw.connect", return_value=MINIMAL_STATUS + "pyotgw.OpenThermGateway.connect", return_value=MINIMAL_STATUS ) as mock_pyotgw_connect, patch( - "pyotgw.pyotgw.disconnect", return_value=None - ) as mock_pyotgw_disconnect: + "pyotgw.OpenThermGateway.disconnect", return_value=None + ) as mock_pyotgw_disconnect, patch( + "pyotgw.status.StatusManager._process_updates", return_value=None + ): result1 = await hass.config_entries.flow.async_configure( flow1["flow_id"], {CONF_NAME: "Test Entry 1", CONF_DEVICE: "/dev/ttyUSB0"} ) @@ -148,8 +154,10 @@ async def test_form_connection_timeout(hass): ) with patch( - "pyotgw.pyotgw.connect", side_effect=(asyncio.TimeoutError) - ) as mock_connect: + "pyotgw.OpenThermGateway.connect", side_effect=(asyncio.TimeoutError) + ) as mock_connect, patch( + "pyotgw.status.StatusManager._process_updates", return_value=None + ): result2 = await hass.config_entries.flow.async_configure( result["flow_id"], {CONF_NAME: "Test Entry 1", CONF_DEVICE: "socket://192.0.2.254:1234"}, @@ -166,7 +174,11 @@ async def test_form_connection_error(hass): DOMAIN, context={"source": config_entries.SOURCE_USER} ) - with patch("pyotgw.pyotgw.connect", side_effect=(SerialException)) as mock_connect: + with patch( + "pyotgw.OpenThermGateway.connect", side_effect=(SerialException) + ) as mock_connect, patch( + "pyotgw.status.StatusManager._process_updates", return_value=None + ): result2 = await hass.config_entries.flow.async_configure( result["flow_id"], {CONF_NAME: "Test Entry 1", CONF_DEVICE: "/dev/ttyUSB0"} ) @@ -196,7 +208,11 @@ async def test_options_migration(hass): with patch( "homeassistant.components.opentherm_gw.OpenThermGatewayDevice.connect_and_subscribe", return_value=True, - ), patch("homeassistant.components.opentherm_gw.async_setup", return_value=True): + ), patch( + "homeassistant.components.opentherm_gw.async_setup", return_value=True + ), patch( + "pyotgw.status.StatusManager._process_updates", return_value=None + ): await hass.config_entries.async_setup(entry.entry_id) await hass.async_block_till_done() diff --git a/tests/components/opentherm_gw/test_init.py b/tests/components/opentherm_gw/test_init.py index 554f58fd81b..7e16805c683 100644 --- a/tests/components/opentherm_gw/test_init.py +++ b/tests/components/opentherm_gw/test_init.py @@ -34,7 +34,7 @@ async def test_device_registry_insert(hass): with patch( "homeassistant.components.opentherm_gw.OpenThermGatewayDevice.cleanup", return_value=None, - ), patch("pyotgw.pyotgw.connect", return_value=MINIMAL_STATUS): + ), patch("pyotgw.OpenThermGateway.connect", return_value=MINIMAL_STATUS): await setup.async_setup_component(hass, DOMAIN, {}) await hass.async_block_till_done() @@ -62,7 +62,7 @@ async def test_device_registry_update(hass): with patch( "homeassistant.components.opentherm_gw.OpenThermGatewayDevice.cleanup", return_value=None, - ), patch("pyotgw.pyotgw.connect", return_value=MINIMAL_STATUS_UPD): + ), patch("pyotgw.OpenThermGateway.connect", return_value=MINIMAL_STATUS_UPD): await setup.async_setup_component(hass, DOMAIN, {}) await hass.async_block_till_done()