예제 #1
0
	def setStatusBarInfo(self,info):
		log("",self)
		try:
			if self.currentScreen != None:
				self.currentScreen.handleFromThread(self.currentScreen.setStatusBarInfo,_("Info: ["+ info +"]"))
				pass
			#clear info
			self.clearStatusInfo = 2
		except:
			from traceback import format_exc
			log("",self,"Error: "+format_exc())
			try:
				open(getCrashFilePath(),"w").write(format_exc())
				if config.plugins.enigmalight.message_error_onoff.value:
					showError(self.session, (format_exc()), "E")
			except:
				pass
예제 #2
0
	def setStatusBarInfo(self,info):
		log("",self)
		try:
			if self.currentScreen != None:
				self.currentScreen.handleFromThread(self.currentScreen.setStatusBarInfo,_("Info: ["+ info +"]"))
				pass
			#clear info
			self.clearStatusInfo = 2
		except:
			from traceback import format_exc
			log("",self,"Error: "+format_exc())
			try:
				open(getCrashFilePath(),"w").write(format_exc())
				if config.plugins.enigmalight.message_error_onoff.value:
					showError(self.session, (format_exc()), "E")
			except:
				pass
예제 #3
0
	def getCpu(self):
		#log("",self)
		try:
			cpu = commands.getstatusoutput('top -n1 | grep "enigmalight" | awk \'{print $7}\'')
			cpu_split = str(cpu).split("'")
			cpu = cpu_split[1][:3]#remove new line and other stuff
			cpu = cpu.replace("\\","")
			#print ("[EnigmaLight] Cpu usage [" + cpu + "]")
			self.current_cpu = cpu
		except:
			from traceback import format_exc
			log("",self,"Error: "+format_exc())
			try:
				open(getCrashFilePath(),"w").write(format_exc())
				if config.plugins.enigmalight.message_error_onoff.value:
					showError(self.session, (format_exc()), "E")
			except:
				pass
예제 #4
0
	def getCpu(self):
		#log("",self)
		try:
			cpu = commands.getstatusoutput('top -n1 | grep "enigmalight" | awk \'{print $7}\'')
			cpu_split = str(cpu).split("'")
			cpu = cpu_split[1][:3]#remove new line and other stuff
			cpu = cpu.replace("\\","")
			#print ("[EnigmaLight] Cpu usage [" + cpu + "]")
			self.current_cpu = cpu
		except:
			from traceback import format_exc
			log("",self,"Error: "+format_exc())
			try:
				open(getCrashFilePath(),"w").write(format_exc())
				if config.plugins.enigmalight.message_error_onoff.value:
					showError(self.session, (format_exc()), "E")
			except:
				pass
