From dc7c8817c2e9f9b4ee1ec7604b4da1de2bb6615e Mon Sep 17 00:00:00 2001 From: raykleibelt <54982000+raykleibelt@users.noreply.github.com> Date: Wed, 5 Jan 2022 20:59:00 +0100 Subject: [PATCH] Update HomematicDeviceDiscoveryService.java fix for bug #11969 After a restart of openHAB the function 'getScanTimeout()' is called before the member 'installModeDuration' has been initialized with the correct value from the configuration. With a large number of Homematic devices, the default value of 'installModeDuration' is too small to read in all Homematic devices from the CCU. Therefore, when calling the function 'getScanTimeout()', the value is read directly from the configuration. The member 'installModeDuration' has been removed. Signed-off-by: raykleibelt <54982000+raykleibelt@users.noreply.github.com> --- .../discovery/HomematicDeviceDiscoveryService.java | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/bundles/org.openhab.binding.homematic/src/main/java/org/openhab/binding/homematic/internal/discovery/HomematicDeviceDiscoveryService.java b/bundles/org.openhab.binding.homematic/src/main/java/org/openhab/binding/homematic/internal/discovery/HomematicDeviceDiscoveryService.java index 180d29bfef9c8..eefb9f4096a5b 100644 --- a/bundles/org.openhab.binding.homematic/src/main/java/org/openhab/binding/homematic/internal/discovery/HomematicDeviceDiscoveryService.java +++ b/bundles/org.openhab.binding.homematic/src/main/java/org/openhab/binding/homematic/internal/discovery/HomematicDeviceDiscoveryService.java @@ -52,7 +52,6 @@ public class HomematicDeviceDiscoveryService extends AbstractDiscoveryService private Future loadDevicesFuture; private volatile boolean isInInstallMode = false; private volatile Object installModeSync = new Object(); - private volatile int installModeDuration = HomematicConfig.DEFAULT_INSTALL_MODE_DURATION; public HomematicDeviceDiscoveryService() { super(Collections.singleton(new ThingTypeUID(BINDING_ID, "-")), DISCOVER_TIMEOUT_SECONDS, false); @@ -103,10 +102,9 @@ private void enableInstallMode() { if (bridgeHandler != null) { Thing bridge = bridgeHandler.getThing(); bridgeStatus = bridge.getStatus(); - updateInstallModeDuration(bridge); } if (ThingStatus.ONLINE == bridgeStatus) { - gateway.setInstallMode(true, installModeDuration); + gateway.setInstallMode(true, getInstallModeDuration()); int remaining = gateway.getInstallMode(); if (remaining > 0) { @@ -123,14 +121,16 @@ private void enableInstallMode() { } } - private void updateInstallModeDuration(Thing bridge) { - HomematicConfig config = bridge.getConfiguration().as(HomematicConfig.class); - installModeDuration = config.getInstallModeDuration(); + private int getInstallModeDuration() { + if (bridgeHandler != null) { + return bridgeHandler.getThing().getConfiguration().as(HomematicConfig.class).getInstallModeDuration(); + } + return HomematicConfig.DEFAULT_INSTALL_MODE_DURATION; } @Override public int getScanTimeout() { - return installModeDuration; + return getInstallModeDuration(); } @Override