Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[homematic] fixing incorrect scan duration after openHAB restart #11971

Merged
merged 1 commit into from
Jan 7, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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