예제 #5
0
    def run(self):
        log("", self, "ControlThread: Running...")

        checkLoop = 4  # check every 2 sec for cpu usage
        loopCount = 0

        while (self.thread_running):

            #Check connection
            self.sockClass.checkConnection()

            #if not connected then connect with it.
            if self.sockClass.connectedWithEnigmalight():
                self.readInfo()  #get runninginfo
            else:
                self.lightsEnabled = False
                self.current_fps = "0"
                self.current_resolution = "0x0"
                self.current_mode = "Off"
                self.current_cpu = "0"

            #when checkloop is 2 then getcpu

            if (loopCount == checkLoop):
                #self.getCpu()
                loopCount = 0
            else:
                loopCount += 1

        #check mode
            if config.plugins.enigmalight.network_onoff.value:
                ext = "Daemon %s:%s" % (
                    str(config.plugins.enigmalight.address.getText()),
                    str(config.plugins.enigmalight.port.getText()))
            elif config.plugins.enigmalight.type.value == "WifiLight":
                ext = "Local [Wifilight] %s:%s" % (
                    str(config.plugins.enigmalight.wifilight_ip.getText()),
                    str(config.plugins.enigmalight.wifilight_port.getText()))
            else:
                ext = "Local"

            if (self.current_mode == "0" and not self.serverstate):
                mode = _("[Server] Idle")
                self.lightsEnabled = False
            elif (self.current_mode == "0" and self.serverstate):
                mode = _("[Server] Client connected (%s)" %
                         (self.connectedAddres))
                self.lightsEnabled = False
            elif (self.current_mode == "1"):
                mode = _("[Moodlamp] %s | Static color" % (ext))
                self.lightsEnabled = True
            elif (self.current_mode == "2"):
                mode = _("[Dynamic] %s | %s") % (ext, self.current_resolution)
                self.lightsEnabled = True
            elif (self.current_mode == "3"):
                mode = _("[Moodlamp] %s | RGBtest" % (ext))
                self.lightsEnabled = True
            elif (self.current_mode == "4"):
                mode = _("[Moodlamp] %s | ColorFader" % (ext))
                self.lightsEnabled = True
            elif (self.current_mode == "5"):
                mode = _("[Moodlamp] %s | Rainbow" % (ext))
                self.lightsEnabled = True
            else:
                mode = "Off"
                self.lightsEnabled = False

            if self.currentScreen != None and self.mainScreen != None:
                self.currentScreen.handleFromThread(
                    self.currentScreen.showButtons)

            #Set StatusBar text
            if not self.lightsEnabled and not self.sockClass.connected:
                status = _("Not Running")
                mode = "Off"
            elif self.lightsEnabled and self.sockClass.connected:
                status = _("LightsOn")
            elif not self.lightsEnabled and self.sockClass.connected:
                status = _("LightsOff")

            #Statusbar
            if self.currentScreen != None:
                stContent = _("Status: %s | Current mode: %s | FPS: %s") % (
                    status, mode, self.current_fps)
                try:
                    #self.currentScreen.handleFromThread("setStatusBarTxt",stContent)
                    self.currentScreen.handleFromThread(
                        self.currentScreen.setStatusBarTxt, stContent)
                except:
                    from traceback import format_exc
                    log("", self, "Error: " + format_exc())
                    try:
                        open(getCrashFilePath(), "w").write(format_exc())
                        if config.plugins.enigmalight.message_error_onoff.value:
                            showError(self.session, (format_exc()), "E")
                    except:
                        pass

                #clear info
                if self.clearStatusInfo != None and self.clearStatusInfo == loopCount:
                    try:
                        #self.currentScreen.handleFromThread("setStatusBarInfo","")
                        self.currentScreen.handleFromThread(
                            self.currentScreen.setStatusBarInfo, "")
                        #clear info
                        self.clearStatusInfo = None
                    except:
                        from traceback import format_exc
                        log("", self, "Error: " + format_exc())
                        try:
                            open(getCrashFilePath(), "w").write(format_exc())
                            if config.plugins.enigmalight.message_error_onoff.value:
                                showError(self.session, (format_exc()), "E")
                        except:
                            pass

            time.sleep(0.5)

        log("ControlThread: exit...")
        self.thread_running = False
