Skip to content

Commit 836581e

Browse files
authored
[mqtt] Treat incoming empty string as NULL for enum (openhab#16641)
Treat incoming empty string as NULL for enum (openhab#16641) Signed-off-by: Cody Cutrer <[email protected]>
1 parent 8329668 commit 836581e

File tree

1 file changed

+5
-1
lines changed
  • bundles/org.openhab.binding.mqtt.generic/src/main/java/org/openhab/binding/mqtt/generic/values

1 file changed

+5
-1
lines changed

bundles/org.openhab.binding.mqtt.generic/src/main/java/org/openhab/binding/mqtt/generic/values/TextValue.java

+5-1
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,11 @@ public State parseMessage(Command command) throws IllegalArgumentException {
106106
final Set<String> states = this.states;
107107
String valueStr = command.toString();
108108
if (states != null && !states.contains(valueStr)) {
109-
throw new IllegalArgumentException("Value " + valueStr + " not within range");
109+
if (valueStr.isEmpty()) {
110+
return UnDefType.NULL;
111+
} else {
112+
throw new IllegalArgumentException("Value " + valueStr + " not within range");
113+
}
110114
}
111115
return new StringType(valueStr);
112116
}

0 commit comments

Comments
 (0)