Skip to content

Commit

Permalink
[miio] fix color lights sending numbers as strings (openhab#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 <[email protected]>
  • Loading branch information
marcelrv authored and computergeek1507 committed Jul 13, 2021
1 parent 8d9c9d2 commit 2ad05d3
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 2ad05d3

Please sign in to comment.