[mqtt] Treat incoming empty string as NULL for enum (#16641)

Treat incoming empty string as NULL for enum (#16641)

Signed-off-by: Cody Cutrer <cody@cutrer.us>
Signed-off-by: Ciprian Pascu <contact@ciprianpascu.ro>
This commit is contained in:
Cody Cutrer 2024-04-28 13:33:44 -06:00 committed by Ciprian Pascu
parent 39f91e7a7a
commit ee9a0a31bf

View File

@ -106,7 +106,11 @@ public class TextValue extends Value {
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);
}