Retry SmartThings setup when the subscription times out (#180495)

This commit is contained in:
Franck Nijhof
2026-08-28 11:31:14 +02:00
committed by GitHub
parent 7dbc17c9a0
commit beb87717d3
2 changed files with 11 additions and 3 deletions
@@ -199,7 +199,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: SmartThingsConfigEntry)
entry.data[CONF_LOCATION_ID],
entry.data[CONF_TOKEN][CONF_INSTALLED_APP_ID],
)
except SmartThingsSinkError as err:
except (SmartThingsConnectionError, SmartThingsSinkError) as err:
_LOGGER.exception("Couldn't create a new subscription")
raise ConfigEntryNotReady from err
subscription_id = subscription.subscription_id
+10 -2
View File
@@ -188,16 +188,24 @@ async def test_create_subscription(
@pytest.mark.parametrize("device_fixture", ["da_ac_rac_000001"])
async def test_create_subscription_sink_error(
@pytest.mark.parametrize(
"error",
[
SmartThingsSinkError("Sink error"),
SmartThingsConnectionError("Timeout occurred while connecting to SmartThings"),
],
)
async def test_create_subscription_error(
hass: HomeAssistant,
devices: AsyncMock,
mock_config_entry: MockConfigEntry,
snapshot: SnapshotAssertion,
error: Exception,
) -> None:
"""Test handling an error when creating a subscription."""
assert CONF_SUBSCRIPTION_ID not in mock_config_entry.data
devices.create_subscription.side_effect = SmartThingsSinkError("Sink error")
devices.create_subscription.side_effect = error
await setup_integration(hass, mock_config_entry)