From 2d1d9e9e203f1f049cdee27dbcb1279230275b39 Mon Sep 17 00:00:00 2001 From: Matthias Lohr Date: Sun, 28 Nov 2021 16:50:57 +0100 Subject: [PATCH] Address late review of tolo integration (#60453) * improvements requested by @MartinHjelmare * addressed requested changes * more improvements --- homeassistant/components/tolo/__init__.py | 4 ++-- homeassistant/components/tolo/config_flow.py | 2 +- homeassistant/components/tolo/strings.json | 1 - homeassistant/components/tolo/translations/en.json | 3 +-- tests/components/tolo/test_config_flow.py | 4 +--- 5 files changed, 5 insertions(+), 9 deletions(-) diff --git a/homeassistant/components/tolo/__init__.py b/homeassistant/components/tolo/__init__.py index 3776c4bd61c..666e86c951b 100644 --- a/homeassistant/components/tolo/__init__.py +++ b/homeassistant/components/tolo/__init__.py @@ -64,7 +64,7 @@ class ToloSaunaUpdateCoordinator(DataUpdateCoordinator[ToloSaunaData]): hass=hass, logger=_LOGGER, name=f"{entry.title} ({entry.data[CONF_HOST]}) Data Update Coordinator", - update_interval=timedelta(seconds=3), + update_interval=timedelta(seconds=5), ) async def _async_update_data(self) -> ToloSaunaData: @@ -78,9 +78,9 @@ class ToloSaunaUpdateCoordinator(DataUpdateCoordinator[ToloSaunaData]): settings = self.client.get_settings_info( resend_timeout=DEFAULT_RETRY_TIMEOUT, retries=DEFAULT_RETRY_COUNT ) - return ToloSaunaData(status, settings) except ResponseTimedOutError as error: raise UpdateFailed("communication timeout") from error + return ToloSaunaData(status, settings) class ToloSaunaCoordinatorEntity(CoordinatorEntity): diff --git a/homeassistant/components/tolo/config_flow.py b/homeassistant/components/tolo/config_flow.py index 4503fd511ba..24708580d20 100644 --- a/homeassistant/components/tolo/config_flow.py +++ b/homeassistant/components/tolo/config_flow.py @@ -35,9 +35,9 @@ class ToloSaunaConfigFlow(ConfigFlow, domain=DOMAIN): result = client.get_status_info( resend_timeout=DEFAULT_RETRY_TIMEOUT, retries=DEFAULT_RETRY_COUNT ) - return result is not None except ResponseTimedOutError: return False + return result is not None async def async_step_user( self, user_input: dict[str, Any] | None = None diff --git a/homeassistant/components/tolo/strings.json b/homeassistant/components/tolo/strings.json index f9316f4d72b..0a81dad73f6 100644 --- a/homeassistant/components/tolo/strings.json +++ b/homeassistant/components/tolo/strings.json @@ -16,7 +16,6 @@ "cannot_connect": "[%key:common::config_flow::error::cannot_connect%]" }, "abort": { - "no_devices_found": "[%key:common::config_flow::abort::no_devices_found%]", "already_configured": "[%key:common::config_flow::abort::already_configured_device%]" } } diff --git a/homeassistant/components/tolo/translations/en.json b/homeassistant/components/tolo/translations/en.json index 488c2f7ae69..dea5a3b30df 100644 --- a/homeassistant/components/tolo/translations/en.json +++ b/homeassistant/components/tolo/translations/en.json @@ -1,8 +1,7 @@ { "config": { "abort": { - "already_configured": "Device is already configured", - "no_devices_found": "No devices found on the network" + "already_configured": "Device is already configured" }, "error": { "cannot_connect": "Failed to connect" diff --git a/tests/components/tolo/test_config_flow.py b/tests/components/tolo/test_config_flow.py index 6634d444bce..df9134b4dbd 100644 --- a/tests/components/tolo/test_config_flow.py +++ b/tests/components/tolo/test_config_flow.py @@ -27,9 +27,7 @@ def toloclient_fixture() -> Mock: async def test_user_with_timed_out_host(hass: HomeAssistant, toloclient: Mock): """Test a user initiated config flow with provided host which times out.""" - toloclient().get_status_info.side_effect = lambda *args, **kwargs: ( - _ for _ in () - ).throw(ResponseTimedOutError()) + toloclient().get_status_info.side_effect = ResponseTimedOutError() result = await hass.config_entries.flow.async_init( DOMAIN,