Skip to content

Commit

Permalink
[unifi] Fix thing configuration reload after changes (#11411)
Browse files Browse the repository at this point in the history
* 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>
  • Loading branch information
jlaur committed Oct 22, 2021
1 parent d4c9d6e commit 8337f8b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
Expand Up @@ -59,6 +59,7 @@ public final void initialize() {
}
if (bridge.getStatus() == OFFLINE) {
updateStatus(OFFLINE, ThingStatusDetail.BRIDGE_OFFLINE, "The UniFi Controller is currently offline.");
return;
}
// mgb: derive the config class from the generic type
Class<?> clazz = (Class<?>) (((ParameterizedType) getClass().getGenericSuperclass())
Expand Down
Expand Up @@ -69,16 +69,14 @@ public UniFiClientThingHandler(Thing thing) {
@Override
protected synchronized void initialize(UniFiClientThingConfig config) {
// mgb: called when the config changes
if (thing.getStatus() == INITIALIZING) {
logger.debug("Initializing the UniFi Client Handler with config = {}", config);
if (!config.isValid()) {
updateStatus(OFFLINE, CONFIGURATION_ERROR,
"You must define a MAC address, IP address, hostname or alias for this thing.");
return;
}
this.config = config;
updateStatus(ONLINE);
logger.debug("Initializing the UniFi Client Handler with config = {}", config);
if (!config.isValid()) {
updateStatus(OFFLINE, CONFIGURATION_ERROR,
"You must define a MAC address, IP address, hostname or alias for this thing.");
return;
}
this.config = config;
updateStatus(ONLINE);
}

private static boolean belongsToSite(UniFiClient client, String siteName) {
Expand Down

0 comments on commit 8337f8b

Please sign in to comment.