[miio] fix color lights sending numbers as strings (#10960)

* [miio] fix color lights sending numbers as strings

Signed-off-by: Marcel Verpaalen <marcel@verpaalen.com>
This commit is contained in:
Marcel 2021-07-12 09:53:49 +02:00 committed by GitHub
parent 29acaf6246
commit c0ab022e4e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 304 additions and 11 deletions

View File

@ -598,7 +598,8 @@ public class MiIoBasicHandler extends MiIoAbstractHandler {
}
break;
case "color":
if (val.isJsonPrimitive() && val.getAsJsonPrimitive().isNumber()) {
if (val.isJsonPrimitive()
&& (val.getAsJsonPrimitive().isNumber() || val.getAsString().matches("^[0-9]+$"))) {
Color rgb = new Color(val.getAsInt());
HSBType hsb = HSBType.fromRGB(rgb.getRed(), rgb.getGreen(), rgb.getBlue());
updateState(basicChannel.getChannel(), hsb);