]> git.basschouten.com Git - openhab-addons.git/commitdiff
Fix IndexOutOfBoundsException in aggregator function (#11113)
authorAnders Alfredsson <30875102+pacive@users.noreply.github.com>
Sun, 22 Aug 2021 09:53:11 +0000 (11:53 +0200)
committerGitHub <noreply@github.com>
Sun, 22 Aug 2021 09:53:11 +0000 (11:53 +0200)
Signed-off-by: Anders Alfredsson <andersb86@gmail.com>
bundles/org.openhab.binding.smhi/README.md
bundles/org.openhab.binding.smhi/src/main/java/org/openhab/binding/smhi/internal/ForecastAggregator.java
bundles/org.openhab.binding.smhi/src/main/java/org/openhab/binding/smhi/internal/SmhiHandler.java

index f98fc486a2c9d222d5b3f1a9f830ed7c9891ae70..88184356604c00d5669ea70c6034d87447f4056c 100644 (file)
@@ -34,6 +34,7 @@ The complete channel identifier is the channel group id (`hour_<offset>` or `day
 or the number of hours/days from now) + the channel id, concatenated with a `#`.
 
 Examples:
+
 * Temperature for the current hour: `hour_0#t`
 * Total precipitation 3 days from now: `day_3#ptotal`
 
index 1d1c1079c02b6e493be6e639fc1ee233a8a77670..d2c4ea55ac228af22996955afbb000bca6bc4da9 100644 (file)
@@ -64,6 +64,9 @@ public class ForecastAggregator {
      */
     public static Optional<BigDecimal> total(TimeSeries timeSeries, int dayOffset, String parameter) {
         List<Forecast> dayForecasts = timeSeries.getDay(dayOffset);
+        if (dayForecasts.size() == 1) {
+            return dayForecasts.get(0).getParameter(parameter);
+        }
         List<BigDecimal> values = new ArrayList<>();
         for (int i = 0; i < dayForecasts.size(); i++) {
             Forecast current = dayForecasts.get(i);
index 89af596cea059bc9ef1ad9af84f38a4de47ee309..c037fe497937e024b3ed4fe3a641375ef63e29f6 100644 (file)
@@ -254,6 +254,7 @@ public class SmhiHandler extends BaseThingHandler {
         } catch (RuntimeException e) {
             logger.warn("Unexpected exception occurred, please report to the developers: {}: {}", e.getClass(),
                     e.getMessage());
+            logger.debug("Details: ", e);
         }
     }