Increase sleep in Risco setup (#77619)
This commit is contained in:
parent
93a8aef4cc
commit
1692808d5b
8 changed files with 10 additions and 16 deletions
|
@ -154,6 +154,10 @@ async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
|||
"""Unload a config entry."""
|
||||
unload_ok = await hass.config_entries.async_unload_platforms(entry, PLATFORMS)
|
||||
if unload_ok:
|
||||
if is_local(entry):
|
||||
local_data: LocalData = hass.data[DOMAIN][entry.entry_id]
|
||||
await local_data.system.disconnect()
|
||||
|
||||
hass.data[DOMAIN].pop(entry.entry_id)
|
||||
|
||||
return unload_ok
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
"""Config flow for Risco integration."""
|
||||
from __future__ import annotations
|
||||
|
||||
import asyncio
|
||||
from collections.abc import Mapping
|
||||
import logging
|
||||
|
||||
|
@ -32,7 +31,6 @@ from .const import (
|
|||
DEFAULT_OPTIONS,
|
||||
DOMAIN,
|
||||
RISCO_STATES,
|
||||
SLEEP_INTERVAL,
|
||||
TYPE_LOCAL,
|
||||
)
|
||||
|
||||
|
@ -150,9 +148,6 @@ class ConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
|||
await self.async_set_unique_id(info["title"])
|
||||
self._abort_if_unique_id_configured()
|
||||
|
||||
# Risco can hang if we don't wait before creating a new connection
|
||||
await asyncio.sleep(SLEEP_INTERVAL)
|
||||
|
||||
return self.async_create_entry(
|
||||
title=info["title"], data={**user_input, **{CONF_TYPE: TYPE_LOCAL}}
|
||||
)
|
||||
|
|
|
@ -46,5 +46,3 @@ DEFAULT_OPTIONS = {
|
|||
CONF_RISCO_STATES_TO_HA: DEFAULT_RISCO_STATES_TO_HA,
|
||||
CONF_HA_STATES_TO_RISCO: DEFAULT_HA_STATES_TO_RISCO,
|
||||
}
|
||||
|
||||
SLEEP_INTERVAL = 1
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
"name": "Risco",
|
||||
"config_flow": true,
|
||||
"documentation": "https://www.home-assistant.io/integrations/risco",
|
||||
"requirements": ["pyrisco==0.5.3"],
|
||||
"requirements": ["pyrisco==0.5.4"],
|
||||
"codeowners": ["@OnFreund"],
|
||||
"quality_scale": "platinum",
|
||||
"iot_class": "local_push",
|
||||
|
|
|
@ -1814,7 +1814,7 @@ pyrecswitch==1.0.2
|
|||
pyrepetierng==0.1.0
|
||||
|
||||
# homeassistant.components.risco
|
||||
pyrisco==0.5.3
|
||||
pyrisco==0.5.4
|
||||
|
||||
# homeassistant.components.rituals_perfume_genie
|
||||
pyrituals==0.0.6
|
||||
|
|
|
@ -1270,7 +1270,7 @@ pyps4-2ndscreen==1.3.1
|
|||
pyqwikswitch==0.93
|
||||
|
||||
# homeassistant.components.risco
|
||||
pyrisco==0.5.3
|
||||
pyrisco==0.5.4
|
||||
|
||||
# homeassistant.components.rituals_perfume_genie
|
||||
pyrituals==0.0.6
|
||||
|
|
|
@ -479,6 +479,9 @@ async def test_local_setup(hass, two_part_local_alarm, setup_risco_local):
|
|||
device = registry.async_get_device({(DOMAIN, TEST_SITE_UUID + "_1_local")})
|
||||
assert device is not None
|
||||
assert device.manufacturer == "Risco"
|
||||
with patch("homeassistant.components.risco.RiscoLocal.disconnect") as mock_close:
|
||||
await hass.config_entries.async_unload(setup_risco_local.entry_id)
|
||||
mock_close.assert_awaited_once()
|
||||
|
||||
|
||||
async def _check_local_state(
|
||||
|
|
|
@ -72,9 +72,6 @@ async def test_cloud_form(hass):
|
|||
), patch(
|
||||
"homeassistant.components.risco.config_flow.RiscoCloud.close"
|
||||
) as mock_close, patch(
|
||||
"homeassistant.components.risco.config_flow.SLEEP_INTERVAL",
|
||||
0,
|
||||
), patch(
|
||||
"homeassistant.components.risco.async_setup_entry",
|
||||
return_value=True,
|
||||
) as mock_setup_entry:
|
||||
|
@ -168,9 +165,6 @@ async def test_local_form(hass):
|
|||
), patch(
|
||||
"homeassistant.components.risco.config_flow.RiscoLocal.disconnect"
|
||||
) as mock_close, patch(
|
||||
"homeassistant.components.risco.config_flow.SLEEP_INTERVAL",
|
||||
0,
|
||||
), patch(
|
||||
"homeassistant.components.risco.async_setup_entry",
|
||||
return_value=True,
|
||||
) as mock_setup_entry:
|
||||
|
|
Loading…
Add table
Reference in a new issue