예제 #6
0
    def changeValue(self, currentoption):
        log("", self)
        color = None
        value = str(currentoption.getValue())
        text = str(currentoption.getText())

        self.setStatusBarInfo("changeValue")

        try:

            if self.lightsEnabled == True:
                if currentoption == config.plugins.enigmalight.mode:
                    if text == _("Moodlamp"):
                        if self.current_mode == "2" or self.current_mode != None:
                            self.writeMoodlamp()

                    elif text == _("Dynamic") and self.current_mode != "2":
                        self.writeDynamic()

                elif currentoption == config.plugins.enigmalight.moodlamp_mode:  #Change mode only when mode is set to moodlamp
                    if self.current_mode != "2" and self.current_mode != None:
                        self.writeMoodlamp()

                #elif currentoption == config.plugins.enigmalight.presets: #send all setting
                #	self.sendAll()

                elif currentoption == config.plugins.enigmalight.moodlamp_static_color_r or currentoption == config.plugins.enigmalight.moodlamp_static_color_g or currentoption == config.plugins.enigmalight.moodlamp_static_color_b or currentoption == config.plugins.enigmalight.moodlamp_fader_brightness or currentoption == config.plugins.enigmalight.adjustr or currentoption == config.plugins.enigmalight.adjustg or currentoption == config.plugins.enigmalight.adjustb or currentoption == config.plugins.enigmalight.use_live_adjust:

                    data = self.writeAdjust()

                    #data +="set color_sequence " + str(config.plugins.enigmalight.color_sequence.getValue()) + "\n"

                    if self.current_mode != "2" and self.current_mode != None:
                        color = self.getColor()

                        data += "set static_color " + str(color) + "\n"
                        data += "set moodlamp_brightness" + str(
                            config.plugins.enigmalight.
                            moodlamp_fader_brightness.getValue()) + "\n"

                    self.sockClass.setCommand(data)

                elif currentoption == config.plugins.enigmalight.saturation:
                    data = "set saturation " + str(value) + "\n"
                    self.sockClass.setCommand(data)
                elif currentoption == config.plugins.enigmalight.saturationmin:
                    data = "set saturationmin " + str(value) + "\n"
                    self.sockClass.setCommand(data)
                elif currentoption == config.plugins.enigmalight.saturationmax:
                    data = "set saturationmax " + str(value) + "\n"
                    self.sockClass.setCommand(data)
                elif currentoption == config.plugins.enigmalight.value:
                    data = "set value " + str(value) + "\n"
                    self.sockClass.setCommand(data)
                elif currentoption == config.plugins.enigmalight.valuemin:
                    data = "set valuemin " + str(value) + "\n"
                    self.sockClass.setCommand(data)
                elif currentoption == config.plugins.enigmalight.valuemax:
                    data = "set valuemax " + str(value) + "\n"
                    self.sockClass.setCommand(data)
                elif currentoption == config.plugins.enigmalight.speed:
                    data = "set speed " + str(value) + "\n"
                    self.sockClass.setCommand(data)
                elif currentoption == config.plugins.enigmalight.delay:
                    data = "set delay " + str(value) + "\n"
                    self.sockClass.setCommand(data)
                elif currentoption == config.plugins.enigmalight.autospeed:
                    data = "set autospeed " + str(value) + "\n"
                    self.sockClass.setCommand(data)
                elif currentoption == config.plugins.enigmalight.interval:
                    data = "set interval " + str(value) + "\n"
                    self.sockClass.setCommand(data)
                elif currentoption == config.plugins.enigmalight.gamma:
                    data = "set gamma " + str(value) + "\n"
                    self.sockClass.setCommand(data)
                elif currentoption == config.plugins.enigmalight.m_3dmode:
                    data = "set 3dmode " + str(value) + "\n"
                    self.sockClass.setCommand(data)
                elif currentoption == config.plugins.enigmalight.interpolation:
                    data = "set saturation " + str(value) + "\n"
                    self.sockClass.setCommand(data)
                elif currentoption == config.plugins.enigmalight.blackbar_h:
                    data = "set blackbar_h " + str(value) + "\n"
                    data += "set blackbar_f " + str(value) + "\n"
                    self.sockClass.setCommand(data)
                elif currentoption == config.plugins.enigmalight.blackbar_v:
                    data = "set blackbar_v " + str(value) + "\n"
                    data += "set blackbar_f " + str(value) + "\n"
                    self.sockClass.setCommand(data)
                elif currentoption == config.plugins.enigmalight.blackbar_f:
                    data = "set blackbar_f " + str(value) + "\n"
                    self.sockClass.setCommand(data)
                elif currentoption == config.plugins.enigmalight.threshold:
                    data = "set threshold " + str(value) + "\n"
                    self.sockClass.setCommand(data)
                elif currentoption == config.plugins.enigmalight.cluster:
                    data = "set cluster " + str(value) + "\n"
                    self.sockClass.setCommand(data)

        except:
            from traceback import format_exc
            log("", self, "Error: " + format_exc())
            try:
                open(getCrashFilePath(), "w").write(format_exc())
                if config.plugins.enigmalight.message_error_onoff.value:
                    showError(self.session, (format_exc()), "E")
            except:
                pass
