diff --git a/bundles/org.openhab.transform.scale/conf/transform/scale/spektrum.scale b/bundles/org.openhab.transform.scale/conf/transform/scale/spektrum.scale
new file mode 100644
index 0000000000000..c305b82a18add
--- /dev/null
+++ b/bundles/org.openhab.transform.scale/conf/transform/scale/spektrum.scale
@@ -0,0 +1,4 @@
+[..10]=Kaltweiß
+]10..90[=Gemischt
+[90..100]=Warmweiß
+NaN=Unbekannt
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..e5afba155c4e0 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
@@ -93,7 +93,7 @@ public Object put(Object key, Object value) {
* The method transforms the input source
by matching searching
* the range where it fits i.e. [min..max]=value or ]min..max]=value
*
- * @param properties the list of properties defining all the available ranges
+ * @param data the list of properties defining all the available ranges
* @param source the input to transform
*
*/
@@ -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..999c77c772ce8 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/spektrum.scale";
+ String source = "2409";
+ String transformedResponse = processor.transform(existingscale, source);
+ Assert.assertEquals("", transformedResponse);
+ }
}