Skip to content

Commit

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

Signed-off-by: Cody Cutrer <cody@cutrer.us>
  • Loading branch information
ccutrer committed Apr 28, 2024
1 parent 8329668 commit 836581e
Showing 1 changed file with 5 additions and 1 deletion.
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 836581e

Please sign in to comment.