Skip to content

Commit

Permalink
[mqtt] Treat incoming empty string as NULL for enum (openhab#16641)
Browse files Browse the repository at this point in the history
Treat incoming empty string as NULL for enum (openhab#16641)

Signed-off-by: Cody Cutrer <[email protected]>
  • Loading branch information
ccutrer authored and joni1993 committed Oct 15, 2024
1 parent 397dbf7 commit 580f8ec
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,11 @@ public State parseMessage(Command command) throws IllegalArgumentException {
final Set<String> states = this.states;
String valueStr = command.toString();
if (states != null && !states.contains(valueStr)) {
throw new IllegalArgumentException("Value " + valueStr + " not within range");
if (valueStr.isEmpty()) {
return UnDefType.NULL;
} else {
throw new IllegalArgumentException("Value " + valueStr + " not within range");
}
}
return new StringType(valueStr);
}
Expand Down

0 comments on commit 580f8ec

Please sign in to comment.