예제 #7
0
    def DoControl(self, result, retval, extra_args=None):
        log("", self)
        (checkResult, control, callback) = extra_args
        ret = 0
        error = False

        commandResult = str(result)

        if checkResult:
            #sleep one sec before do next step.
            time.sleep(1)
            if commandResult.find("ERROR:") != -1:
                self.showResult(str(result))
                error = True

        if error is False:
            try:

                if control['value'] == "stop":

                    self.setStatusBarInfo(_("Stop lights.."))

                    if config.plugins.enigmalight.server.value is True and config.plugins.enigmalight.network_onoff.value == False:
                        #Switch to server
                        log(
                            "", self,
                            "config.plugins.enigmalight.server.value is true, Start server"
                        )
                        data = "set mode 0\n"
                        ret = self.sockClass.setCommand(data)

                    else:
                        #kill enigmalight
                        data = "set mode stop\n"
                        self.sockClass.setCommand(data)
                    if config.plugins.enigmalight.message_onoff.getValue():
                        showMessage(self.session,
                                    _("Control: Lights disabled."), "I")

                elif control['value'] == "dynamic":

                    self.setStatusBarInfo(_("Start lights.."))

                    ret = self.controlMode()

                    if config.plugins.enigmalight.message_onoff.getValue():
                        showMessage(self.session,
                                    _("Control: Lights enabled."), "I")

                elif control['value'] == "configtest":

                    self.setStatusBarInfo(_("Change mode"))

                    data = "set mode 3\n"
                    ret = self.sockClass.setCommand(data)  #3 test

                    if config.plugins.enigmalight.message_onoff.getValue():
                        showMessage(self.session,
                                    _("Control: Lights enabled, mode[test]"),
                                    "I")

                elif control['value'] == "server":

                    self.setStatusBarInfo(_("Change mode"))

                    data = "set mode 0\n"
                    ret = self.sockClass.setCommand(data)

                elif control['value'] == "moodlamp":

                    self.setStatusBarInfo(_("Change mode"))

                    ret = self.writeMoodlamp()

                    if config.plugins.enigmalight.message_onoff.getValue():
                        showMessage(
                            self.session,
                            _("Control: Lights enabled, mode[%s]") %
                            (str(config.plugins.enigmalight.moodlamp_mode.
                                 getText())), "I")

                elif control['value'] == "sleep":

                    if config.plugins.enigmalight.standbymode.value == str(1):
                        #Start Moodlamp
                        ret = self.writeMoodlamp()

                    elif config.plugins.enigmalight.standbymode.value == str(
                            0):

                        if config.plugins.enigmalight.server.value is True and config.plugins.enigmalight.network_onoff.value == False:
                            #Switch to server
                            log(
                                "", self,
                                "config.plugins.enigmalight.server.value is true, Start server"
                            )
                            data = "set mode 0\n"
                            ret = self.sockClass.setCommand(data)
                        else:
                            #disable lights
                            data = "set mode stop\n"
                            ret = self.sockClass.setCommand(data)

                elif control['value'] == "wakeup":
                    ret = self.controlMode()

                if self.currentScreen != None and self.mainScreen != None:
                    self.currentScreen.handleFromThread(
                        self.currentScreen.showButtons)

                #Send all values
                if ret == 1:
                    if control['value'] == "dynamic" or control[
                            'value'] == "restart" or control[
                                'value'] == "wakeup":
                        self.sendAll(True)

                if control['value'] != "stop" and control['value'] != "sleep":
                    self.writeSettings()

                return ret

            except:
                from traceback import format_exc
                log("", self, "Error: " + format_exc())
                try:
                    open(getCrashFilePath(), "w").write(format_exc())
                    if config.plugins.enigmalight.message_error_onoff.value:
                        showError(self.session, (format_exc()), "E")
                except:
                    pass
