Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Moonlight: Fix parameters of the set_rgb api call #435

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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