Try to reconnect to UniFi on 403 (#109067)
This commit is contained in:
parent
6f88cd3273
commit
f1392f8519
3 changed files with 5 additions and 11 deletions
|
@ -36,8 +36,6 @@ async def async_setup_entry(hass: HomeAssistant, config_entry: ConfigEntry) -> b
|
|||
|
||||
try:
|
||||
api = await get_unifi_controller(hass, config_entry.data)
|
||||
controller = UniFiController(hass, config_entry, api)
|
||||
await controller.initialize()
|
||||
|
||||
except CannotConnect as err:
|
||||
raise ConfigEntryNotReady from err
|
||||
|
@ -45,7 +43,10 @@ async def async_setup_entry(hass: HomeAssistant, config_entry: ConfigEntry) -> b
|
|||
except AuthenticationRequired as err:
|
||||
raise ConfigEntryAuthFailed from err
|
||||
|
||||
controller = UniFiController(hass, config_entry, api)
|
||||
await controller.initialize()
|
||||
hass.data[UNIFI_DOMAIN][config_entry.entry_id] = controller
|
||||
|
||||
await hass.config_entries.async_forward_entry_setups(config_entry, PLATFORMS)
|
||||
controller.async_update_device_registry()
|
||||
|
||||
|
|
|
@ -501,6 +501,7 @@ async def get_unifi_controller(
|
|||
except (
|
||||
asyncio.TimeoutError,
|
||||
aiounifi.BadGateway,
|
||||
aiounifi.Forbidden,
|
||||
aiounifi.ServiceUnavailable,
|
||||
aiounifi.RequestError,
|
||||
aiounifi.ResponseError,
|
||||
|
@ -510,14 +511,6 @@ async def get_unifi_controller(
|
|||
)
|
||||
raise CannotConnect from err
|
||||
|
||||
except aiounifi.Forbidden as err:
|
||||
LOGGER.warning(
|
||||
"Access forbidden to UniFi Network at %s, check access rights: %s",
|
||||
config[CONF_HOST],
|
||||
err,
|
||||
)
|
||||
raise AuthenticationRequired from err
|
||||
|
||||
except aiounifi.LoginRequired as err:
|
||||
LOGGER.warning(
|
||||
"Connected to UniFi Network at %s but login required: %s",
|
||||
|
|
|
@ -461,11 +461,11 @@ async def test_get_unifi_controller_verify_ssl_false(hass: HomeAssistant) -> Non
|
|||
[
|
||||
(asyncio.TimeoutError, CannotConnect),
|
||||
(aiounifi.BadGateway, CannotConnect),
|
||||
(aiounifi.Forbidden, CannotConnect),
|
||||
(aiounifi.ServiceUnavailable, CannotConnect),
|
||||
(aiounifi.RequestError, CannotConnect),
|
||||
(aiounifi.ResponseError, CannotConnect),
|
||||
(aiounifi.Unauthorized, AuthenticationRequired),
|
||||
(aiounifi.Forbidden, AuthenticationRequired),
|
||||
(aiounifi.LoginRequired, AuthenticationRequired),
|
||||
(aiounifi.AiounifiException, AuthenticationRequired),
|
||||
],
|
||||
|
|
Loading…
Add table
Reference in a new issue