diff --git a/bundles/org.openhab.transform.scale/conf/transform/scale/humidex.scale b/bundles/org.openhab.transform.scale/conf/transform/scale/humidex.scale index 0ed152d56f713..eaa333e18b3bc 100644 --- a/bundles/org.openhab.transform.scale/conf/transform/scale/humidex.scale +++ b/bundles/org.openhab.transform.scale/conf/transform/scale/humidex.scale @@ -4,3 +4,4 @@ [38..45]=avoid exertion [45..54]=dangerous [54..100]=heat stroke imminent +NaN=unknown diff --git a/bundles/org.openhab.transform.scale/src/main/java/org/openhab/transform/scale/internal/ScaleTransformationService.java b/bundles/org.openhab.transform.scale/src/main/java/org/openhab/transform/scale/internal/ScaleTransformationService.java index 5e3a5b16095b8..8538657348ea2 100644 --- a/bundles/org.openhab.transform.scale/src/main/java/org/openhab/transform/scale/internal/ScaleTransformationService.java +++ b/bundles/org.openhab.transform.scale/src/main/java/org/openhab/transform/scale/internal/ScaleTransformationService.java @@ -129,7 +129,7 @@ private String formatResult(Map data, String source, final BigDec private String getScaleResult(Map data, String source, final BigDecimal value) throws TransformationException { - return data.entrySet().stream().filter(entry -> entry.getKey().contains(value)).findFirst() + return data.entrySet().stream().filter(entry -> entry.getKey() != null && entry.getKey().contains(value)).findFirst() .map(Map.Entry::getValue) .orElseThrow(() -> new TransformationException("No matching range for '" + source + "'")); } diff --git a/bundles/org.openhab.transform.scale/src/test/java/org/openhab/transform/scale/internal/ScaleTransformServiceTest.java b/bundles/org.openhab.transform.scale/src/test/java/org/openhab/transform/scale/internal/ScaleTransformServiceTest.java index a32a786417b67..17836e536badb 100644 --- a/bundles/org.openhab.transform.scale/src/test/java/org/openhab/transform/scale/internal/ScaleTransformServiceTest.java +++ b/bundles/org.openhab.transform.scale/src/test/java/org/openhab/transform/scale/internal/ScaleTransformServiceTest.java @@ -146,4 +146,12 @@ public void testTransformAndFormat() throws TransformationException { String transformedResponse = processor.transform(existingscale, source); Assert.assertEquals("Correcte (992) !", transformedResponse); } + + @Test + public void testValueExceedsRange() throws TransformationException { + String existingscale = "scale/humidex.scale"; + String source = "200"; + String transformedResponse = processor.transform(existingscale, source); + Assert.assertEquals("", transformedResponse); + } }