mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 13:17:32 +00:00
Address late review of tolo integration (#60453)
* improvements requested by @MartinHjelmare * addressed requested changes * more improvements
This commit is contained in:
parent
bae01ca7d8
commit
2d1d9e9e20
@ -64,7 +64,7 @@ class ToloSaunaUpdateCoordinator(DataUpdateCoordinator[ToloSaunaData]):
|
|||||||
hass=hass,
|
hass=hass,
|
||||||
logger=_LOGGER,
|
logger=_LOGGER,
|
||||||
name=f"{entry.title} ({entry.data[CONF_HOST]}) Data Update Coordinator",
|
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:
|
async def _async_update_data(self) -> ToloSaunaData:
|
||||||
@ -78,9 +78,9 @@ class ToloSaunaUpdateCoordinator(DataUpdateCoordinator[ToloSaunaData]):
|
|||||||
settings = self.client.get_settings_info(
|
settings = self.client.get_settings_info(
|
||||||
resend_timeout=DEFAULT_RETRY_TIMEOUT, retries=DEFAULT_RETRY_COUNT
|
resend_timeout=DEFAULT_RETRY_TIMEOUT, retries=DEFAULT_RETRY_COUNT
|
||||||
)
|
)
|
||||||
return ToloSaunaData(status, settings)
|
|
||||||
except ResponseTimedOutError as error:
|
except ResponseTimedOutError as error:
|
||||||
raise UpdateFailed("communication timeout") from error
|
raise UpdateFailed("communication timeout") from error
|
||||||
|
return ToloSaunaData(status, settings)
|
||||||
|
|
||||||
|
|
||||||
class ToloSaunaCoordinatorEntity(CoordinatorEntity):
|
class ToloSaunaCoordinatorEntity(CoordinatorEntity):
|
||||||
|
@ -35,9 +35,9 @@ class ToloSaunaConfigFlow(ConfigFlow, domain=DOMAIN):
|
|||||||
result = client.get_status_info(
|
result = client.get_status_info(
|
||||||
resend_timeout=DEFAULT_RETRY_TIMEOUT, retries=DEFAULT_RETRY_COUNT
|
resend_timeout=DEFAULT_RETRY_TIMEOUT, retries=DEFAULT_RETRY_COUNT
|
||||||
)
|
)
|
||||||
return result is not None
|
|
||||||
except ResponseTimedOutError:
|
except ResponseTimedOutError:
|
||||||
return False
|
return False
|
||||||
|
return result is not None
|
||||||
|
|
||||||
async def async_step_user(
|
async def async_step_user(
|
||||||
self, user_input: dict[str, Any] | None = None
|
self, user_input: dict[str, Any] | None = None
|
||||||
|
@ -16,7 +16,6 @@
|
|||||||
"cannot_connect": "[%key:common::config_flow::error::cannot_connect%]"
|
"cannot_connect": "[%key:common::config_flow::error::cannot_connect%]"
|
||||||
},
|
},
|
||||||
"abort": {
|
"abort": {
|
||||||
"no_devices_found": "[%key:common::config_flow::abort::no_devices_found%]",
|
|
||||||
"already_configured": "[%key:common::config_flow::abort::already_configured_device%]"
|
"already_configured": "[%key:common::config_flow::abort::already_configured_device%]"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
{
|
{
|
||||||
"config": {
|
"config": {
|
||||||
"abort": {
|
"abort": {
|
||||||
"already_configured": "Device is already configured",
|
"already_configured": "Device is already configured"
|
||||||
"no_devices_found": "No devices found on the network"
|
|
||||||
},
|
},
|
||||||
"error": {
|
"error": {
|
||||||
"cannot_connect": "Failed to connect"
|
"cannot_connect": "Failed to connect"
|
||||||
|
@ -27,9 +27,7 @@ def toloclient_fixture() -> Mock:
|
|||||||
|
|
||||||
async def test_user_with_timed_out_host(hass: HomeAssistant, toloclient: 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."""
|
"""Test a user initiated config flow with provided host which times out."""
|
||||||
toloclient().get_status_info.side_effect = lambda *args, **kwargs: (
|
toloclient().get_status_info.side_effect = ResponseTimedOutError()
|
||||||
_ for _ in ()
|
|
||||||
).throw(ResponseTimedOutError())
|
|
||||||
|
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN,
|
DOMAIN,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user