예제 #8
0
	def run(self):
		log("",self,"ControlThread: Running...")
		
		checkLoop = 4 # check every 2 sec for cpu usage
		loopCount = 0

		while(self.thread_running):

			#Check connection
			self.sockClass.checkConnection()

			#if not connected then connect with it.
			if self.sockClass.connectedWithEnigmalight():
				self.readInfo() #get runninginfo				
			else:
				self.lightsEnabled = False
				self.current_fps = "0"
				self.current_resolution = "0x0"
				self.current_mode = "Off"
				self.current_cpu = "0"

			#when checkloop is 2 then getcpu
			
		 	if(loopCount == checkLoop):		 		
		 		#self.getCpu()
		 		loopCount = 0
		 	else:
		 		loopCount += 1
		 	

		 	#check mode
		 	if config.plugins.enigmalight.network_onoff.value:
		 		ext = "Daemon %s:%s" %(str(config.plugins.enigmalight.address.getText()),str(config.plugins.enigmalight.port.getText()))
		 	elif config.plugins.enigmalight.type.value == "WifiLight": 
		 		ext = "Local [Wifilight] %s:%s" %(str(config.plugins.enigmalight.wifilight_ip.getText()),str(config.plugins.enigmalight.wifilight_port.getText()))
		 	else:
		 		ext = "Local"
		 	

		 	

			if(self.current_mode == "0" and not self.serverstate):
				mode = _("[Server] Idle")
				self.lightsEnabled = False
			elif(self.current_mode == "0" and self.serverstate):
				mode = _("[Server] Client connected (%s)" %(self.connectedAddres))
				self.lightsEnabled = False
			elif(self.current_mode == "1"):
				mode = _("[Moodlamp] %s | Static color" %(ext))
				self.lightsEnabled = True
			elif(self.current_mode == "2"):
				mode = _("[Dynamic] %s | %s") %(ext,self.current_resolution)
				self.lightsEnabled = True
			elif(self.current_mode == "3"):
				mode = _("[Moodlamp] %s | RGBtest" %(ext))
				self.lightsEnabled = True
			elif(self.current_mode == "4"):
				mode = _("[Moodlamp] %s | ColorFader" %(ext))
				self.lightsEnabled = True
			elif(self.current_mode == "5"):
				mode = _("[Moodlamp] %s | Rainbow" %(ext))
				self.lightsEnabled = True
			else:
				mode = "Off"
				self.lightsEnabled = False
			

			if self.currentScreen != None and self.mainScreen != None:
				self.currentScreen.handleFromThread(self.currentScreen.showButtons)

			#Set StatusBar text
			if not self.lightsEnabled and not self.sockClass.connected:
				status = _("Not Running")
				mode   = "Off"
			elif self.lightsEnabled and self.sockClass.connected:
				status = _("LightsOn")
			elif not self.lightsEnabled and self.sockClass.connected:
				status = _("LightsOff")
			

			#Statusbar
			if self.currentScreen != None:
				stContent = _("Status: %s | Current mode: %s | FPS: %s") %(status,mode,self.current_fps)
				try:
					#self.currentScreen.handleFromThread("setStatusBarTxt",stContent)
					self.currentScreen.handleFromThread(self.currentScreen.setStatusBarTxt,stContent)
				except:
					from traceback import format_exc
					log("",self,"Error: "+format_exc())
					try:
						open(getCrashFilePath(),"w").write(format_exc())
						if config.plugins.enigmalight.message_error_onoff.value:
							showError(self.session, (format_exc()), "E")
					except:
						pass

				#clear info
				if self.clearStatusInfo != None and self.clearStatusInfo == loopCount:
					try:
						#self.currentScreen.handleFromThread("setStatusBarInfo","")
						self.currentScreen.handleFromThread(self.currentScreen.setStatusBarInfo,"")
						#clear info
						self.clearStatusInfo = None
					except:
						from traceback import format_exc
						log("",self,"Error: "+format_exc())
						try:
							open(getCrashFilePath(),"w").write(format_exc())
							if config.plugins.enigmalight.message_error_onoff.value:
								showError(self.session, (format_exc()), "E")
						except:
							pass

			time.sleep(0.5)

		log("ControlThread: exit...")
		self.thread_running = False
