parent
3a2beb2212
commit
75aea68b75
|
@ -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(
|
||||
|
|
|
@ -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)
|
||||
|
||||
|
|
|
@ -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",
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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()
|
||||
|
||||
|
|
|
@ -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()
|
||||
|
|
Loading…
Reference in New Issue