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]>
Signed-off-by: Patrik Gfeller <[email protected]>
  • Loading branch information
ccutrer authored and pgfeller committed Sep 29, 2024
1 parent 837ec89 commit 8de2e76
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 8de2e76

Please sign in to comment.