예제 #9
0
	def changeValue(self, currentoption):
		log("",self)
		color = None
		value = str(currentoption.getValue())
		text  = str(currentoption.getText())
		
		self.setStatusBarInfo("changeValue")

		try:

			if self.lightsEnabled == True:
				if currentoption == config.plugins.enigmalight.mode:
					if text == _("Moodlamp"):
						if self.current_mode == "2" or self.current_mode != None:
							self.writeMoodlamp()

					elif text == _("Dynamic") and self.current_mode != "2":
						self.writeDynamic()

				elif currentoption == config.plugins.enigmalight.moodlamp_mode:  #Change mode only when mode is set to moodlamp
					if self.current_mode != "2" and self.current_mode != None:				
						self.writeMoodlamp()

				#elif currentoption == config.plugins.enigmalight.presets: #send all setting
				#	self.sendAll()
					
				elif currentoption == config.plugins.enigmalight.moodlamp_static_color_r or currentoption == config.plugins.enigmalight.moodlamp_static_color_g or currentoption == config.plugins.enigmalight.moodlamp_static_color_b or currentoption == config.plugins.enigmalight.moodlamp_fader_brightness or currentoption == config.plugins.enigmalight.adjustr or currentoption == config.plugins.enigmalight.adjustg or currentoption == config.plugins.enigmalight.adjustb or currentoption == config.plugins.enigmalight.use_live_adjust:
					
					data = self.writeAdjust()
					
					#data +="set color_sequence " + str(config.plugins.enigmalight.color_sequence.getValue()) + "\n"

					if self.current_mode != "2" and self.current_mode != None:
						color = self.getColor()
											
						data +="set static_color " + str(color) + "\n"
						data +="set moodlamp_brightness" + str(config.plugins.enigmalight.moodlamp_fader_brightness.getValue()) + "\n"

					self.sockClass.setCommand(data)					

				elif currentoption == config.plugins.enigmalight.saturation:
					data ="set saturation "+ str(value) + "\n"
					self.sockClass.setCommand(data)
				elif currentoption == config.plugins.enigmalight.saturationmin:
					data ="set saturationmin "+ str(value) + "\n"
					self.sockClass.setCommand(data)
				elif currentoption == config.plugins.enigmalight.saturationmax:
					data ="set saturationmax "+ str(value) + "\n"
					self.sockClass.setCommand(data)
				elif currentoption == config.plugins.enigmalight.value:
					data ="set value "+ str(value) + "\n"
					self.sockClass.setCommand(data)
				elif currentoption == config.plugins.enigmalight.valuemin:
					data ="set valuemin "+ str(value) + "\n"
					self.sockClass.setCommand(data)
				elif currentoption == config.plugins.enigmalight.valuemax:
					data ="set valuemax "+ str(value) + "\n"
					self.sockClass.setCommand(data)
				elif currentoption == config.plugins.enigmalight.speed:
					data ="set speed "+ str(value) + "\n"
					self.sockClass.setCommand(data)
				elif currentoption == config.plugins.enigmalight.delay:
					data ="set delay "+ str(value) + "\n"
					self.sockClass.setCommand(data)
				elif currentoption == config.plugins.enigmalight.autospeed:
					data ="set autospeed "+ str(value) + "\n"
					self.sockClass.setCommand(data)
				elif currentoption == config.plugins.enigmalight.interval:
					data ="set interval "+ str(value) + "\n"
					self.sockClass.setCommand(data)
				elif currentoption == config.plugins.enigmalight.gamma:
					data ="set gamma "+ str(value) + "\n"
					self.sockClass.setCommand(data)
				elif currentoption == config.plugins.enigmalight.m_3dmode:
					data ="set 3dmode "+ str(value) + "\n"
					self.sockClass.setCommand(data)
				elif currentoption == config.plugins.enigmalight.interpolation:
					data ="set saturation "+ str(value) + "\n"
					self.sockClass.setCommand(data)
				elif currentoption == config.plugins.enigmalight.blackbar_h:
					data ="set blackbar_h "+ str(value) + "\n"
					data +="set blackbar_f "+ str(value) + "\n"
					self.sockClass.setCommand(data)
				elif currentoption == config.plugins.enigmalight.blackbar_v:
					data ="set blackbar_v "+ str(value) + "\n"
					data +="set blackbar_f "+ str(value) + "\n"
					self.sockClass.setCommand(data)					
				elif currentoption == config.plugins.enigmalight.blackbar_f:
					data ="set blackbar_f "+ str(value) + "\n"
					self.sockClass.setCommand(data)
				elif currentoption == config.plugins.enigmalight.threshold:
					data ="set threshold "+ str(value) + "\n"
					self.sockClass.setCommand(data)
				elif currentoption == config.plugins.enigmalight.cluster:
					data ="set cluster "+ str(value) + "\n"
					self.sockClass.setCommand(data)

		except:
			from traceback import format_exc
			log("",self,"Error: "+format_exc())
			try:
				open(getCrashFilePath(),"w").write(format_exc())
				if config.plugins.enigmalight.message_error_onoff.value:
					showError(self.session, (format_exc()), "E")
			except:
				pass
