Skip to content

Commit

Permalink
[miio] fix color lights sending numbers as strings (#10960)
Browse files Browse the repository at this point in the history
* [miio] fix color lights sending numbers as strings

Signed-off-by: Marcel Verpaalen <marcel@verpaalen.com>
  • Loading branch information
marcelrv committed Jul 12, 2021
1 parent 29acaf6 commit c0ab022
Show file tree
Hide file tree
Showing 2 changed files with 304 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -598,7 +598,8 @@ private void updateChannel(@Nullable MiIoBasicChannel basicChannel, String param
}
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);
Expand Down
Loading

0 comments on commit c0ab022

Please sign in to comment.