]> git.basschouten.com Git - openhab-addons.git/commitdiff
[netatmo] Discovery using current value of readFriends parameter (#12782)
authorlolodomo <lg.hc@free.fr>
Sun, 22 May 2022 08:34:41 +0000 (10:34 +0200)
committerGitHub <noreply@github.com>
Sun, 22 May 2022 08:34:41 +0000 (10:34 +0200)
Fix #12778

Signed-off-by: Laurent Garnier <lg.hc@free.fr>
bundles/org.openhab.binding.netatmo/src/main/java/org/openhab/binding/netatmo/internal/discovery/NetatmoDiscoveryService.java

index 9e95ea86ac4f0ba82073b1ada53453e42169adad..23bcfdeacd34f4d107e1a3c547c06f81b5184639 100644 (file)
@@ -50,7 +50,6 @@ public class NetatmoDiscoveryService extends AbstractDiscoveryService implements
     private static final int DISCOVER_TIMEOUT_SECONDS = 5;
     private final Logger logger = LoggerFactory.getLogger(NetatmoDiscoveryService.class);
     private @Nullable ApiBridgeHandler handler;
-    private boolean readFriends;
 
     public NetatmoDiscoveryService() {
         super(ModuleType.AS_SET.stream().filter(mt -> !SKIPPED_TYPES.contains(mt)).map(mt -> mt.thingTypeUID)
@@ -70,7 +69,7 @@ public class NetatmoDiscoveryService extends AbstractDiscoveryService implements
                         body.getElements().stream().forEach(homeCoach -> createThing(homeCoach, apiBridgeUID));
                     }
                 }
-                if (readFriends) {
+                if (localHandler.getReadFriends()) {
                     WeatherApi weatherApi = localHandler.getRestManager(WeatherApi.class);
                     if (weatherApi != null) { // Search favorite stations
                         weatherApi.getFavoriteAndGuestStationsData().stream().filter(NAMain::isReadOnly)
@@ -136,7 +135,6 @@ public class NetatmoDiscoveryService extends AbstractDiscoveryService implements
     public void setThingHandler(ThingHandler handler) {
         if (handler instanceof ApiBridgeHandler) {
             this.handler = (ApiBridgeHandler) handler;
-            this.readFriends = ((ApiBridgeHandler) handler).getReadFriends();
         }
     }