From 4531ed56342b139ba1c1e73fcaba7c27fae9b88e Mon Sep 17 00:00:00 2001 From: derekcentrico <1930094+derekcentrico@users.noreply.github.com> Date: Mon, 14 Sep 2026 15:42:17 -0400 Subject: [PATCH] Bump asyncsleepiq to 1.7.2 (#182224) --- homeassistant/components/sleepiq/__init__.py | 5 +++++ homeassistant/components/sleepiq/config_flow.py | 9 ++++++++- homeassistant/components/sleepiq/manifest.json | 2 +- requirements_all.txt | 2 +- tests/components/sleepiq/test_init.py | 13 +++++++++++++ 5 files changed, 28 insertions(+), 3 deletions(-) diff --git a/homeassistant/components/sleepiq/__init__.py b/homeassistant/components/sleepiq/__init__.py index ef648cd624b6..57e2d536eb0f 100644 --- a/homeassistant/components/sleepiq/__init__.py +++ b/homeassistant/components/sleepiq/__init__.py @@ -7,6 +7,7 @@ from asyncsleepiq import ( AsyncSleepIQ, SleepIQAPIException, SleepIQBed, + SleepIQConnectionException, SleepIQLoginException, SleepIQTimeoutException, ) @@ -76,6 +77,10 @@ async def async_setup_entry(hass: HomeAssistant, entry: SleepIQConfigEntry) -> b try: await gateway.login(email, password) + except SleepIQConnectionException as err: + raise ConfigEntryNotReady( + str(err) or "Transient connection failure during authentication" + ) from err except SleepIQLoginException as err: _LOGGER.error("Could not authenticate with SleepIQ server") raise ConfigEntryAuthFailed(err) from err diff --git a/homeassistant/components/sleepiq/config_flow.py b/homeassistant/components/sleepiq/config_flow.py index 4e8213a370cf..90973327490f 100644 --- a/homeassistant/components/sleepiq/config_flow.py +++ b/homeassistant/components/sleepiq/config_flow.py @@ -4,7 +4,12 @@ from collections.abc import Mapping import logging from typing import Any, override -from asyncsleepiq import AsyncSleepIQ, SleepIQLoginException, SleepIQTimeoutException +from asyncsleepiq import ( + AsyncSleepIQ, + SleepIQConnectionException, + SleepIQLoginException, + SleepIQTimeoutException, +) import probatio from homeassistant.config_entries import ConfigFlow, ConfigFlowResult @@ -116,6 +121,8 @@ async def try_connection(hass: HomeAssistant, user_input: dict[str, Any]) -> str gateway = AsyncSleepIQ(client_session=client_session) try: await gateway.login(user_input[CONF_USERNAME], user_input[CONF_PASSWORD]) + except SleepIQConnectionException: + return "cannot_connect" except SleepIQLoginException: return "invalid_auth" except SleepIQTimeoutException: diff --git a/homeassistant/components/sleepiq/manifest.json b/homeassistant/components/sleepiq/manifest.json index 9cecbfbbcec5..d8a99edc2d23 100644 --- a/homeassistant/components/sleepiq/manifest.json +++ b/homeassistant/components/sleepiq/manifest.json @@ -12,5 +12,5 @@ "integration_type": "hub", "iot_class": "cloud_polling", "loggers": ["asyncsleepiq"], - "requirements": ["asyncsleepiq==1.7.1"] + "requirements": ["asyncsleepiq==1.7.2"] } diff --git a/requirements_all.txt b/requirements_all.txt index df87c68da18f..481ff86b2486 100644 --- a/requirements_all.txt +++ b/requirements_all.txt @@ -603,7 +603,7 @@ asyncinotify==4.4.4 asyncpysupla==0.0.5 # homeassistant.components.sleepiq -asyncsleepiq==1.7.1 +asyncsleepiq==1.7.2 # homeassistant.components.sftp_storage asyncssh==2.23.1 diff --git a/tests/components/sleepiq/test_init.py b/tests/components/sleepiq/test_init.py index 51e6c303718b..2120ce0e1d07 100644 --- a/tests/components/sleepiq/test_init.py +++ b/tests/components/sleepiq/test_init.py @@ -10,6 +10,7 @@ from asyncsleepiq import ( SleepData, SleepIQAPIException, SleepIQBed, + SleepIQConnectionException, SleepIQFoundation, SleepIQLoginException, SleepIQSleeper, @@ -82,6 +83,18 @@ async def test_entry_setup_timeout_error( assert not await hass.config_entries.async_setup(entry.entry_id) +async def test_entry_setup_connection_error( + hass: HomeAssistant, mock_asyncsleepiq: MagicMock +) -> None: + """Test that a transient connection failure retries instead of triggering reauth.""" + mock_asyncsleepiq.login.side_effect = SleepIQConnectionException( + "Connection failure: DNS resolution failed" + ) + entry = await setup_platform(hass, None) + assert not await hass.config_entries.async_setup(entry.entry_id) + assert entry.state is ConfigEntryState.SETUP_RETRY + + async def test_update_interval(hass: HomeAssistant, mock_asyncsleepiq) -> None: """Test update interval.""" await setup_platform(hass, "sensor")