Compare commits

...

2 Commits

Author SHA1 Message Date
G Johansson
66897a247a Fix 2026-04-07 15:36:54 +00:00
G Johansson
5ae4bed868 Fix double reloading in unifi 2026-04-05 15:38:25 +00:00
2 changed files with 29 additions and 2 deletions

View File

@@ -176,7 +176,7 @@ class UnifiFlowHandler(ConfigFlow, domain=DOMAIN):
):
return self.async_abort(reason="already_configured")
return self.async_update_reload_and_abort(
return self.async_update_and_abort(
config_entry, data=self.config, reason=abort_reason
)
@@ -230,7 +230,7 @@ class UnifiFlowHandler(ConfigFlow, domain=DOMAIN):
self._async_abort_entries_match({CONF_HOST: self.config[CONF_HOST]})
await self.async_set_unique_id(mac_address)
self._abort_if_unique_id_configured(updates=self.config)
self._abort_if_unique_id_configured(updates=self.config, reload_on_update=False)
self.context["title_placeholders"] = {
CONF_HOST: self.config[CONF_HOST],

View File

@@ -7,6 +7,13 @@ from typing import TYPE_CHECKING
import aiounifi
from homeassistant.const import (
CONF_HOST,
CONF_PASSWORD,
CONF_PORT,
CONF_USERNAME,
CONF_VERIFY_SSL,
)
from homeassistant.core import Event, HomeAssistant, callback
from homeassistant.helpers import device_registry as dr
from homeassistant.helpers.device_registry import (
@@ -131,6 +138,26 @@ class UnifiHub:
the entry might already have been reset and thus is not available.
"""
hub = config_entry.runtime_data
check_keys = {
CONF_HOST: "host",
CONF_PORT: "port",
CONF_USERNAME: "username",
CONF_PASSWORD: "password",
CONF_SITE_ID: "site",
CONF_VERIFY_SSL: "ssl_context",
}
for key, value in check_keys.items():
if key == CONF_VERIFY_SSL:
# ssl_context is either False or a SSLContext object, so we need to compare it differently
if config_entry.data[CONF_VERIFY_SSL] != bool(
getattr(hub.config, value)
):
hass.config_entries.async_schedule_reload(config_entry.entry_id)
return
if config_entry.data[key] != getattr(hub.config, value):
hass.config_entries.async_schedule_reload(config_entry.entry_id)
return
hub.config = UnifiConfig.from_config_entry(config_entry)
async_dispatcher_send(hass, hub.signal_options_update)