Compare commits

...

1 Commits

Author SHA1 Message Date
G Johansson
e20ced6204 Fix double reloading in unifi 2025-10-25 13:07:57 +00:00
2 changed files with 22 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,19 @@ 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 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)