Ejemplo n.º 1
0
 def rgb(self, value):
     is_tuple = isinstance(value, Tuple)
     if self.reverse:
         if not is_tuple:
             value = int_to_rgb(value)
         value = list(value)
     elif is_tuple:
         return rgb_to_int(value)
     return value
Ejemplo n.º 2
0
    def test_status(self):
        self.device._reset_state()

        assert repr(self.state()) == repr(PhilipsMoonlightStatus(self.device.start_state))

        assert self.is_on() is True
        assert self.state().brightness == self.device.start_state["bri"]
        assert self.state().color_temperature == self.device.start_state["cct"]
        assert self.state().rgb == int_to_rgb(int(self.device.start_state["rgb"]))
        assert self.state().scene == self.device.start_state["snm"]
Ejemplo n.º 3
0
 def hs_color(self):
     if self._prop_color:
         num = round(self._prop_color.from_dict(self._state_attrs) or 0)
         rgb = int_to_rgb(num)
         return color.color_RGB_to_hs(*rgb)
     return None
Ejemplo n.º 4
0
 def rgb(self) -> Optional[Tuple[int, int, int]]:
     """Return color in RGB if RGB mode is active."""
     rgb = self.data[self.get_prop_name("rgb")]
     if self.color_mode == YeelightMode.RGB and rgb:
         return int_to_rgb(int(rgb))
     return None
Ejemplo n.º 5
0
 def hs_color(self):
     if 'rgb' in self._state_attrs:
         rgb = int_to_rgb(int(self._state_attrs['rgb'] or 0))
         return color.color_RGB_to_hs(*rgb)
     return None
Ejemplo n.º 6
0
 def rgb(self) -> Tuple[int, int, int]:
     """Return color in RGB."""
     return int_to_rgb(int(self.data["rgb"]))
Ejemplo n.º 7
0
 def rgb_color(self):
     """Return the rgb color value [int, int, int]."""
     if self._prop_color:
         num = int(self._prop_color.from_dict(self._state_attrs) or 0)
         return int_to_rgb(num)
     return None