mirror of
https://github.com/danieldemus/openhab-core.git
synced 2026-07-29 12:34:22 +02:00
Fix startup of background discovery (#4323)
Apply the same logic in AbstractThingHandlerDiscoveryService as in AbstractDiscoveryService to determine if background discovery should be enabled or disabled. Fix openhab/openhab-addons#17089 Signed-off-by: Laurent Garnier <lg.hc@free.fr>
This commit is contained in:
+7
-6
@@ -48,17 +48,16 @@ public abstract class AbstractThingHandlerDiscoveryService<T extends ThingHandle
|
||||
int timeout, boolean backgroundDiscoveryEnabledByDefault) throws IllegalArgumentException {
|
||||
super(supportedThingTypes, timeout, backgroundDiscoveryEnabledByDefault);
|
||||
this.thingClazz = thingClazz;
|
||||
this.backgroundDiscoveryEnabled = backgroundDiscoveryEnabledByDefault;
|
||||
}
|
||||
|
||||
protected AbstractThingHandlerDiscoveryService(Class<T> thingClazz, @Nullable Set<ThingTypeUID> supportedThingTypes,
|
||||
int timeout) throws IllegalArgumentException {
|
||||
super(supportedThingTypes, timeout);
|
||||
this.thingClazz = thingClazz;
|
||||
this(thingClazz, supportedThingTypes, timeout, true);
|
||||
}
|
||||
|
||||
protected AbstractThingHandlerDiscoveryService(Class<T> thingClazz, int timeout) throws IllegalArgumentException {
|
||||
super(timeout);
|
||||
this.thingClazz = thingClazz;
|
||||
this(thingClazz, null, timeout);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -86,7 +85,8 @@ public abstract class AbstractThingHandlerDiscoveryService<T extends ThingHandle
|
||||
// thing handler is set. This is correctly handled in initialize
|
||||
if (config != null) {
|
||||
backgroundDiscoveryEnabled = ConfigParser.valueAsOrElse(
|
||||
config.get(DiscoveryService.CONFIG_PROPERTY_BACKGROUND_DISCOVERY), Boolean.class, false);
|
||||
config.get(DiscoveryService.CONFIG_PROPERTY_BACKGROUND_DISCOVERY), Boolean.class,
|
||||
backgroundDiscoveryEnabled);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -94,7 +94,8 @@ public abstract class AbstractThingHandlerDiscoveryService<T extends ThingHandle
|
||||
public void modified(@Nullable Map<String, Object> config) {
|
||||
if (config != null) {
|
||||
boolean enabled = ConfigParser.valueAsOrElse(
|
||||
config.get(DiscoveryService.CONFIG_PROPERTY_BACKGROUND_DISCOVERY), Boolean.class, false);
|
||||
config.get(DiscoveryService.CONFIG_PROPERTY_BACKGROUND_DISCOVERY), Boolean.class,
|
||||
backgroundDiscoveryEnabled);
|
||||
|
||||
if (backgroundDiscoveryEnabled && !enabled) {
|
||||
stopBackgroundDiscovery();
|
||||
|
||||
Reference in New Issue
Block a user