diff --git a/homeassistant/components/izone/config_flow.py b/homeassistant/components/izone/config_flow.py index 64fbc531d60e..cd9a942d24fe 100644 --- a/homeassistant/components/izone/config_flow.py +++ b/homeassistant/components/izone/config_flow.py @@ -425,12 +425,6 @@ class IZoneConfigFlow(ConfigFlow, domain=DOMAIN): suggested_values={CONF_HOST: host}, ) - if endpoint is None: - return self._async_show_manual_host_form( - errors={"base": "cannot_connect"}, - suggested_values={CONF_HOST: host}, - ) - if endpoint.uid in izone_discovery.yaml_excluded_uids(self.hass): return self._async_show_manual_host_form( errors={"base": "no_devices_found"}, diff --git a/homeassistant/components/izone/discovery.py b/homeassistant/components/izone/discovery.py index eead68fd0c79..32e9b60b482f 100644 --- a/homeassistant/components/izone/discovery.py +++ b/homeassistant/components/izone/discovery.py @@ -236,7 +236,7 @@ async def async_discover_endpoint( async def async_discover_by_host( hass: HomeAssistant, host: str -) -> pizone.ControllerEndpoint | None: +) -> pizone.ControllerEndpoint: """HTTP-probe a controller at *host* for config-flow validation. Starts shared discovery if needed. diff --git a/homeassistant/components/izone/manifest.json b/homeassistant/components/izone/manifest.json index 3afb4affeecd..4e7c71303d87 100644 --- a/homeassistant/components/izone/manifest.json +++ b/homeassistant/components/izone/manifest.json @@ -13,5 +13,5 @@ "iot_class": "local_polling", "loggers": ["pizone"], "quality_scale": "silver", - "requirements": ["python-izone==2.0.0"] + "requirements": ["python-izone==2.0.1"] } diff --git a/requirements_all.txt b/requirements_all.txt index 4e2a8e993c91..e58085b85c2e 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -2821,7 +2821,7 @@ python-hotspring==4.0.2 python-hpilo==4.4.3 # homeassistant.components.izone -python-izone==2.0.0 +python-izone==2.0.1 # homeassistant.components.joaoapps_join python-join-api==0.1.1 diff --git a/tests/components/izone/conftest.py b/tests/components/izone/conftest.py index 19c717d68a3a..af898290d09c 100644 --- a/tests/components/izone/conftest.py +++ b/tests/components/izone/conftest.py @@ -4,7 +4,14 @@ from collections.abc import AsyncGenerator, Generator, Iterable from contextlib import contextmanager from unittest.mock import AsyncMock, Mock, patch -from pizone import Controller, ControllerEndpoint, DiscoveryService, Zone +from pizone import ( + Controller, + ControllerEndpoint, + DiscoveryService, + EndpointVerifyError, + VerifyFailure, + Zone, +) import pytest from pytest_homeassistant.common import MockConfigEntry @@ -225,10 +232,12 @@ def patch_discovered_controllers( async def _discover_one(hass: HomeAssistant, uid: str) -> ControllerEndpoint | None: return endpoints.get(uid) - async def _discover_by_host( - hass: HomeAssistant, host: str - ) -> ControllerEndpoint | None: - return next((ep for ep in endpoints.values() if ep.host == host), None) + async def _discover_by_host(hass: HomeAssistant, host: str) -> ControllerEndpoint: + if ( + endpoint := next((ep for ep in endpoints.values() if ep.host == host), None) + ) is None: + raise EndpointVerifyError(host, VerifyFailure.NO_REPLY) + return endpoint mock_discover_all = AsyncMock(side_effect=_discover_all) mock_scan = AsyncMock(side_effect=_scan) diff --git a/tests/components/izone/test_config_flow.py b/tests/components/izone/test_config_flow.py index cd75aee39c3a..45755b89eed9 100644 --- a/tests/components/izone/test_config_flow.py +++ b/tests/components/izone/test_config_flow.py @@ -1679,27 +1679,15 @@ async def test_user_manual_host_empty_rejected_by_schema(hass: HomeAssistant) -> @pytest.mark.usefixtures("mock_entry_setup") -@pytest.mark.parametrize( - "lookup", - [ - pytest.param(AsyncMock(return_value=None), id="no-endpoint"), - pytest.param( - AsyncMock( - side_effect=pizone.EndpointVerifyError( - "192.0.2.99", pizone.VerifyFailure.NO_REPLY - ) - ), - id="verify-error", - ), - ], -) -async def test_user_manual_host_unreachable( - hass: HomeAssistant, lookup: AsyncMock -) -> None: +async def test_user_manual_host_unreachable(hass: HomeAssistant) -> None: """Unreachable host redisplays the form with cannot_connect.""" with patch( "homeassistant.components.izone.discovery.async_discover_by_host", - new=lookup, + new=AsyncMock( + side_effect=pizone.EndpointVerifyError( + "192.0.2.99", pizone.VerifyFailure.NO_REPLY + ) + ), ): result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": config_entries.SOURCE_USER} diff --git a/tests/components/izone/test_discovery.py b/tests/components/izone/test_discovery.py index d310f6c19c49..2a00521d16ac 100644 --- a/tests/components/izone/test_discovery.py +++ b/tests/components/izone/test_discovery.py @@ -27,7 +27,6 @@ def _mock_pizone_service() -> Mock: service.close = AsyncMock() service.discover_all = AsyncMock(return_value=[]) service.discover_by_uid = AsyncMock(return_value=None) - service.discover_by_host = AsyncMock(return_value=None) return service