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 <marcel@verpaalen.com>
  • Loading branch information
marcelrv authored and thinkingstone committed Nov 7, 2021
1 parent 0d5f1c7 commit c45a8cf
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 c45a8cf

Please sign in to comment.