Skip to content

Commit

Permalink
Moonlight: Fix parameters of the set_rgb api call (#435)
Browse files Browse the repository at this point in the history
  • Loading branch information
syssi authored Dec 12, 2018
1 parent 2e63681 commit 6db862d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
4 changes: 2 additions & 2 deletions miio/philips_moonlight.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ def set_rgb(self, rgb: Tuple[int, int, int]):
if color < 0 or color > 255:
raise PhilipsMoonlightException("Invalid color: %s" % color)

return self.send("set_rgb", [rgb_to_int(rgb)])
return self.send("set_rgb", [*rgb])

@command(
click.argument("level", type=int),
Expand Down Expand Up @@ -241,7 +241,7 @@ def set_brightness_and_rgb(self, brightness: int, rgb: Tuple[int, int, int]):
if color < 0 or color > 255:
raise PhilipsMoonlightException("Invalid color: %s" % color)

return self.send("set_brirgb", [brightness, rgb_to_int(rgb)])
return self.send("set_brirgb", [*rgb, brightness])

@command(
click.argument("number", type=int),
Expand Down
12 changes: 5 additions & 7 deletions miio/tests/test_philips_moonlight.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from miio import PhilipsMoonlight
from miio.philips_moonlight import PhilipsMoonlightStatus, PhilipsMoonlightException
from miio.utils import int_to_rgb
from miio.utils import int_to_rgb, rgb_to_int
from .dummies import DummyDevice


Expand All @@ -30,15 +30,15 @@ def __init__(self, *args, **kwargs):
'set_power': lambda x: self._set_state("pow", x),
'set_bright': lambda x: self._set_state("bri", x),
'set_cct': lambda x: self._set_state("cct", x),
'set_rgb': lambda x: self._set_state("rgb", x),
'set_rgb': lambda x: self._set_state("rgb", [rgb_to_int(x)]),
'apply_fixed_scene': lambda x: self._set_state("snm", x),
'set_bricct': lambda x: (
self._set_state('bri', [x[0]]),
self._set_state('cct', [x[1]])
self._set_state('cct', [x[1]]),
),
'set_brirgb': lambda x: (
self._set_state('bri', [x[0]]),
self._set_state('rgb', [x[1]])
self._set_state('rgb', [rgb_to_int((x[0], x[1], x[2]))]),
self._set_state('bri', [x[3]]),
)
}
super().__init__(args, kwargs)
Expand Down Expand Up @@ -229,8 +229,6 @@ def rgb():
with pytest.raises(PhilipsMoonlightException):
self.device.set_brightness_and_rgb(10, (0, 0, 256))



def test_set_scene(self):
def scene():
return self.device.status().scene
Expand Down

0 comments on commit 6db862d

Please sign in to comment.