diff --git a/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/discovery/OpenWeatherMapDiscoveryService.java b/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/discovery/OpenWeatherMapDiscoveryService.java index af48422cb3f65..ff9d880288156 100644 --- a/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/discovery/OpenWeatherMapDiscoveryService.java +++ b/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/discovery/OpenWeatherMapDiscoveryService.java @@ -79,7 +79,7 @@ public void deactivate() { @Override protected void startScan() { logger.debug("Start manual OpenWeatherMap Location discovery scan."); - scanForNewLocation(); + scanForNewLocation(false); } @Override @@ -93,8 +93,9 @@ protected void startBackgroundDiscovery() { if (discoveryJob == null || discoveryJob.isCancelled()) { logger.debug("Start OpenWeatherMap Location background discovery job at interval {} s.", DISCOVERY_INTERVAL_SECONDS); - discoveryJob = scheduler.scheduleWithFixedDelay(this::scanForNewLocation, 0, DISCOVERY_INTERVAL_SECONDS, - TimeUnit.SECONDS); + discoveryJob = scheduler.scheduleWithFixedDelay(() -> { + scanForNewLocation(true); + }, 0, DISCOVERY_INTERVAL_SECONDS, TimeUnit.SECONDS); } } @@ -108,7 +109,7 @@ protected void stopBackgroundDiscovery() { } } - private void scanForNewLocation() { + private void scanForNewLocation(boolean updateOnlyIfNewLocation) { PointType currentLocation = locationProvider.getLocation(); if (currentLocation == null) { logger.debug("Location is not set -> Will not provide any discovery results."); @@ -117,7 +118,7 @@ private void scanForNewLocation() { currentLocation); createResults(currentLocation); previousLocation = currentLocation; - } else { + } else if (!updateOnlyIfNewLocation) { createResults(currentLocation); } }