def initLights():

    print "Light Controller v0.1. Made by Yashi Sharma"
    print "Using McSwindler's python-milight library"

    controller.send(light.color(milight.color_from_rgb(255, 0, 0), 0))
    controller.send(light.color(milight.color_from_rgb(0, 255, 0), 0))
    controller.send(light.color(milight.color_from_rgb(0, 0, 255), 0))
    controller.send(light.white(0))
    controller.send(light.all_off())
Esempio n. 2
0
 def color(self, color=None):
   '''Get and set color'''
   if color != None:
     rgb = milight.color_from_rgb(color[0], color[1], color[2])
     self._controller.send(self._lightbulb.color(rgb, self.group))
     self._currentColor = color
   return self._currentColor
Esempio n. 3
0
    def respond(self,msg,sock):
        splitMsg = msg.msg.split()
        response=""
        
        if splitMsg[0]=='!light':
            red = int(splitMsg[1])
            if red<0:
                red=0
            elif red>255:
                red=255
                
            green = int(splitMsg[2])
            if green<0:
                green=0
            elif green>255:
                green=255
                
            blue = int(splitMsg[3])
            if blue<0:
                blue=0
            elif blue>255:
                blue=255
                
            self.cont.send(self.light.color(milight.color_from_rgb(red,green,blue),self.lightgroup))
            self.lastState = "R"+str(red)+" G"+str(green)+" B"+str(blue)
            response = "Light changed to R"+str(red)+" G"+str(green)+" B"+str(blue)
            
        elif splitMsg[0]=='!disco':
            self.cont.send(self.light.party('rainbow_jump',self.lightgroup))
            self.lastState="Disco Mode"
            response = "Light switched to disco mode"
            
        elif splitMsg[0]=='!swirl':
            self.cont.send(self.light.party('rainbow_swirl',self.lightgroup))
            self.lastState="Rainbow Swirl Mode"
            response = "Light switched to rainbow swirl mode"

        elif splitMsg[0]=='!lightgroup':
            if len(splitMsg)>1:
                if splitMsg[1].isdigit():
                    group = int(splitMsg[1])
                    if group>=1 and group <=4: 
                        self.lightgroup=group
                        self.paramsHaveChanged = True
                        response = "Switched to MiLight light group "+str(group)
                    else:
                        response = "Invalid MiLight light group"
                else:
                    response = "Invalid MiLight light group"
            else:
                response = "No MiLight light group provided"
            
        ircResponse = "PRIVMSG "+channel+" :"+response+"\n"
        sock.sendall(ircResponse.encode('utf-8'))
        return response
Esempio n. 4
0
	def setLight(self, rgb, brightness, group) : 
		self._controller.send(self._light.color(milight.color_from_rgb(*rgb), group))
		self.setBrightness(brightness, group)
Esempio n. 5
0
	def setColor(self, rgb, group) :
		self._controller.send(self._light.color(milight.color_from_rgb(*rgb), group))
def setColor(r, g, b, bulb):
    controller.send(light.color(milight.color_from_rgb(r, g, b), bulb))
Esempio n. 7
0
 def _calcColor(self, colorTuple):
     """ calculates hex value for color from colortuple """
     return milight.color_from_rgb(*colorTuple)
Esempio n. 8
0
 def setColor(self, color, group=None):
     """ sets the color tuple """
     group = group is None and self.group or group
     r = self.controller.send(self.light.color(milight.color_from_rgb(*color), group))
     logger.debug('Set color to %s (group: %s): %s' % (color, self.group, r))