diff --git a/bundles/org.openhab.io.homekit/src/main/java/org/openhab/io/homekit/internal/HomekitImpl.java b/bundles/org.openhab.io.homekit/src/main/java/org/openhab/io/homekit/internal/HomekitImpl.java index dfe91464a..3226e770f 100644 --- a/bundles/org.openhab.io.homekit/src/main/java/org/openhab/io/homekit/internal/HomekitImpl.java +++ b/bundles/org.openhab.io.homekit/src/main/java/org/openhab/io/homekit/internal/HomekitImpl.java @@ -87,7 +87,7 @@ public class HomekitImpl implements Homekit, NetworkAddressChangeListener, Ready private final List homekitServers = new ArrayList<>(); private final List bridges = new ArrayList<>(); private MDNSClient mdnsClient; - private int currentStartLevel = 0; + private boolean started = false; private final List changeListeners = new ArrayList<>(); @@ -170,7 +170,7 @@ public class HomekitImpl implements Homekit, NetworkAddressChangeListener, Ready clearStorage(i); } stopHomekitServer(); - if (currentStartLevel >= StartLevelService.STARTLEVEL_STATES) { + if (started) { startHomekitServer(); } } else { @@ -201,6 +201,7 @@ public class HomekitImpl implements Homekit, NetworkAddressChangeListener, Ready @Override public synchronized void onReadyMarkerAdded(ReadyMarker readyMarker) { try { + started = true; startHomekitServer(); } catch (IOException | InvalidAlgorithmParameterException e) { logger.warn("could not initialize HomeKit bridge: {}", e.getMessage()); @@ -209,6 +210,7 @@ public class HomekitImpl implements Homekit, NetworkAddressChangeListener, Ready @Override public synchronized void onReadyMarkerRemoved(ReadyMarker readyMarker) { + started = false; stopHomekitServer(); } @@ -411,7 +413,7 @@ public class HomekitImpl implements Homekit, NetworkAddressChangeListener, Ready @Override public synchronized void onChanged(final List added, final List removed) { logger.trace("HomeKit bridge reacting on network interface changes."); - if (currentStartLevel < StartLevelService.STARTLEVEL_STATES) { + if (!started) { return; } removed.forEach(i -> {