[openweathermap] Added hint about deprecation of UV Index API (#10326)

Signed-off-by: Christoph Weitkamp <github@christophweitkamp.de>
This commit is contained in:
Christoph Weitkamp
2021-03-15 23:25:32 +01:00
committed by GitHub
parent 279e87851c
commit 04da89cc4f
2 changed files with 39 additions and 57 deletions

View File

@@ -90,10 +90,11 @@ public class OpenWeatherMapDiscoveryService extends AbstractDiscoveryService {
@Override
protected void startBackgroundDiscovery() {
if (discoveryJob == null || discoveryJob.isCancelled()) {
ScheduledFuture<?> localDiscoveryJob = discoveryJob;
if (localDiscoveryJob == null || localDiscoveryJob.isCancelled()) {
logger.debug("Start OpenWeatherMap Location background discovery job at interval {} s.",
DISCOVERY_INTERVAL_SECONDS);
discoveryJob = scheduler.scheduleWithFixedDelay(() -> {
localDiscoveryJob = scheduler.scheduleWithFixedDelay(() -> {
scanForNewLocation(true);
}, 0, DISCOVERY_INTERVAL_SECONDS, TimeUnit.SECONDS);
}
@@ -101,9 +102,10 @@ public class OpenWeatherMapDiscoveryService extends AbstractDiscoveryService {
@Override
protected void stopBackgroundDiscovery() {
if (discoveryJob != null && !discoveryJob.isCancelled()) {
ScheduledFuture<?> localDiscoveryJob = discoveryJob;
if (localDiscoveryJob != null && !localDiscoveryJob.isCancelled()) {
logger.debug("Stop OpenWeatherMap Location background discovery job.");
if (discoveryJob.cancel(true)) {
if (localDiscoveryJob.cancel(true)) {
discoveryJob = null;
}
}
@@ -127,7 +129,6 @@ public class OpenWeatherMapDiscoveryService extends AbstractDiscoveryService {
String locationString = location.toFullString();
ThingUID bridgeUID = bridgeHandler.getThing().getUID();
createWeatherAndForecastResult(locationString, bridgeUID);
createUVIndexResult(locationString, bridgeUID);
createOneCallResult(locationString, bridgeUID);
createOneCallHistoryResult(locationString, bridgeUID);
}
@@ -138,12 +139,6 @@ public class OpenWeatherMapDiscoveryService extends AbstractDiscoveryService {
.withRepresentationProperty(CONFIG_LOCATION).withBridge(bridgeUID).build());
}
private void createUVIndexResult(String location, ThingUID bridgeUID) {
thingDiscovered(DiscoveryResultBuilder.create(new ThingUID(THING_TYPE_UVINDEX, bridgeUID, LOCAL))
.withLabel("Local UV Index").withProperty(CONFIG_LOCATION, location)
.withRepresentationProperty(CONFIG_LOCATION).withBridge(bridgeUID).build());
}
private void createOneCallResult(String location, ThingUID bridgeUID) {
thingDiscovered(
DiscoveryResultBuilder.create(new ThingUID(THING_TYPE_ONECALL_WEATHER_AND_FORECAST, bridgeUID, LOCAL))