mirror of
https://github.com/openhab/openhab-addons.git
synced 2025-01-10 15:11:59 +01:00
[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) {
|
||||
logger.trace("registerDeviceDiscoveryService({}) called.", bridgeHandler);
|
||||
boolean createNew = false;
|
||||
VeluxDiscoveryService discoveryService = this.discoveryService;
|
||||
if (discoveryService == null) {
|
||||
discoveryService = new VeluxDiscoveryService(localization);
|
||||
createNew = true;
|
||||
discoveryService = this.discoveryService = new VeluxDiscoveryService(localization);
|
||||
}
|
||||
discoveryService.addBridge(bridgeHandler);
|
||||
if (createNew) {
|
||||
if (discoveryServiceRegistration == null) {
|
||||
discoveryServiceRegistration = bundleContext.registerService(DiscoveryService.class.getName(),
|
||||
discoveryService, new Hashtable<>());
|
||||
}
|
||||
@ -90,6 +88,7 @@ public class VeluxHandlerFactory extends BaseThingHandlerFactory {
|
||||
ServiceRegistration<?> discoveryServiceRegistration = this.discoveryServiceRegistration;
|
||||
if (discoveryServiceRegistration != null) {
|
||||
discoveryServiceRegistration.unregister();
|
||||
this.discoveryServiceRegistration = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user