From 080f7a5172aa7f75602a9e29306a4172824e6764 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABl=20L=27hopital?= Date: Thu, 12 Dec 2024 12:46:58 +0100 Subject: [PATCH] Code review corrections MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Gaël L'hopital --- .../org.openhab.binding.airparif/README.md | 69 +++++++++++++++++-- .../internal/AirParifHandlerFactory.java | 7 +- .../airparif/internal/api/AirParifApi.java | 4 -- .../airparif/internal/api/AirParifDto.java | 24 +++---- .../deserialization/AirParifDeserializer.java | 10 ++- .../PollutantConcentrationDeserializer.java | 5 +- .../discovery/AirParifDiscoveryService.java | 4 +- .../handler/AirParifBridgeHandler.java | 16 +++-- .../internal/handler/HandlerUtils.java | 6 +- .../resources/OH-INF/i18n/airparif.properties | 12 ++-- .../resources/OH-INF/thing/channel-groups.xml | 4 +- .../main/resources/OH-INF/thing/location.xml | 8 +-- 12 files changed, 111 insertions(+), 58 deletions(-) diff --git a/bundles/org.openhab.binding.airparif/README.md b/bundles/org.openhab.binding.airparif/README.md index 3e515749d42..0f0cd51e323 100755 --- a/bundles/org.openhab.binding.airparif/README.md +++ b/bundles/org.openhab.binding.airparif/README.md @@ -61,7 +61,8 @@ Please check that proposed value is correct according to the place. | aq-bulletin-tomorrow | pm10-max | Number:Density | R | Maximum level of PM 10 concentration | | aq-bulletin-tomorrow | pm25-min | Number:Density | R | Minimum level of PM 2.5 concentration | | aq-bulletin-tomorrow | pm25-max | Number:Density | R | Maximum level of PM 2.5 concentration | -| daily | message | String | R | Today's daily general information ||| daily | tomorrow | String | R | Tomorrow's daily general information | +| daily | message | String | R | Today's daily general information | +| daily | tomorrow | String | R | Tomorrow's daily general information | ### `location` Thing Channels @@ -150,19 +151,75 @@ This binding has its own IconProvider and makes available the following list of | oh:airparif:willow | Yes | ![](doc/images/willow.svg) | | oh:airparif:wormwood | Yes | ![](doc/images/wormwood.svg) | - ## Full Examplee ### Thing Configurationn -```jav +```java Bridge airparif:api:local "AirParif" [ apikey="xxxxx-dddd-cccc-4321-zzzzzzzzzzzzz" ] { - location yvelines "Yvelines" [ department="78", location="52.639,1.8284" ] -}a + location 78 "Yvelines" [ department="78", location="52.639,1.8284" ] +} ``` ### Item Configurationn ```java -Example item configuration goes here. +String AirParifPollensComment "Situation" {channel="airparif:api:local:pollens#comment"} +DateTime AirParifPollensBeginValidity "Begin validity" {channel="airparif:api:local:pollens#begin-validity"} +DateTime AirParifPollensEndValidity "End validity" {channel="airparif:api:local:pollens#end-validity"} +String AirParifAqBulletinComment "Message" {channel="airparif:api:local:aq-bulletin#comment"} +Number:Density AirParifAqBulletinNo2Min "No2 min" {channel="airparif:api:local:aq-bulletin#no2-min"} +Number:Density AirParifAqBulletinNo2Max "No2 max" {channel="airparif:api:local:aq-bulletin#no2-max"} +Number:Density AirParifAqBulletinO3Min "O3 min" {channel="airparif:api:local:aq-bulletin#o3-min"} +Number:Density AirParifAqBulletinO3Max "O3 max" {channel="airparif:api:local:aq-bulletin#o3-max"} +Number:Density AirParifAqBulletinPm10Min "Pm 10 min" {channel="airparif:api:local:aq-bulletin#pm10-min"} +Number:Density AirParifAqBulletinPm10Max "Pm 10 max" {channel="airparif:api:local:aq-bulletin#pm10-max"} +Number:Density AirParifAqBulletinPm25Min "Pm 2.5 min" {channel="airparif:api:local:aq-bulletin#pm25-min"} +Number:Density AirParifAqBulletinPm25Max "Pm 2.5 max" {channel="airparif:api:local:aq-bulletin#pm25-max"} +String AirParifAqBulletinTomorrowComment "Message" {channel="airparif:api:local:aq-bulletin-tomorrow#comment"} +Number:Density AirParifAqBulletinTomorrowNo2Min "No2 min" {channel="airparif:api:local:aq-bulletin-tomorrow#no2-min"} +Number:Density AirParifAqBulletinTomorrowNo2Max "No2 max" {channel="airparif:api:local:aq-bulletin-tomorrow#no2-max"} +Number:Density AirParifAqBulletinTomorrowO3Min "O3 min" {channel="airparif:api:local:aq-bulletin-tomorrow#o3-min"} +Number:Density AirParifAqBulletinTomorrowO3Max "O3 max" {channel="airparif:api:local:aq-bulletin-tomorrow#o3-max"} +Number:Density AirParifAqBulletinTomorrowPm10Min "Pm 10 min" {channel="airparif:api:local:aq-bulletin-tomorrow#pm10-min"} +Number:Density AirParifAqBulletinTomorrowPm10Max "Pm 10 max" {channel="airparif:api:local:aq-bulletin-tomorrow#pm10-max"} +Number:Density AirParifAqBulletinTomorrowPm25Min "Pm 2.5 min" {channel="airparif:api:local:aq-bulletin-tomorrow#pm25-min"} +Number:Density AirParifAqBulletinTomorrowPm25Max "Pm 2.5 max" {channel="airparif:api:local:aq-bulletin-tomorrow#pm25-max"} +String AirParifDailyMessage "Message" {channel="airparif:api:local:daily#message"} +String AirParifDailyTomorrow "Tomorrow" {channel="airparif:api:local:daily#tomorrow"} + +Number Yvelines_Pollens_Cypress "Cypress" {channel="airparif:location:local:78:pollens#cypress"} +Number Yvelines_Pollens_Hazel "Hazel level" {channel="airparif:location:local:78:pollens#hazel"} +Number Yvelines_Pollens_Alder "Alder" {channel="airparif:location:local:78:pollens#alder"} +Number Yvelines_Pollens_Poplar "Poplar" {channel="airparif:location:local:78:pollens#poplar"} +Number Yvelines_Pollens_Willow "Willow" {channel="airparif:location:local:78:pollens#willow"} +Number Yvelines_Pollens_Ash "Ash" {channel="airparif:location:local:78:pollens#ash"} +Number Yvelines_Pollens_Hornbeam "Hornbeam" {channel="airparif:location:local:78:pollens#hornbeam"} +Number Yvelines_Pollens_Birch "Birch level" {channel="airparif:location:local:78:pollens#birch"} +Number Yvelines_Pollens_Plane "Plane" {channel="airparif:location:local:78:pollens#plane"} +Number Yvelines_Pollens_Oak "Oak" {channel="airparif:location:local:78:pollens#oak"} +Number Yvelines_Pollens_Olive "Olive" {channel="airparif:location:local:78:pollens#olive"} +Number Yvelines_Pollens_Linden "Linden" {channel="airparif:location:local:78:pollens#linden"} +Number Yvelines_Pollens_Chestnut "Chestnut" {channel="airparif:location:local:78:pollens#chestnut"} +Number Yvelines_Pollens_Rumex "Rumex" {channel="airparif:location:local:78:pollens#rumex"} +Number Yvelines_Pollens_Grasses "Grasses" {channel="airparif:location:local:78:pollens#grasses"} +Number Yvelines_Pollens_Plantain "Plantain" {channel="airparif:location:local:78:pollens#plantain"} +Number Yvelines_Pollens_Urticaceae "Urticacea" {channel="airparif:location:local:78:pollens#urticaceae"} +Number Yvelines_Pollens_Wormwood "Wormwood" {channel="airparif:location:local:78:pollens#wormwood"} +Number Yvelines_Pollens_Ragweed "Ragweed" {channel="airparif:location:local:78:pollens#ragweed"} +String Yvelines_Indice_Message "Message" {channel="airparif:location:local:78:indice#message"} +DateTime Yvelines_Indice_Timestamp "Timestamp" {channel="airparif:location:local:78:indice#timestamp"} +Number Yvelines_Indice_Alert "Index" {channel="airparif:location:local:78:indice#alert"} +String Yvelines_O3_Message "Message" {channel="airparif:location:local:78:o3#message"} +Number:Density Yvelines_O3_Value "Concentration" {channel="airparif:location:local:78:o3#value"} +Number Yvelines_O3_Alert "Alert level" {channel="airparif:location:local:78:o3#alert"} +String Yvelines_No2_Message "Message" {channel="airparif:location:local:78:no2#message"} +Number:Density Yvelines_No2_Value "Concentration" {channel="airparif:location:local:78:no2#value"} +Number Yvelines_No2_Alert "Alert level" {channel="airparif:location:local:78:no2#alert"} +String Yvelines_Pm25_Message "Message" {channel="airparif:location:local:78:pm25#message"} +Number:Density Yvelines_Pm25_Value "Concentration" {channel="airparif:location:local:78:pm25#value"} +Number Yvelines_Pm25_Alert "Alert level" {channel="airparif:location:local:78:pm25#alert"} +String Yvelines_Pm10_Message "Message" {channel="airparif:location:local:78:pm10#message"} +Number:Density Yvelines_Pm10_Value "Concentration" {channel="airparif:location:local:78:pm10#value"} +Number Yvelines_Pm10_Alert "Alert level" {channel="airparif:location:local:78:pm10#alert"} `` diff --git a/bundles/org.openhab.binding.airparif/src/main/java/org/openhab/binding/airparif/internal/AirParifHandlerFactory.java b/bundles/org.openhab.binding.airparif/src/main/java/org/openhab/binding/airparif/internal/AirParifHandlerFactory.java index ea9f49da607..76805b24c17 100755 --- a/bundles/org.openhab.binding.airparif/src/main/java/org/openhab/binding/airparif/internal/AirParifHandlerFactory.java +++ b/bundles/org.openhab.binding.airparif/src/main/java/org/openhab/binding/airparif/internal/AirParifHandlerFactory.java @@ -16,7 +16,6 @@ import static org.openhab.binding.airparif.internal.AirParifBindingConstants.*; import org.eclipse.jdt.annotation.NonNullByDefault; import org.eclipse.jdt.annotation.Nullable; -import org.eclipse.jetty.client.HttpClient; import org.openhab.binding.airparif.internal.deserialization.AirParifDeserializer; import org.openhab.binding.airparif.internal.handler.AirParifBridgeHandler; import org.openhab.binding.airparif.internal.handler.LocationHandler; @@ -40,12 +39,12 @@ import org.osgi.service.component.annotations.Reference; @Component(configurationPid = "binding.airparif", service = ThingHandlerFactory.class) public class AirParifHandlerFactory extends BaseThingHandlerFactory { private final AirParifDeserializer deserializer; - private final HttpClient httpClient; + private final HttpClientFactory httpClientFactory; @Activate public AirParifHandlerFactory(final @Reference HttpClientFactory httpClientFactory, final @Reference AirParifDeserializer deserializer) { - this.httpClient = httpClientFactory.getCommonHttpClient(); + this.httpClientFactory = httpClientFactory; this.deserializer = deserializer; } @@ -59,7 +58,7 @@ public class AirParifHandlerFactory extends BaseThingHandlerFactory { ThingTypeUID thingTypeUID = thing.getThingTypeUID(); return APIBRIDGE_THING_TYPE.equals(thingTypeUID) - ? new AirParifBridgeHandler((Bridge) thing, httpClient, deserializer) + ? new AirParifBridgeHandler((Bridge) thing, httpClientFactory.getCommonHttpClient(), deserializer) : LOCATION_THING_TYPE.equals(thingTypeUID) ? new LocationHandler(thing) : null; } } diff --git a/bundles/org.openhab.binding.airparif/src/main/java/org/openhab/binding/airparif/internal/api/AirParifApi.java b/bundles/org.openhab.binding.airparif/src/main/java/org/openhab/binding/airparif/internal/api/AirParifApi.java index bd270779d50..94ed8c3ed6f 100644 --- a/bundles/org.openhab.binding.airparif/src/main/java/org/openhab/binding/airparif/internal/api/AirParifApi.java +++ b/bundles/org.openhab.binding.airparif/src/main/java/org/openhab/binding/airparif/internal/api/AirParifApi.java @@ -41,10 +41,6 @@ public class AirParifApi { private static final UriBuilder POLLENS_BUILDER = AIRPARIF_BUILDER.clone().path("pollens"); public static final URI POLLENS_URI = POLLENS_BUILDER.clone().path("bulletin").build(); - // Poor interest, only returns highest risk level for the dept. - // public static final UriBuilder POLLENS_DEPT_BUILDER = POLLENS_BUILDER.clone().path("departement"); - // public static final URI PREV_COLORS_URI = INDICES_BUILDER.clone().path("couleurs").build(); - public enum Scope { @SerializedName("Cartes et résultats Hor'Air") MAPS, diff --git a/bundles/org.openhab.binding.airparif/src/main/java/org/openhab/binding/airparif/internal/api/AirParifDto.java b/bundles/org.openhab.binding.airparif/src/main/java/org/openhab/binding/airparif/internal/api/AirParifDto.java index 73374d491c4..0edb8a6315e 100644 --- a/bundles/org.openhab.binding.airparif/src/main/java/org/openhab/binding/airparif/internal/api/AirParifDto.java +++ b/bundles/org.openhab.binding.airparif/src/main/java/org/openhab/binding/airparif/internal/api/AirParifDto.java @@ -13,9 +13,9 @@ package org.openhab.binding.airparif.internal.api; import java.time.Duration; +import java.time.Instant; import java.time.LocalDate; import java.time.ZoneId; -import java.time.ZonedDateTime; import java.time.format.DateTimeFormatter; import java.util.HashMap; import java.util.List; @@ -54,7 +54,7 @@ public class AirParifDto { } public record KeyInfo(// - ZonedDateTime expiration, // + Instant expiration, // @SerializedName("droits") Set scopes) { } @@ -135,33 +135,33 @@ public class AirParifDto { private static ZoneId DEFAULT_ZONE = ZoneId.of("Europe/Paris"); public List data = List.of(); - private @Nullable ZonedDateTime beginValidity; - private @Nullable ZonedDateTime endValidity; + private @Nullable Instant beginValidity; + private @Nullable Instant endValidity; public Optional getData() { return Optional.ofNullable(data.isEmpty() ? null : data.get(0)); } - private Set getValidities() { - Set validities = new TreeSet<>(); + private Set getValidities() { + Set validities = new TreeSet<>(); getData().ifPresent(pollens -> { Matcher matcher = PATTERN.matcher(pollens.periode); while (matcher.find()) { - validities.add(LocalDate.parse(matcher.group(), FORMATTER).atStartOfDay(DEFAULT_ZONE)); + validities.add(LocalDate.parse(matcher.group(), FORMATTER).atStartOfDay(DEFAULT_ZONE).toInstant()); } }); return validities; } - public Optional getBeginValidity() { + public Optional getBeginValidity() { if (beginValidity == null) { beginValidity = getValidities().iterator().next(); } return Optional.ofNullable(beginValidity); } - public Optional getEndValidity() { + public Optional getEndValidity() { if (endValidity == null) { endValidity = getValidities().stream().reduce((prev, next) -> next).orElse(null); } @@ -170,7 +170,7 @@ public class AirParifDto { public Duration getValidityDuration() { return Objects.requireNonNull(getEndValidity().map(end -> { - Duration duration = Duration.between(ZonedDateTime.now().withZoneSameInstant(end.getZone()), end); + Duration duration = Duration.between(Instant.now(), end); return duration.isNegative() ? Duration.ZERO : duration; }).orElse(Duration.ZERO)); } @@ -197,7 +197,7 @@ public class AirParifDto { public record Concentration(// @SerializedName("polluant") Pollutant pollutant, // - ZonedDateTime date, // + Instant date, // @SerializedName("valeurs") double[] values, // @Nullable Message message) { @@ -224,7 +224,7 @@ public class AirParifDto { } public record Route(// - @SerializedName("dateRequise") ZonedDateTime requestedDate, // + @SerializedName("dateRequise") Instant requestedDate, // double[][] longlats, // @SerializedName("resultats") List concentrations, // @Nullable Message[] messages) { diff --git a/bundles/org.openhab.binding.airparif/src/main/java/org/openhab/binding/airparif/internal/deserialization/AirParifDeserializer.java b/bundles/org.openhab.binding.airparif/src/main/java/org/openhab/binding/airparif/internal/deserialization/AirParifDeserializer.java index edafa433730..90d0199655a 100755 --- a/bundles/org.openhab.binding.airparif/src/main/java/org/openhab/binding/airparif/internal/deserialization/AirParifDeserializer.java +++ b/bundles/org.openhab.binding.airparif/src/main/java/org/openhab/binding/airparif/internal/deserialization/AirParifDeserializer.java @@ -12,18 +12,16 @@ */ package org.openhab.binding.airparif.internal.deserialization; +import java.time.Instant; import java.time.LocalDate; -import java.time.ZonedDateTime; import org.eclipse.jdt.annotation.NonNullByDefault; import org.eclipse.jdt.annotation.Nullable; import org.openhab.binding.airparif.internal.AirParifException; import org.openhab.binding.airparif.internal.api.AirParifDto.PollutantConcentration; import org.openhab.binding.airparif.internal.api.PollenAlertLevel; -import org.openhab.core.i18n.TimeZoneProvider; import org.osgi.service.component.annotations.Activate; import org.osgi.service.component.annotations.Component; -import org.osgi.service.component.annotations.Reference; import com.google.gson.FieldNamingPolicy; import com.google.gson.Gson; @@ -42,7 +40,7 @@ public class AirParifDeserializer { private final Gson gson; @Activate - public AirParifDeserializer(final @Reference TimeZoneProvider timeZoneProvider) { + public AirParifDeserializer() { gson = new GsonBuilder().setFieldNamingPolicy(FieldNamingPolicy.IDENTITY) .registerTypeAdapter(PollenAlertLevel.class, new PollenAlertLevelDeserializer()) .registerTypeAdapterFactory(new StrictEnumTypeAdapterFactory()) @@ -50,10 +48,10 @@ public class AirParifDeserializer { .registerTypeAdapter(LocalDate.class, (JsonDeserializer) (json, type, context) -> LocalDate .parse(json.getAsJsonPrimitive().getAsString())) - .registerTypeAdapter(ZonedDateTime.class, (JsonDeserializer) (json, type, context) -> { + .registerTypeAdapter(Instant.class, (JsonDeserializer) (json, type, context) -> { String string = json.getAsJsonPrimitive().getAsString(); string += string.contains("+") ? "" : "Z"; - return ZonedDateTime.parse(string).withZoneSameInstant(timeZoneProvider.getTimeZone()); + return Instant.parse(string); }).create(); } diff --git a/bundles/org.openhab.binding.airparif/src/main/java/org/openhab/binding/airparif/internal/deserialization/PollutantConcentrationDeserializer.java b/bundles/org.openhab.binding.airparif/src/main/java/org/openhab/binding/airparif/internal/deserialization/PollutantConcentrationDeserializer.java index d66045b6d77..656417fea64 100644 --- a/bundles/org.openhab.binding.airparif/src/main/java/org/openhab/binding/airparif/internal/deserialization/PollutantConcentrationDeserializer.java +++ b/bundles/org.openhab.binding.airparif/src/main/java/org/openhab/binding/airparif/internal/deserialization/PollutantConcentrationDeserializer.java @@ -18,6 +18,8 @@ import org.eclipse.jdt.annotation.NonNullByDefault; import org.eclipse.jdt.annotation.Nullable; import org.openhab.binding.airparif.internal.api.AirParifDto.PollutantConcentration; import org.openhab.binding.airparif.internal.api.Pollutant; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import com.google.gson.JsonArray; import com.google.gson.JsonDeserializationContext; @@ -32,6 +34,7 @@ import com.google.gson.JsonSyntaxException; */ @NonNullByDefault class PollutantConcentrationDeserializer implements JsonDeserializer { + private final Logger logger = LoggerFactory.getLogger(PollutantConcentrationDeserializer.class); @Override public @Nullable PollutantConcentration deserialize(JsonElement json, Type clazz, @@ -44,7 +47,7 @@ class PollutantConcentrationDeserializer implements JsonDeserializer Will not provide any discovery results"); + logger.warn("LocationProvider.getLocation() is not set -> Will not provide any discovery results"); return; } @@ -82,8 +82,6 @@ public class AirParifDiscoveryService extends AbstractThingHandlerDiscoveryServi .withProperty(LocationConfiguration.LOCATION, serverLocation.toFullString())// .withRepresentationProperty(LocationConfiguration.DEPARTMENT) // .withBridge(bridgeUID).build())); - } else { - logger.info("No department could be discovered matching server location"); } } } diff --git a/bundles/org.openhab.binding.airparif/src/main/java/org/openhab/binding/airparif/internal/handler/AirParifBridgeHandler.java b/bundles/org.openhab.binding.airparif/src/main/java/org/openhab/binding/airparif/internal/handler/AirParifBridgeHandler.java index 8784ce3147c..64683f85798 100755 --- a/bundles/org.openhab.binding.airparif/src/main/java/org/openhab/binding/airparif/internal/handler/AirParifBridgeHandler.java +++ b/bundles/org.openhab.binding.airparif/src/main/java/org/openhab/binding/airparif/internal/handler/AirParifBridgeHandler.java @@ -117,6 +117,7 @@ public class AirParifBridgeHandler extends BaseBridgeHandler implements HandlerU "@text/offline.config-error-unknown-apikey"); return; } + updateStatus(ThingStatus.UNKNOWN); scheduler.execute(this::initiateConnexion); } @@ -196,7 +197,7 @@ public class AirParifBridgeHandler extends BaseBridgeHandler implements HandlerU thing.setProperty("api-version", version.version()); thing.setProperty("key-expiration", keyInfo.expiration().toString()); thing.setProperty("scopes", keyInfo.scopes().stream().map(e -> e.name()).collect(Collectors.joining(","))); - logger.info("The api key is valid until {}", keyInfo.expiration().toString()); + logger.debug("The api key is valid until {}", keyInfo.expiration().toString()); updateStatus(ThingStatus.ONLINE); ThingUID thingUID = thing.getUID(); @@ -258,10 +259,8 @@ public class AirParifBridgeHandler extends BaseBridgeHandler implements HandlerU }); }); - ZonedDateTime tomorrowMorning = ZonedDateTime.now().plusDays(1).truncatedTo(ChronoUnit.DAYS).plusMinutes(1); logger.debug("Rescheduling daily air quality bulletin job tomorrow morning"); - schedule(AQ_JOB, () -> updateDailyAQBulletin(todayGroupUID, tomorrowGroupUID), - Duration.between(ZonedDateTime.now(), tomorrowMorning)); + schedule(AQ_JOB, () -> updateDailyAQBulletin(todayGroupUID, tomorrowGroupUID), untilTomorrowMorning()); } private void updateEpisode(ChannelGroupUID dailyGroupUID) { @@ -278,9 +277,12 @@ public class AirParifBridgeHandler extends BaseBridgeHandler implements HandlerU updateState(new ChannelUID(dailyGroupUID, CHANNEL_MESSAGE), new StringType(episode.message().fr())); updateState(new ChannelUID(dailyGroupUID, CHANNEL_TOMORROW), new StringType(episode.message().fr())); - ZonedDateTime tomorrowMorning = ZonedDateTime.now().plusDays(1).truncatedTo(ChronoUnit.DAYS).plusMinutes(1); - schedule(EPISODE_JOB, () -> updateEpisode(dailyGroupUID), - Duration.between(ZonedDateTime.now(), tomorrowMorning)); + schedule(EPISODE_JOB, () -> updateEpisode(dailyGroupUID), untilTomorrowMorning()); + } + + private Duration untilTomorrowMorning() { + return Duration.between(ZonedDateTime.now(), + ZonedDateTime.now().plusDays(1).truncatedTo(ChronoUnit.DAYS).plusMinutes(1)); } public @Nullable Route getConcentrations(String location) { diff --git a/bundles/org.openhab.binding.airparif/src/main/java/org/openhab/binding/airparif/internal/handler/HandlerUtils.java b/bundles/org.openhab.binding.airparif/src/main/java/org/openhab/binding/airparif/internal/handler/HandlerUtils.java index df2aec547da..4b3528f8102 100644 --- a/bundles/org.openhab.binding.airparif/src/main/java/org/openhab/binding/airparif/internal/handler/HandlerUtils.java +++ b/bundles/org.openhab.binding.airparif/src/main/java/org/openhab/binding/airparif/internal/handler/HandlerUtils.java @@ -62,12 +62,12 @@ public interface HandlerUtils { default void schedule(String jobName, Runnable job, Duration duration) { ScheduledFuture result = getJobs().remove(jobName); - String operation = "Scheduling"; + + getLogger().debug("{} {} in {}", result != null ? "Rescheduled" : "Scheduling", jobName, duration); if (result != null) { - operation = "Rescheduled"; cancelFuture(result); } - getLogger().info("{} {} in {}", operation, jobName, duration); + getJobs().put(jobName, getScheduler().schedule(job, duration.getSeconds(), TimeUnit.SECONDS)); } diff --git a/bundles/org.openhab.binding.airparif/src/main/resources/OH-INF/i18n/airparif.properties b/bundles/org.openhab.binding.airparif/src/main/resources/OH-INF/i18n/airparif.properties index c6250fc92f7..ef0d892ad5f 100755 --- a/bundles/org.openhab.binding.airparif/src/main/resources/OH-INF/i18n/airparif.properties +++ b/bundles/org.openhab.binding.airparif/src/main/resources/OH-INF/i18n/airparif.properties @@ -11,10 +11,10 @@ thing-type.airparif.api.group.aq-bulletin.label = Today's Air Quality Bulletin thing-type.airparif.api.group.aq-bulletin-tomorrow.label = Tomorrow's Air Quality Bulletin thing-type.airparif.location.label = Department Report thing-type.airparif.location.description = AirParif air quality report for the given location -thing-type.airparif.location.group.no2.label = NO2 Concentration Information -thing-type.airparif.location.group.o3.label = Ozone Concentration Information -thing-type.airparif.location.group.pm10.label = PM10 Concentration Information -thing-type.airparif.location.group.pm25.label = PM2.5 Concentration Information +thing-type.airparif.location.group.no2.label = NO2 Concentration +thing-type.airparif.location.group.o3.label = Ozone Concentration +thing-type.airparif.location.group.pm10.label = PM10 Concentration +thing-type.airparif.location.group.pm25.label = PM2.5 Concentration # thing types config @@ -60,12 +60,12 @@ channel-group-type.airparif.bridge-pollens.channel.comment.label = Situation channel-group-type.airparif.bridge-pollens.channel.comment.description = Current pollens situation channel-group-type.airparif.bridge-pollens.channel.end-validity.label = End Validity channel-group-type.airparif.bridge-pollens.channel.end-validity.description = Bulletin validity end -channel-group-type.airparif.daily.label = Daily information for the region +channel-group-type.airparif.daily.label = Daily Region Information channel-group-type.airparif.daily.channel.message.label = Message channel-group-type.airparif.daily.channel.message.description = Today's daily general information channel-group-type.airparif.daily.channel.tomorrow.label = Tomorrow channel-group-type.airparif.daily.channel.tomorrow.description = Tomorrow's daily general information -channel-group-type.airparif.dept-pollens.label = Pollen information for the department +channel-group-type.airparif.dept-pollens.label = Department Pollen Information channel-group-type.airparif.pollutant-mpc.label = Pollutant Concentration Information channel-group-type.airparif.pollutant-mpc.channel.alert.label = Alert Level channel-group-type.airparif.pollutant-mpc.channel.alert.description = Alert Level associated to pollutant concentration diff --git a/bundles/org.openhab.binding.airparif/src/main/resources/OH-INF/thing/channel-groups.xml b/bundles/org.openhab.binding.airparif/src/main/resources/OH-INF/thing/channel-groups.xml index aff93e79e02..fb2bf70230c 100644 --- a/bundles/org.openhab.binding.airparif/src/main/resources/OH-INF/thing/channel-groups.xml +++ b/bundles/org.openhab.binding.airparif/src/main/resources/OH-INF/thing/channel-groups.xml @@ -101,7 +101,7 @@ - + @@ -115,7 +115,7 @@ - + diff --git a/bundles/org.openhab.binding.airparif/src/main/resources/OH-INF/thing/location.xml b/bundles/org.openhab.binding.airparif/src/main/resources/OH-INF/thing/location.xml index c9a814c19d7..aab4dd83b7f 100755 --- a/bundles/org.openhab.binding.airparif/src/main/resources/OH-INF/thing/location.xml +++ b/bundles/org.openhab.binding.airparif/src/main/resources/OH-INF/thing/location.xml @@ -16,16 +16,16 @@ - + - + - + - +