Update HomematicDeviceDiscoveryService.java (#11971)
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>pull/11992/head
parent
78fd621ad9
commit
65002647df
|
@ -52,7 +52,6 @@ public class HomematicDeviceDiscoveryService extends AbstractDiscoveryService
|
||||||
private Future<?> loadDevicesFuture;
|
private Future<?> loadDevicesFuture;
|
||||||
private volatile boolean isInInstallMode = false;
|
private volatile boolean isInInstallMode = false;
|
||||||
private volatile Object installModeSync = new Object();
|
private volatile Object installModeSync = new Object();
|
||||||
private volatile int installModeDuration = HomematicConfig.DEFAULT_INSTALL_MODE_DURATION;
|
|
||||||
|
|
||||||
public HomematicDeviceDiscoveryService() {
|
public HomematicDeviceDiscoveryService() {
|
||||||
super(Collections.singleton(new ThingTypeUID(BINDING_ID, "-")), DISCOVER_TIMEOUT_SECONDS, false);
|
super(Collections.singleton(new ThingTypeUID(BINDING_ID, "-")), DISCOVER_TIMEOUT_SECONDS, false);
|
||||||
|
@ -103,10 +102,9 @@ public class HomematicDeviceDiscoveryService extends AbstractDiscoveryService
|
||||||
if (bridgeHandler != null) {
|
if (bridgeHandler != null) {
|
||||||
Thing bridge = bridgeHandler.getThing();
|
Thing bridge = bridgeHandler.getThing();
|
||||||
bridgeStatus = bridge.getStatus();
|
bridgeStatus = bridge.getStatus();
|
||||||
updateInstallModeDuration(bridge);
|
|
||||||
}
|
}
|
||||||
if (ThingStatus.ONLINE == bridgeStatus) {
|
if (ThingStatus.ONLINE == bridgeStatus) {
|
||||||
gateway.setInstallMode(true, installModeDuration);
|
gateway.setInstallMode(true, getInstallModeDuration());
|
||||||
|
|
||||||
int remaining = gateway.getInstallMode();
|
int remaining = gateway.getInstallMode();
|
||||||
if (remaining > 0) {
|
if (remaining > 0) {
|
||||||
|
@ -123,14 +121,16 @@ public class HomematicDeviceDiscoveryService extends AbstractDiscoveryService
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateInstallModeDuration(Thing bridge) {
|
private int getInstallModeDuration() {
|
||||||
HomematicConfig config = bridge.getConfiguration().as(HomematicConfig.class);
|
if (bridgeHandler != null) {
|
||||||
installModeDuration = config.getInstallModeDuration();
|
return bridgeHandler.getThing().getConfiguration().as(HomematicConfig.class).getInstallModeDuration();
|
||||||
|
}
|
||||||
|
return HomematicConfig.DEFAULT_INSTALL_MODE_DURATION;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getScanTimeout() {
|
public int getScanTimeout() {
|
||||||
return installModeDuration;
|
return getInstallModeDuration();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in New Issue