Skip to content

Commit

Permalink
Update HomematicDeviceDiscoveryService.java (openhab#11971)
Browse files Browse the repository at this point in the history
fix for bug openhab#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>
Signed-off-by: Nick Waterton <n.waterton@outlook.com>
  • Loading branch information
raykleibelt authored and NickWaterton committed Apr 27, 2022
1 parent fc31c71 commit df9da51
Showing 1 changed file with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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) {
Expand All @@ -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
Expand Down

0 comments on commit df9da51

Please sign in to comment.