[velux] fix discovery service de- and re- registration (#8673)
Signed-off-by: Andrew Fiddian-Green <software@whitebear.ch>
This commit is contained in:
parent
937c7a3a45
commit
178e657d80
@ -68,14 +68,12 @@ public class VeluxHandlerFactory extends BaseThingHandlerFactory {
|
|||||||
|
|
||||||
private void registerDeviceDiscoveryService(VeluxBridgeHandler bridgeHandler) {
|
private void registerDeviceDiscoveryService(VeluxBridgeHandler bridgeHandler) {
|
||||||
logger.trace("registerDeviceDiscoveryService({}) called.", bridgeHandler);
|
logger.trace("registerDeviceDiscoveryService({}) called.", bridgeHandler);
|
||||||
boolean createNew = false;
|
|
||||||
VeluxDiscoveryService discoveryService = this.discoveryService;
|
VeluxDiscoveryService discoveryService = this.discoveryService;
|
||||||
if (discoveryService == null) {
|
if (discoveryService == null) {
|
||||||
discoveryService = new VeluxDiscoveryService(localization);
|
discoveryService = this.discoveryService = new VeluxDiscoveryService(localization);
|
||||||
createNew = true;
|
|
||||||
}
|
}
|
||||||
discoveryService.addBridge(bridgeHandler);
|
discoveryService.addBridge(bridgeHandler);
|
||||||
if (createNew) {
|
if (discoveryServiceRegistration == null) {
|
||||||
discoveryServiceRegistration = bundleContext.registerService(DiscoveryService.class.getName(),
|
discoveryServiceRegistration = bundleContext.registerService(DiscoveryService.class.getName(),
|
||||||
discoveryService, new Hashtable<>());
|
discoveryService, new Hashtable<>());
|
||||||
}
|
}
|
||||||
@ -90,6 +88,7 @@ public class VeluxHandlerFactory extends BaseThingHandlerFactory {
|
|||||||
ServiceRegistration<?> discoveryServiceRegistration = this.discoveryServiceRegistration;
|
ServiceRegistration<?> discoveryServiceRegistration = this.discoveryServiceRegistration;
|
||||||
if (discoveryServiceRegistration != null) {
|
if (discoveryServiceRegistration != null) {
|
||||||
discoveryServiceRegistration.unregister();
|
discoveryServiceRegistration.unregister();
|
||||||
|
this.discoveryServiceRegistration = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user