[netatmo] Discovery using current value of readFriends parameter (#12782)

Fix #12778

Signed-off-by: Laurent Garnier <lg.hc@free.fr>
This commit is contained in:
lolodomo 2022-05-22 10:34:41 +02:00 committed by GitHub
parent 2fbdc7d21e
commit 50831fff14
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View 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();
}
}