def killEnigmalightFinisched(self, result, retval, extra_args=None): log("", self) (values, callback) = extra_args log("", self, "values " + str(values)) log("", self, "result " + str(result)) log("", self, "retval " + str(retval)) log("", self, "callback " + str(callback)) time.sleep(1) if len(str(result)) == 0: self.setStatusBarInfo(_("Enigmalight killed.")) if config.plugins.enigmalight.message_onoff.getValue(): showMessage(self.session, _("Enigmalight killed.", "I")) else: self.setStatusBarInfo(_("Enigmalight not killed!")) if config.plugins.enigmalight.message_onoff.getValue(): showMessage( self.session, _("Enigmalight not killed\nresult: %s") % (str(result)), "I") if callback != None: if self.callbackArgs != None: callback( self.callbackArgs) # now do callback from saved callback else: callback()
def Control(self, command, value, startcommand = "enigmalight -m 0 -f", callback = None): log("",self,"Control: c:%s v:%s" %(command, value)) #Set ConfigFile s_command = startcommand + " -c " + str(config.plugins.enigmalight.configfilepath.value) #Don't use config file for client -> host if config.plugins.enigmalight.network_onoff.value: host = str(config.plugins.enigmalight.address.getText()) port = str(config.plugins.enigmalight.port.getText()) s_command = "enigmalight -s " + host + ":" + port if value == "configtest": s_command = startcommand + " -c /tmp/enigmalight.conf.new" control = { 'command': command, 'value': value, 'startcommand': s_command} if config.plugins.enigmalight.network_onoff.value == True: #self.getPid(control,None,self.checkIfRunningFinisched) #only network mode self.checkIfRunningFinisched(control,None) elif os.path.isfile(str(config.plugins.enigmalight.configfilepath.value)) is True: # getpid and execute command self.checkIfRunning -> DoControl self.checkIfRunningFinisched(control,None) else: showMessage(self.session, elightconf_notfound, "W") self.setStatusBarInfo(_("Configfile not found!"))
def Control(self, command, value, startcommand = "enigmalight -m 0 -f", callback = None): log("",self,"Control: c:%s v:%s" %(command, value)) #Set ConfigFile s_command = startcommand + " -c " + str(config.plugins.enigmalight.configfilepath.value) #Don't use config file for client -> host if config.plugins.enigmalight.network_onoff.value: host = str(config.plugins.enigmalight.address.getText()) port = str(config.plugins.enigmalight.port.getText()) s_command = "enigmalight -s " + host + ":" + port if value == "configtest": s_command = startcommand + " -c /tmp/enigmalight.conf.new" control = { 'command': command, 'value': value, 'startcommand': s_command} if config.plugins.enigmalight.network_onoff.value == True: #self.getPid(control,None,self.checkIfRunningFinisched) #only network mode self.checkIfRunningFinisched(control,None) elif os.path.isfile(str(config.plugins.enigmalight.configfilepath.value)) is True: # getpid and execute command self.checkIfRunning -> DoControl self.checkIfRunningFinisched(control,None) else: showMessage(self.session, _(elightconf_notfound), "W") self.setStatusBarInfo(_("Configfile not found!"))
def getCustom(self,profilenr): try: log("",self) fo = open("/usr/lib/enigma2/python/Plugins/Extensions/EnigmaLight/profiles/custom_%s.profile" %(str(profilenr)), "r") customsettings = fo.read(256) fo.close() customsettings = customsettings.split("|") config.plugins.enigmalight.saturation.setValue(customsettings[0]) config.plugins.enigmalight.value.setValue(customsettings[1]) config.plugins.enigmalight.speed.setValue(customsettings[2]) config.plugins.enigmalight.valuemax.setValue(customsettings[3]) config.plugins.enigmalight.valuemin.setValue(customsettings[4]) config.plugins.enigmalight.saturationmin.setValue(customsettings[5]) config.plugins.enigmalight.saturationmax.setValue(customsettings[6]) config.plugins.enigmalight.gamma.setValue(customsettings[7]) config.plugins.enigmalight.threshold.setValue(customsettings[8]) config.plugins.enigmalight.autospeed.setValue(customsettings[9]) if self.controller.lightsEnabled: self.controller.writeSettings() except: from traceback import format_exc log("Error: " + format_exc(),self) try: open(getCrashFilePath(),"w").write(format_exc()) showMessage(self._session,_("Can't get settings from profile...", "W", timeout = 10)) except: pass
def saveCustom(self,profilenr): try: log("",self) fo = open("/usr/lib/enigma2/python/Plugins/Extensions/EnigmaLight/profiles/custom_%s.profile" %(str(profilenr)), "wb") fo.write(str(config.plugins.enigmalight.saturation.value)+"|") fo.write(str(config.plugins.enigmalight.value.value)+"|") fo.write(str(config.plugins.enigmalight.speed.value)+"|") fo.write(str(config.plugins.enigmalight.valuemax.value)+"|") fo.write(str(config.plugins.enigmalight.valuemin.value)+"|") fo.write(str(config.plugins.enigmalight.saturationmin.value)+"|") fo.write(str(config.plugins.enigmalight.saturationmax.value)+"|") fo.write(str(config.plugins.enigmalight.gamma.value)+"|") fo.write(str(config.plugins.enigmalight.threshold.value)+"|") fo.write(str(config.plugins.enigmalight.autospeed.value)) fo.close(); except: from traceback import format_exc log("Error:" +format_exc(),self) try: open(getCrashFilePath(),"w").write(format_exc()) showMessage(self._session,_("Can't write settings to profile...", "W", timeout = 10)) except: pass
def killEnigmalightFinisched(self, result, retval, extra_args = None): log("",self) (values, callback) = extra_args log("",self,"values " + str(values)) log("",self,"result " + str(result)) log("",self,"retval " + str(retval)) log("",self,"callback " + str(callback)) time.sleep(1) if len(str(result)) == 0: self.setStatusBarInfo(_("Enigmalight killed.")) if config.plugins.enigmalight.message_onoff.getValue(): showMessage(self.session,_("Enigmalight killed.","I")) else: self.setStatusBarInfo(_("Enigmalight not killed!")) if config.plugins.enigmalight.message_onoff.getValue(): showMessage(self.session,_("Enigmalight not killed\nresult: %s") %(str(result)),"I") if callback != None: if self.callbackArgs != None: callback(self.callbackArgs) # now do callback from saved callback else: callback()
def checkForUpdate(self,controller): self.controller = controller log("",self,"Check for update....") self.controller.setStatusBarInfo(_("Check for update..")) if testInetConnectivity(): self.url = config.plugins.enigmalight.url.value + config.plugins.enigmalight.updatexml.value log("",self,"Checking URL: " + self.url) try: f = urllib2.urlopen(self.url) html = f.read() dom = parseString(html) update = dom.getElementsByTagName("update")[0] version = update.getElementsByTagName("version")[0] remoteversion = version.childNodes[0].data urls = update.getElementsByTagName("url") currentversion = getVersion() currentbeta = currentversion[-2:] remotebeta = remoteversion[-2:] self.remoteurl = "" for url in urls: self.remoteurl = url.childNodes[0].data #print("""Version: %s - URL: %s""" % (remoteversion, self.remoteurl)) if currentbeta < remotebeta: self.latestVersion = remoteversion self.controller.setStatusBarInfo(_("New update available !!")) #if self.session != None: self.session.openWithCallback(self.startUpdate, MessageBox,_("Your current Version is " + str(currentversion) + "\nUpdate to " + str(remoteversion) + " found!\n\nDo you want to update now?"), MessageBox.TYPE_YESNO) else: self.controller.setStatusBarInfo(_("No update available..")) #if self.session != None: showMessage(self.session, _("No update available.."), "I") except: from traceback import format_exc log("",self,"Error: " +format_exc()) try: log("",self,"Could not download HTTP Page") open(getCrashFilePath(),"w").write(format_exc()) except: pass else: self.controller.setStatusBarInfo(_("No Internetconnection..")) self.session.openWithCallback(self.close, MessageBox,_("No internet connection available or curl is not installed!"), MessageBox.TYPE_INFO)
def keyYellow(self): log("", self) if self.controller.lightsEnabled: #self.hideOnOff() self["btn_yellow"].hide() self["txt_yellow"].hide() self["btn_blue"].show() self["txt_blue"].show() self.controller.Control("grabber", "moodlamp") config.plugins.enigmalight.mode.setValue(1) config.plugins.enigmalight.mode.save() configfile.save() else: showMessage(self.session, _("Can't switch mode, Lights are disabled."), "I", 3)
def keyBlue(self): log("", self) if self.controller.lightsEnabled: #self.hideOnOff() self["btn_yellow"].show() self["txt_yellow"].show() self["btn_blue"].hide() self["txt_blue"].hide() config.plugins.enigmalight.mode.setValue(2) config.plugins.enigmalight.mode.save() configfile.save() self.controller.Control("start", "dynamic") else: showMessage(self.session, _("Can't switch mode, Lights are disabled."), "I", 3) self.refreshMenu()
def keySave(self): log("",self) #check ip if network is true, before save if config.plugins.enigmalight.network_onoff.getValue(): #check ip if not validIP(str(config.plugins.enigmalight.address.getText())): showMessage(self.session,_("Ip address %s is not accepted, check your input and try again.") %(str(config.plugins.enigmalight.address.getText())),"W") else: #check connection if not testDaemonConnectivity(config.plugins.enigmalight.address.getText(),config.plugins.enigmalight.port.value): showMessage(self.session,_("Enigmalight can't connect with %s:%s,\ncheck your input and try again.") %(str(config.plugins.enigmalight.address.getText()),str(config.plugins.enigmalight.port.getValue())),"W") else: showMessage(self.session,_("Test Connection with %s:%s, succesfull!") %(str(config.plugins.enigmalight.address.getText()),str(config.plugins.enigmalight.port.getValue())),"I") self.saveAll() message = self.session.openWithCallback(self.startClient,MessageBox,_("Do you want to (re)start the client and connect with %s:%s ?") %(str(config.plugins.enigmalight.address.getText()),str(config.plugins.enigmalight.port.getValue())), MessageBox.TYPE_YESNO) message.setTitle(_("(Re)start client ?")) else: self.saveAll() if self._hasNetworkChanged: self._hasNetworkChanged = False if self.controller.lightsEnabled: self.controller.killEnigmalight(None,None) message = self.session.openWithCallback(self.startGrabber,MessageBox,_("Do you want to (re)start the client ?"), MessageBox.TYPE_YESNO) message.setTitle(_("(Re)start client ?")) elif self._binTypeChanged: message = self.session.openWithCallback(self.restartEnigmaLight,MessageBox,_("Type of enigmalight has changed, Start this type of Enigmalight ?"), MessageBox.TYPE_YESNO) message.setTitle(_("Start ?")) else: self.close(None)
def keySave(self): log("", self) #check ip if network is true, before save if config.plugins.enigmalight.network_onoff.getValue(): #check ip if not validIP(str(config.plugins.enigmalight.address.getText())): showMessage( self.session, _("Ip address %s is not accepted, check your input and try again." ) % (str(config.plugins.enigmalight.address.getText())), "W") else: #check connection if not testDaemonConnectivity( config.plugins.enigmalight.address.getText(), config.plugins.enigmalight.port.value): showMessage( self.session, _("Enigmalight can't connect with %s:%s,\ncheck your input and try again." ) % (str(config.plugins.enigmalight.address.getText()), str(config.plugins.enigmalight.port.getValue())), "W") else: showMessage( self.session, _("Test Connection with %s:%s, succesfull!") % (str(config.plugins.enigmalight.address.getText()), str(config.plugins.enigmalight.port.getValue())), "I") self.saveAll() message = self.session.openWithCallback( self.startClient, MessageBox, _("Do you want to (re)start the client and connect with %s:%s ?" ) % (str(config.plugins.enigmalight.address.getText()), str(config.plugins.enigmalight.port.getValue())), MessageBox.TYPE_YESNO) message.setTitle(_("(Re)start client ?")) else: self.saveAll() if self._hasNetworkChanged: self._hasNetworkChanged = False if self.controller.lightsEnabled: self.controller.killEnigmalight(None, None) message = self.session.openWithCallback( self.startGrabber, MessageBox, _("Do you want to (re)start the client ?"), MessageBox.TYPE_YESNO) message.setTitle(_("(Re)start client ?")) elif self._binTypeChanged: message = self.session.openWithCallback( self.restartEnigmaLight, MessageBox, _("Type of enigmalight has changed, Start this type of Enigmalight ?" ), MessageBox.TYPE_YESNO) message.setTitle(_("Start ?")) else: self.close(None)
def BuildConfig(self,message): #print("[Boblight] BuildConfig() ...") # # Set default values # if self.createfile: postfix = "" type = "" blacklevel = str(config.plugins.enigmalight.blacklevel.value[0])+"."+str(config.plugins.enigmalight.blacklevel.value[1]) interval = "interval 20000\n" delayafteropen = "" # # Set sections and depth # leds_bottom = config.plugins.enigmalight.lights_bottom.value leds_top = config.plugins.enigmalight.lights_top.value leds_left = config.plugins.enigmalight.lights_left.value leds_right = config.plugins.enigmalight.lights_right.value scanl = config.plugins.enigmalight.scanl.value scanr = config.plugins.enigmalight.scanr.value scant = config.plugins.enigmalight.scant.value scanb = config.plugins.enigmalight.scanb.value # # Bottom values, for tv's with floorstand. # leds_bottom_center = config.plugins.enigmalight.lights_bottom_center.value leds_bottom_left = config.plugins.enigmalight.lights_bottom_left.value leds_bottom_right = config.plugins.enigmalight.lights_bottom_right.value leds_bottom_total = (leds_bottom_left + leds_bottom_right + leds_bottom_center) # # Total channels # channels = (leds_top + leds_left + leds_right + leds_bottom)*3 # # Floorstand calculation # if config.plugins.enigmalight.floorstand.value == str(2): #print("[Boblight] Clockwise") #print("[Boblight] Set floorstand to true") channels = (leds_top + leds_left + leds_right + leds_bottom_total - leds_bottom_center)*3 #print("[Boblight] Channels: "+str(channels)) # total step hScanStep = 100 / leds_bottom_total; # 100 / 20 lights = 5 hScan_center = (hScanStep*leds_bottom_center) # total center hscan // floorstand // emptyplaces*hScanStep = ... 50 hScan_right = (hScanStep*leds_bottom_right) # total right hscan /// light rights*hScanStep = ... 25 hScanCurrent = 0 + (hScan_center - hScan_right); # 25 hScanBottom_left = hScanCurrent; # = 25 is plus hScanBottom_right = 100 # = 25 + 50 = 75 is min # debug #print("[Boblight] hScanBottom_left:"+str(hScanBottom_left)+" hScanBottom_right:"+str(hScanBottom_right)) if config.plugins.enigmalight.clockwise.value == str(2): #backwards #print("[Boblight] Backwards") #print("[Boblight] Set floorstand to true") channels = (leds_top + leds_left + leds_right + leds_bottom_total - leds_bottom_center)*3 #print("[Boblight] channels:"+str(channels)) #total step hScanStep = 100 / leds_bottom_total; # 100 / 20 lights = 5 hScan_center = (hScanStep*leds_bottom_center) # total center hscan // floorstand // emptyplaces*hScanStep = ... 50 hScan_left = (hScanStep*leds_bottom_left) # total left hscan /// light left*hScanStep = ... 25 hScan_right = (hScanStep*leds_bottom_right) hScanCurrent = (hScan_center + hScan_left); # 75 hScanBottom_left = 0.0; # = 75 hScanBottom_right = hScanCurrent; # = 75 + 50 = 25 #print("[Boblight] hScanBottom_left:"+str(hScanBottom_left)+" hScanBottom_right:"+str(hScanBottom_right)) elif self.begin == "bottom-right" or self.begin == "bottom-middle-right" or self.begin == "bottom-middle-left" or self.begin == "bottom-left": leds_bottom_right = leds_bottom/2; leds_bottom_left = leds_bottom/2; if config.plugins.enigmalight.clockwise.value == str(2): hScanStep = 100 / leds_bottom; hScan_left = (hScanStep*leds_bottom) # total left hscan /// light left*hScanStep = ... 25 hScan_right = (hScanStep*leds_bottom) hScanCurrent = (hScan_left); # 75 hScanBottom_left = 0.0; # = 75 hScanBottom_right = hScanCurrent; # = 75 + 50 = 25 elif config.plugins.enigmalight.clockwise.value == str(1): hScanStep = 100 / leds_bottom; hScan_left = (hScanStep*leds_bottom) # total left hscan /// light left*hScanStep = ... 25 hScan_right = (hScanStep*leds_bottom) hScanCurrent = (hScan_right); # 75 hScanBottom_left = hScanCurrent; # = 75 hScanBottom_right = 100.0; # = 75 + 50 = 25 # # Atmolight need 4 channels more. # if config.plugins.enigmalight.type.value == "Atmolight": channels += 4 total_lights = channels / 3; if self.createfile: # # Set some vars # colorr = "" colorg = "" colorb = "" if config.plugins.enigmalight.color_order.value == "1": colorr = "0000FF" colorg = "00FF00" colorb = "FF0000" if config.plugins.enigmalight.color_order.value == "0": colorr = "FF0000" colorg = "00FF00" colorb = "0000FF" if config.plugins.enigmalight.color_order.value == "2": colorr = "00FF00" colorg = "0000FF" colorb = "FF0000" # # Set prefix, type and interval # if config.plugins.enigmalight.type.value == "Lightpack": type = "lightpack\n" interval= "interval 20000\n" prefix = "\n" if config.plugins.enigmalight.type.value == "Oktolight": type = "karate\n" interval= "interval 16000\n" prefix = "\n" if config.plugins.enigmalight.type.value == "Karatelight": type = "karate\n" interval= "interval 16000\n" prefix = "\n" if config.plugins.enigmalight.type.value == "Atmolight": type = "atmo\n" prefix = "prefix FF\n" interval= "interval 16000\n" prefix = "\n" if config.plugins.enigmalight.type.value == "Adalight/Momo": type = "momo\n" interval= "interval 20000\n" #delayafteropen = "delayafteropen 1000000\n" prefix = "\n" # # Prefix calculation [This only works for arduino boards] # os.system("/home/elight-addons/prefix "+str(total_lights)+" > /tmp/prefix.txt") fo = open("/tmp/prefix.txt", "r") reading = fo.read(1000) fo.close() # remove tmpfile os.system("rm /tmp/prefix.txt") reading = reading.split("LEDS: ") prefix = "prefix "+str(reading[1]); #print("[Boblight] Reading prefixfile for "+str(total_lights)+" leds: "+prefix) if config.plugins.enigmalight.type.value == "iBelight": type = "ibelight\n" interval= "interval 20000\n" prefix = "\n" if config.plugins.enigmalight.type.value == "Sedulight 5A A0 A5": prefix = "prefix 5A A0\n" postfix = "postfix A5\n" type = "momo\n" interval= "interval 10000\n" delayafteropen = "delayafteropen 1000000\n" if config.plugins.enigmalight.type.value == "Sedulight 5A A1 A5": prefix = "prefix 5A A1\n" postfix = "postfix A5\n" type = "momo\n" interval= "interval 10000\n" delayafteropen = "delayafteropen 1000000\n" if config.plugins.enigmalight.type.value == "Sedulight 5A A2 A5": prefix = "prefix 5A A2\n" postfix = "postfix A5\n" type = "momo\n" interval= "interval 10000\n" delayafteropen = "delayafteropen 1000000\n" if config.plugins.enigmalight.type.value == "Sedulight 5A B0 A5": prefix = "prefix 5A B0\n" postfix = "postfix A5\n" type = "momo\n" interval= "interval 10000\n" delayafteropen = "delayafteropen 1000000\n" channels = "768" # # set the name # name = "ambilight" # # Create file # if self.createfile: fo = None fo = open("/tmp/enigmalight.conf.new", "wb") fo.write("[global]\n") fo.write("interface 127.0.0.1\n") fo.write("port 19333\n") fo.write("\n") fo.write("[device]\n") if config.plugins.enigmalight.type.value == "WifiLight": name = "wifilight" fo.write("name "+name+"\n") fo.write("output python /home/elight-addons/wifilight/wifilight.py\n") fo.write("type popen\n") fo.write("interval 100000\n") fo.write("channels 3\n") else: fo.write("name "+name+"\n") fo.write("output "+config.plugins.enigmalight.output.value+"\n") fo.write("type "+type) fo.write(interval) fo.write(prefix) fo.write(postfix) fo.write("channels "+str(channels)+"\n") if config.plugins.enigmalight.type.value != "iBelight" and config.plugins.enigmalight.type.value != "Lightpack": fo.write("rate "+str(config.plugins.enigmalight.rate.value)+"\n") fo.write("debug off\n") fo.write(delayafteropen) fo.write("\n") fo.write("[color]\n") fo.write("name red\n") fo.write("rgb "+colorr+"\n") fo.write("gamma "+str(config.plugins.enigmalight.config_r_gamma.value[0])+"."+str(config.plugins.enigmalight.config_r_gamma.value[1])+"\n") fo.write("adjust "+str(config.plugins.enigmalight.config_r_adjust.value[0])+"."+str(config.plugins.enigmalight.config_r_adjust.value[1])+"\n") fo.write("blacklevel "+str(config.plugins.enigmalight.config_r_blacklevel.value[0])+"."+str(config.plugins.enigmalight.config_r_blacklevel.value[1])+"\n") fo.write("\n") fo.write("[color]\n") fo.write("name green\n") fo.write("rgb "+colorg+"\n") fo.write("gamma "+str(config.plugins.enigmalight.config_g_gamma.value[0])+"."+str(config.plugins.enigmalight.config_g_gamma.value[1])+"\n") fo.write("adjust "+str(config.plugins.enigmalight.config_g_adjust.value[0])+"."+str(config.plugins.enigmalight.config_g_adjust.value[1])+"\n") fo.write("blacklevel "+str(config.plugins.enigmalight.config_g_blacklevel.value[0])+"."+str(config.plugins.enigmalight.config_b_blacklevel.value[1])+"\n") fo.write("\n") fo.write("[color]\n") fo.write("name blue\n") fo.write("rgb "+colorb+"\n") fo.write("gamma "+str(config.plugins.enigmalight.config_b_gamma.value[0])+"."+str(config.plugins.enigmalight.config_b_gamma.value[1])+"\n") fo.write("adjust "+str(config.plugins.enigmalight.config_b_adjust.value[0])+"."+str(config.plugins.enigmalight.config_b_adjust.value[1])+"\n") fo.write("blacklevel "+str(config.plugins.enigmalight.config_b_blacklevel.value[0])+"."+str(config.plugins.enigmalight.config_b_blacklevel.value[1])+"\n") fo.write("\n") # # begin to create lights section # # Set lightCount to 1 lightCount = 1 channelCount = 1 # Atmolight need to start @ 4 if config.plugins.enigmalight.type.value == "Atmolight": channelCount = 4 # Set v and h to 0 vScanCurrent = 0 hScanCurrent = 0 # # Set the section order # if self.begin == "left-bottom" or self.begin == "left-top": if config.plugins.enigmalight.clockwise.value == str(1): order = "left,top,right,bottom" # Clockwise else: order = "left,bottom,right,top" # Backwards if config.plugins.enigmalight.floorstand.value == str(2): if config.plugins.enigmalight.clockwise.value == str(1): order = "left,top,right,bottom-right,bottom-center,bottom-left" # Clockwise else: order = "left,bottom-left,bottom-center,bottom-right,right,top" # Backwards if self.begin == "top-left" or self.begin == "top-right": if config.plugins.enigmalight.clockwise.value == str(1): order = "top,right,bottom,left" # Clockwise else: order = "top,left,bottom,right" # Backwards if config.plugins.enigmalight.floorstand.value == str(2): if config.plugins.enigmalight.clockwise.value == str(1): order = "top,right,bottom-right,bottom-center,bottom-left,left" # Clockwise else: order = "top,left,bottom-left,bottom-center,bottom-right,right" # Backwards if self.begin == "right-top" or self.begin == "right-bottom": if config.plugins.enigmalight.clockwise.value == str(1): order = "right,bottom,left,top" # Clockwise else: order = "right,top,left,bottom" # Backwards if config.plugins.enigmalight.floorstand.value == str(2): if config.plugins.enigmalight.clockwise.value == str(1): order = "right,bottom-right,bottom-center,bottom-left,left,top" # Clockwise else: order = "right,top,left,bottom-left,bottom-center,bottom-right" # Backwards if self.begin == "bottom-right" or self.begin == "bottom-middle-left" or self.begin == "bottom-middle-right" or self.begin == "bottom-left": if self.begin == "bottom-middle-left": if config.plugins.enigmalight.clockwise.value == str(1): order = "bottom-left,left,top,right,bottom-right" # Clockwise else: order = "bottom-right,right,top,left,bottom-left" # Backwards else: if config.plugins.enigmalight.clockwise.value == str(1): order = "bottom,left,top,right" # Clockwise else: order = "bottom,right,top,left" # Backwards if config.plugins.enigmalight.floorstand.value == str(2): if config.plugins.enigmalight.clockwise.value == str(1): order = "bottom-center,bottom-left,left,top,right,bottom-right" # Clockwise else: order = "bottom-center,bottom-right,right,top,left,bottom-left" # Backwards # Split the orderarray order = order.split(",") # Debug #print("[Boblight] order = "+str(order)) #print("[Boblight] begincount = "+config.plugins.enigmalight.begincount.value) # 100 0 100 0 0 100 0 100 clockwards # 0 100 100 0 100 0 0 100 backwards # # order loop # totalCount = 1 for section in order: if section == "left": lights = leds_left vScanCurrent = 100.00 # From LEFT-bottom to LEFT-top # Clockwise if config.plugins.enigmalight.clockwise.value == str(2): vScanCurrent = 0.00 # From LEFT-top to LEFT-bottom # Backwards if section == "top": lights = leds_top hScanCurrent = 0.00 # From TOP-left to TOP-right # Clockwise if config.plugins.enigmalight.clockwise.value == str(2): hScanCurrent = 100.00 # From TOP-right to TOP-left # Backwards if section == "right": lights = leds_right vScanCurrent = 0.00 # From RIGHT-top to RIGHT-bottom # Clockwise if config.plugins.enigmalight.clockwise.value == str(2): vScanCurrent = 100.00 # From RIGHT-bottom to RIGHT-top # Backwards if section == "bottom": lights = leds_bottom hScanCurrent = 100.00 # From BOTTOM-right to BOTTOM-left # Clockwise if config.plugins.enigmalight.clockwise.value == str(2): hScanCurrent = 0.00 # From BOTTOM-left to BOTTOM-right # Backwards if section == "bottom-right": lights = leds_bottom_right hScanCurrent = float(hScanBottom_right) if config.plugins.enigmalight.clockwise.value == str(2): hScanCurrent = float(hScanBottom_right) if section == "bottom-left": lights = leds_bottom_left hScanCurrent = float(hScanBottom_left) if config.plugins.enigmalight.clockwise.value == str(2): hScanCurrent = float(hScanBottom_left) '''################### Bottom Center ####################''' if self.begin == "bottom-middle-left" or self.begin == "bottom-middle-right": if section == "bottom": lights = leds_bottom lights = lights/2; # we start at middle so we need to deceide it. hScanCurrent = 50 if section == "bottom-left": lights = leds_bottom_left hScanCurrent = hScanBottom_left if section == "bottom-right": lights = leds_bottom_right hScanCurrent = hScanBottom_right '''########################################################''' # # Set start value # if section == "left" and self.begin == "left-bottom": vScanCurrent = 100.00 # Start @ LEFT-bottom if section == "left" and self.begin == "left-top": vScanCurrent = 0.00 # Start @ LEFT-top if section == "top" and self.begin == "top-left": hScanCurrent = 0.00 # Start @ TOP-left if section == "top" and self.begin == "top-right": hScanCurrent = 100.00 # Start @ TOP-right if section == "right" and self.begin == "right-bottom": vScanCurrent = 100.00 # Start @ RIGHT-bottom if section == "right" and self.begin == "right-top": vScanCurrent = 0.00 # Start @ RIGHT-top if section == "bottom" and self.begin == "bottom-left": hScanCurrent = 0.00 # Start @ BOTTOM-left if section == "bottom" and self.begin == "bottom-right": hScanCurrent = 100.00 # Start @ BOTTOM-right lightCount = 1 #lights counter # Atmolight need to start @ 4 if config.plugins.enigmalight.type.value == "Atmolight": lightCount = 4 # Empty places for floorstand option if section == "bottom-center": lights = 0; #Set lights to 0, we want not into loop. # Debug ##print("[Boblight] Overlap : "+str(overlap)) #print("[Boblight] Start section : "+str(section)) #print("[Boblight] Start lights : "+str(lights)) #print("[Boblight] Start HscanCurrent : "+str(hScanCurrent)) #print("[Boblight] Start VscanCurrent : "+str(vScanCurrent)) # # check if section contains more then 0 lights # if lights > 0: # Steps vScanStep = 100.00 / lights; hScanStep = 100.00 / lights; # Debug #print("[Boblight] vScanStep 100/"+str(lights)+" : "+str(vScanStep)) #print("[Boblight] hScanStep 100/"+str(lights)+" : "+str(hScanStep)) # Set other step for floorstand option if config.plugins.enigmalight.floorstand.value == str(2): if section == "bottom-left" or section == "bottom-right" or section == "bottom-center": hScanStep = 100.00 / leds_bottom_total; elif self.begin == "bottom-middle-left" or self.begin == "bottom-middle-right": if section == "bottom-left" or section == "bottom-right": hScanStep = 100.00 / leds_bottom; # Loop while(lightCount <= lights): if section == "right" or section == "top": vScanEnd = vScanCurrent hScanEnd = hScanCurrent if config.plugins.enigmalight.clockwise.value == str(2): #backwards vScanStart = vScanCurrent - vScanStep hScanStart = hScanCurrent - hScanStep else: vScanStart = vScanCurrent + vScanStep hScanStart = hScanCurrent + hScanStep vScanCurrent = vScanStart hScanCurrent = hScanStart if section == "left" or section == "bottom" or section == "bottom-left" or section == "bottom-right": vScanStart = vScanCurrent hScanStart = hScanCurrent if config.plugins.enigmalight.clockwise.value == str(2): #backwards vScanEnd = vScanCurrent + vScanStep hScanEnd = hScanCurrent + hScanStep if section == "bottom-right" and self.begin == "bottom-middle": hScanEnd = hScanCurrent - hScanStep else: vScanEnd = vScanCurrent - vScanStep hScanEnd = hScanCurrent - hScanStep vScanCurrent = vScanEnd hScanCurrent = hScanEnd if self.createfile: fo.write("\n") fo.write("\n") # Light name must be 3 chars s = str(totalCount) s += "XX" length = len(s) mini = length -3 if length is 4 or length > 4: s = s[:-mini] if self.createfile: fo.write("[light]\n") fo.write("position "+str(section)+"\n") fo.write("name "+str(s)+"\n") fo.write("color red "+name+" "+str(channelCount)+"\n") channelCount += 1; fo.write("color green "+name+" "+str(channelCount)+"\n") channelCount += 1; fo.write("color blue "+name+" "+str(channelCount)+"\n") channelCount += 1; # Swap end and start if it's clockwise if config.plugins.enigmalight.clockwise.value == str(1): v = vScanEnd;vScanEnd = vScanStart;vScanStart = v; h = hScanEnd;hScanEnd = hScanStart;hScanStart = h; # Set hscan and vscan if section == "right": vs = abs(round(vScanStart,2)) ve = abs(round(vScanEnd,2)) hd = 100.00 - scanr if self.createfile: fo.write("hscan "+str(hd)+" 100 \n") fo.write("vscan "+str(vs)+" "+str(ve)+"\n") #step = i * (300 / config.plugins.enigmalight.lights_right.value) #self.c.fill(390, vs*2, 5, 5, RGB(000,000,255)) #print "step-right %s" %(str(vs*2)) # Debug #print("[Boblight] vScanStart : "+str(vs)) #print("[Boblight] vScanEnd : "+str(ve)) if section == "bottom" or section == "bottom-left" or section == "bottom-right": hs = abs(round(hScanStart,2)) he = abs(round(hScanEnd,2)) vd = 100.00 - scanb if self.createfile: fo.write("hscan "+str(hs)+" "+str(he)+"\n") fo.write("vscan "+str(vd)+" 100\n") # Debug #print("[Boblight] hScanStart : "+str(hs)) #print("[Boblight] hScanEnd : "+str(he)) if section == "top": hs = abs(round(hScanStart,2)) he = abs(round(hScanEnd,2)) vd = scant if self.createfile: fo.write("hscan "+str(hs)+" "+str(he)+"\n") fo.write("vscan 0 "+str(vd)+"\n") #self.c.fill(hs*4, 0, 5, 5, RGB(255,000,000)) #print "step-top %s" %(str(hs*4)) # Debug #print("[Boblight] hScanStart : "+str(hs)) #print("[Boblight] hScanEnd : "+str(he)) if section == "left": vs = abs(round(vScanStart,2)) ve = abs(round(vScanEnd,2)) hd = scanl if self.createfile: fo.write("hscan 0 "+str(hd)+"\n") fo.write("vscan "+str(vs)+" "+str(ve)+"\n") #self.c.fill(0, vs*2, 5, 5, RGB(000,255,000)) #print "step-left %s" %(str(vs*2)) # Debug #print("[Boblight] vScanStart : "+str(vs)) #print("[Boblight] vScanEnd : "+str(ve)) lightCount += 1; # Counter for sections totalCount += 1; # End loop #self.c.flush() if config.plugins.enigmalight.type.value == "WifiLight": try: fowifi = open("/home/elight-addons/wifilight/wifilight.conf", "wb") fowifi.write(str(config.plugins.enigmalight.wifilight_ip.getText())+"|") fowifi.write(str(config.plugins.enigmalight.wifilight_port.getText())) fowifi.close(); except: from traceback import format_exc log("Error:" +format_exc(),self) try: open(getCrashFilePath(),"w").write(format_exc()) showMessage(self._session,_("Can't write settings to /home/elight-addons/wifilight/wifilight.conf...", "W", timeout = 10)) except: pass fo.close(); if self.test: #kill enigmalight and start the test self.controller.killEnigmalight(None,self.doTest) else: self.MovetoEtc(True,True)
def showResult(self, result): s = showMessage(self.session,_("Error while starting EnigmaLight:\n\n%s") %(result),"E",10)
def showResult(self, result): s = showMessage( self.session, _("Error while starting EnigmaLight:\n\n%s") % (result), "E", 10)
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
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