def test_set_color(self): self.led.send(self.bulb.color(0)) self.led.send(self.bulb.color(127, 1)) red = milight.color_from_hex('#FF0000') self.assertEqual(red, 170) self.led.send(self.bulb.color(red)) blue = milight.color_from_hls(0.66, 0.5, 0.5) self.assertEqual(blue, 1) self.led.send(self.bulb.color(blue))
def test_set_color(self): self.led.send(self.bulb.color(0)) self.led.send(self.bulb.color(127, 1)) red = milight.color_from_hex('#FF0000') self.assertEqual(red, 170) self.led.send(self.bulb.color(red)) blue = milight.color_from_hls(0.66,0.5,0.5) self.assertEqual(blue, 1) self.led.send(self.bulb.color(blue))
def test_white(self): white = self.bulb.white(1) color = self.bulb.color(milight.color_from_hls(0.66, 1, 0.5), 1) self.assertEqual(white, color) self.led.send(white)
def test_color(self): self.led.send(self.bulb.color(milight.color_from_hls(0.66, 0.5, 0.5)))
def setColourHSL(self, hue, sat, light): message = self.group.color(milight.color_from_hls(hue, light, sat)) self.controller.send(message)
print("waiting on port:", port) light = milight.LightBulb(['rgbw']) #Can specify which types of bulbs to use controller.send(light.on(1)) # Turn on group 1 lights status = "on"; try: while True: d = s.recvfrom(3) new = bytearray(d[0]) # print (colorsys.rgb_to_hls(new[0]/255, new[1]/255, new[2]/255)) if new != last: hls = colorsys.rgb_to_hls(new[0]/255, new[1]/255, new[2]/255); bri = round(100 / 255 * ((new[0]*299) + (new[1]*587) + (new[0]*114)) / 1000) if bri == 0: controller.send(light.color(milight.color_from_rgb(0,0,0), 1)) elif hls[0] == 0 and hls[2] == 0: controller.send(light.color(milight.color_from_rgb(255,255,255), 1)) controller.send(light.brightness(bri, 1)) else: controller.send(light.color(milight.color_from_hls(*hls), 1)) controller.send(light.brightness(bri, 1)) print (bri) last = new except KeyboardInterrupt: print("Exit ...")
def test_white(self): white = self.bulb.white(1) color = self.bulb.color(milight.color_from_hls(0.66,1,0.5), 1) self.assertEqual(white, color) self.led.send(white)
def test_color(self): self.led.send(self.bulb.color(milight.color_from_hls(0.66,0.5,0.5)))