[unifi] Fix thing configuration reload after changes (#11411)

* Fix config reload after changes.

Fixes #11407

Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk>

* Don't try to initialize client when bridge is offline.

Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk>
pull/11433/head
jlaur 2021-10-23 00:05:16 +02:00 committed by GitHub
parent d4c9d6ef77
commit 8337f8b92d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 9 deletions

View File

@ -59,6 +59,7 @@ public abstract class UniFiBaseThingHandler<E, C> extends BaseThingHandler {
} }
if (bridge.getStatus() == OFFLINE) { if (bridge.getStatus() == OFFLINE) {
updateStatus(OFFLINE, ThingStatusDetail.BRIDGE_OFFLINE, "The UniFi Controller is currently offline."); updateStatus(OFFLINE, ThingStatusDetail.BRIDGE_OFFLINE, "The UniFi Controller is currently offline.");
return;
} }
// mgb: derive the config class from the generic type // mgb: derive the config class from the generic type
Class<?> clazz = (Class<?>) (((ParameterizedType) getClass().getGenericSuperclass()) Class<?> clazz = (Class<?>) (((ParameterizedType) getClass().getGenericSuperclass())

View File

@ -69,7 +69,6 @@ public class UniFiClientThingHandler extends UniFiBaseThingHandler<UniFiClient,
@Override @Override
protected synchronized void initialize(UniFiClientThingConfig config) { protected synchronized void initialize(UniFiClientThingConfig config) {
// mgb: called when the config changes // mgb: called when the config changes
if (thing.getStatus() == INITIALIZING) {
logger.debug("Initializing the UniFi Client Handler with config = {}", config); logger.debug("Initializing the UniFi Client Handler with config = {}", config);
if (!config.isValid()) { if (!config.isValid()) {
updateStatus(OFFLINE, CONFIGURATION_ERROR, updateStatus(OFFLINE, CONFIGURATION_ERROR,
@ -79,7 +78,6 @@ public class UniFiClientThingHandler extends UniFiBaseThingHandler<UniFiClient,
this.config = config; this.config = config;
updateStatus(ONLINE); updateStatus(ONLINE);
} }
}
private static boolean belongsToSite(UniFiClient client, String siteName) { private static boolean belongsToSite(UniFiClient client, String siteName) {
boolean result = true; // mgb: assume true = proof by contradiction boolean result = true; // mgb: assume true = proof by contradiction