diff --git a/homeassistant/components/hr_energy_qube/config_flow.py b/homeassistant/components/hr_energy_qube/config_flow.py index 39d0b318f14a..e0ae08009803 100644 --- a/homeassistant/components/hr_energy_qube/config_flow.py +++ b/homeassistant/components/hr_energy_qube/config_flow.py @@ -22,7 +22,7 @@ async def _async_validate_device(host: str) -> str | None: try: if not await client.connect(): return "cannot_connect" - if await client.async_get_software_version() is None: + if not await client.async_verify_device(): return "not_qube_device" except OSError: return "cannot_connect" diff --git a/homeassistant/components/hr_energy_qube/manifest.json b/homeassistant/components/hr_energy_qube/manifest.json index d5a578b05ba1..07a0157cdbd8 100644 --- a/homeassistant/components/hr_energy_qube/manifest.json +++ b/homeassistant/components/hr_energy_qube/manifest.json @@ -9,7 +9,7 @@ "iot_class": "local_polling", "loggers": ["python_qube_heatpump"], "quality_scale": "silver", - "requirements": ["python-qube-heatpump==1.16.0"], + "requirements": ["python-qube-heatpump==1.17.0"], "zeroconf": [ { "properties": { "ProjectName": "deqsihpb*", "Vendor": "000a5c" }, diff --git a/requirements_all.txt b/requirements_all.txt index e0b83a5240e5..f6cb21290836 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -2797,7 +2797,7 @@ python-picnic-api2==2.0.1 python-pooldose==0.9.10 # homeassistant.components.hr_energy_qube -python-qube-heatpump==1.16.0 +python-qube-heatpump==1.17.0 # homeassistant.components.rabbitair python-rabbitair==0.0.8 diff --git a/tests/components/hr_energy_qube/conftest.py b/tests/components/hr_energy_qube/conftest.py index 98c73d65e42a..538eefddd091 100644 --- a/tests/components/hr_energy_qube/conftest.py +++ b/tests/components/hr_energy_qube/conftest.py @@ -56,6 +56,7 @@ def mock_qube_client() -> Generator[MagicMock]: client.connect = AsyncMock(return_value=True) client.is_connected = True client.close = AsyncMock(return_value=None) + client.async_verify_device = AsyncMock(return_value=True) client.async_get_software_version = AsyncMock(return_value="2.15") state = QubeState() diff --git a/tests/components/hr_energy_qube/test_config_flow.py b/tests/components/hr_energy_qube/test_config_flow.py index b0dd31ccb0d6..6feb6ebd8680 100644 --- a/tests/components/hr_energy_qube/test_config_flow.py +++ b/tests/components/hr_energy_qube/test_config_flow.py @@ -59,11 +59,11 @@ async def test_full_flow( @pytest.mark.parametrize( - ("connect_side_effect", "connect_result", "version_result", "error"), + ("connect_side_effect", "connect_result", "verified", "error"), [ - (None, False, "2.15", "cannot_connect"), - (OSError, None, "2.15", "cannot_connect"), - (None, True, None, "not_qube_device"), + (None, False, True, "cannot_connect"), + (OSError, None, True, "cannot_connect"), + (None, True, False, "not_qube_device"), ], ) @pytest.mark.usefixtures("mock_setup_entry") @@ -72,14 +72,14 @@ async def test_flow_errors( mock_qube_client: MagicMock, connect_side_effect: type[Exception] | None, connect_result: bool | None, - version_result: str | None, + verified: bool, error: str, ) -> None: """Test flow error handling with recovery.""" mock_qube_client.connect = AsyncMock( side_effect=connect_side_effect, return_value=connect_result ) - mock_qube_client.async_get_software_version = AsyncMock(return_value=version_result) + mock_qube_client.async_verify_device = AsyncMock(return_value=verified) result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": SOURCE_USER} @@ -95,7 +95,7 @@ async def test_flow_errors( # Reset mocks for successful retry mock_qube_client.connect = AsyncMock(return_value=True) - mock_qube_client.async_get_software_version = AsyncMock(return_value="2.15") + mock_qube_client.async_verify_device = AsyncMock(return_value=True) result = await hass.config_entries.flow.async_configure( result["flow_id"], @@ -192,10 +192,10 @@ async def test_zeroconf_flow(hass: HomeAssistant, mock_qube_client: MagicMock) - @pytest.mark.parametrize( - ("connect_result", "version_result", "error"), + ("connect_result", "verified", "error"), [ - pytest.param(False, "2.15", "cannot_connect", id="cannot_connect"), - pytest.param(True, None, "not_qube_device", id="not_qube_device"), + pytest.param(False, True, "cannot_connect", id="cannot_connect"), + pytest.param(True, False, "not_qube_device", id="not_qube_device"), ], ) @pytest.mark.usefixtures("mock_setup_entry") @@ -203,12 +203,12 @@ async def test_zeroconf_confirm_errors( hass: HomeAssistant, mock_qube_client: MagicMock, connect_result: bool, - version_result: str | None, + verified: bool, error: str, ) -> None: """Test the confirm step reports Modbus errors and can be retried.""" mock_qube_client.connect = AsyncMock(return_value=connect_result) - mock_qube_client.async_get_software_version = AsyncMock(return_value=version_result) + mock_qube_client.async_verify_device = AsyncMock(return_value=verified) result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": SOURCE_ZEROCONF}, data=ZEROCONF_DISCOVERY @@ -219,7 +219,7 @@ async def test_zeroconf_confirm_errors( assert result["errors"] == {"base": error} mock_qube_client.connect = AsyncMock(return_value=True) - mock_qube_client.async_get_software_version = AsyncMock(return_value="2.15") + mock_qube_client.async_verify_device = AsyncMock(return_value=True) result = await hass.config_entries.flow.async_configure(result["flow_id"], {}) @@ -394,17 +394,17 @@ async def test_reconfigure_host_of_other_entry( @pytest.mark.parametrize( - ("connect_result", "version_result", "error"), + ("connect_result", "verified", "error"), [ - pytest.param(False, "2.15", "cannot_connect", id="cannot_connect"), - pytest.param(True, None, "not_qube_device", id="not_qube_device"), + pytest.param(False, True, "cannot_connect", id="cannot_connect"), + pytest.param(True, False, "not_qube_device", id="not_qube_device"), ], ) async def test_reconfigure_errors( hass: HomeAssistant, mock_qube_client: MagicMock, connect_result: bool, - version_result: str | None, + verified: bool, error: str, ) -> None: """Test reconfigure reports Modbus errors and can be retried.""" @@ -413,7 +413,7 @@ async def test_reconfigure_errors( ) entry.add_to_hass(hass) mock_qube_client.connect = AsyncMock(return_value=connect_result) - mock_qube_client.async_get_software_version = AsyncMock(return_value=version_result) + mock_qube_client.async_verify_device = AsyncMock(return_value=verified) result = await entry.start_reconfigure_flow(hass) result = await hass.config_entries.flow.async_configure( @@ -424,7 +424,7 @@ async def test_reconfigure_errors( assert result["errors"] == {"base": error} mock_qube_client.connect = AsyncMock(return_value=True) - mock_qube_client.async_get_software_version = AsyncMock(return_value="2.15") + mock_qube_client.async_verify_device = AsyncMock(return_value=True) result = await hass.config_entries.flow.async_configure( result["flow_id"], {CONF_HOST: "192.168.5.208"}