예제 #10
0
	def DoControl(self, result, retval, extra_args = None):
		log("",self)
		(checkResult, control, callback) = extra_args
		ret = 0
		error = False

		commandResult = str(result)

		if checkResult:
			#sleep one sec before do next step.
			time.sleep(1)
			if commandResult.find("ERROR:") != -1:
				self.showResult(str(result))
				error = True

		if error is False:
			try:
			
				if control['value'] == "stop":
					
					self.setStatusBarInfo(_("Stop lights.."))

					if config.plugins.enigmalight.server.value is True and config.plugins.enigmalight.network_onoff.value == False:
						#Switch to server
						log("",self,"config.plugins.enigmalight.server.value is true, Start server")
						data = "set mode 0\n"
						ret = self.sockClass.setCommand(data)

					else:
						#kill enigmalight
						data = "set mode stop\n"
						self.sockClass.setCommand(data)
					if config.plugins.enigmalight.message_onoff.getValue():
						showMessage(self.session,_("Control: Lights disabled."),"I")
				
				elif control['value'] == "dynamic":

					self.setStatusBarInfo(_("Start lights.."))

					ret = self.controlMode()		

					if config.plugins.enigmalight.message_onoff.getValue():
						showMessage(self.session,_("Control: Lights enabled."),"I")

				elif control['value'] == "configtest":

					self.setStatusBarInfo(_("Change mode"))

					data = "set mode 3\n"
					ret = self.sockClass.setCommand(data) #3 test

					if config.plugins.enigmalight.message_onoff.getValue():
						showMessage(self.session,_("Control: Lights enabled, mode[test]"),"I")

				elif control['value'] == "server":

					self.setStatusBarInfo(_("Change mode"))

					data = "set mode 0\n"
					ret = self.sockClass.setCommand(data)

				elif control['value'] == "moodlamp":

					self.setStatusBarInfo(_("Change mode"))

					ret = self.writeMoodlamp()
					
					if config.plugins.enigmalight.message_onoff.getValue():
						showMessage(self.session,_("Control: Lights enabled, mode[%s]") %(str(config.plugins.enigmalight.moodlamp_mode.getText())),"I")
						
				elif control['value'] == "sleep":
					
					if config.plugins.enigmalight.standbymode.value == str(1):
						#Start Moodlamp
						ret = self.writeMoodlamp()

					elif config.plugins.enigmalight.standbymode.value == str(0):

						if config.plugins.enigmalight.server.value is True and config.plugins.enigmalight.network_onoff.value == False:
							#Switch to server
							log("",self,"config.plugins.enigmalight.server.value is true, Start server")
							data = "set mode 0\n"
							ret = self.sockClass.setCommand(data)
						else:
							#disable lights
							data = "set mode stop\n"
							ret = self.sockClass.setCommand(data)


				elif control['value'] == "wakeup":
					ret = self.controlMode()


				if self.currentScreen != None and self.mainScreen != None:
					self.currentScreen.handleFromThread(self.currentScreen.showButtons)


				#Send all values
				if ret == 1:
					if control['value'] == "dynamic" or control['value'] == "restart" or control['value'] == "wakeup":
						self.sendAll(True)

				if control['value'] != "stop" and control['value'] != "sleep":
					self.writeSettings()

				return ret

			except:
				from traceback import format_exc
				log("",self,"Error: "+format_exc())
				try:
					open(getCrashFilePath(),"w").write(format_exc())
					if config.plugins.enigmalight.message_error_onoff.value:
						showError(self.session, (format_exc()), "E")
				except:
					pass