def candleApply(self): self.checkAudio() try: with serial.Serial(self.portTxt.text(), 256000) as ser: if self.getChannel() == None: hue.power(ser, 0, "off") else: hue.candlelight(ser, 0, self.getChannel(), self.getColors(self.candleList)[0]) except serial.serialutil.SerialException: self.error( "Serial port is invalid. Try /dev/ttyACM0 for Linux or COM3 or COM4 for Windows" )
def wingsApply(self): self.checkAudio() try: with serial.Serial(self.portTxt.text(), 256000) as ser: if self.getChannel() == None: hue.power(ser, 0, "off") else: speed = self.wingsSpeed.value() hue.wings(ser, 0, self.getChannel(), self.getColors(self.wingsList)[0], speed) except serial.serialutil.SerialException: self.error( "Serial port is invalid. Try /dev/ttyACM0 for Linux or COM3 or COM4 for Windows" )
def spectrumApply(self): self.checkAudio() try: with serial.Serial(self.portTxt.text(), 256000) as ser: if self.getChannel() == None: hue.power(ser, 0, "off") else: speed = self.spectrumSpeed.value() direction = 1 if self.spectrumBackwards.isChecked() else 0 hue.spectrum(ser, self.getChannel(), speed, direction) except serial.serialutil.SerialException: self.error( "Serial port is invalid. Try /dev/ttyACM0 for Linux or COM3 or COM4 for Windows" )
def customApply(self): self.checkAudio() try: with serial.Serial(self.portTxt.text(), 256000) as ser: if self.getChannel() == None: hue.power(ser, 0, "off") else: speed = self.customSpeed.value() hue.custom(ser, 0, self.getChannel(), self.customGetColors(), self.customMode.currentText().lower(), speed) except serial.serialutil.SerialException: self.error( "Serial port is invalid. Try /dev/ttyACM0 for Linux or COM3 or COM4 for Windows" )
def marqueeApply(self): self.checkAudio() try: with serial.Serial(self.portTxt.text(), 256000) as ser: if self.getChannel() == None: hue.power(ser, 0, "off") else: speed = self.marqueeSpeed.value() size = self.marqueeSize.value() direction = 0 if self.marqueeBackwards.isChecked() else 0 hue.marquee(ser, 0, self.getChannel(), self.getColors(self.marqueeList)[0], speed, size, direction) except serial.serialutil.SerialException: self.error( "Serial port is invalid. Try /dev/ttyACM0 for Linux or COM3 or COM4 for Windows" )
def profileApply(self): self.checkAudio() try: with serial.Serial(self.portTxt.text(), 256000) as ser: if self.getChannel() == None: hue.power(ser, 0, "off") else: out = hue.profile_apply( ser, self.profileList.currentItem().text()) except serial.serialutil.SerialException: self.error( "Serial port is invalid. Try /dev/ttyACM0 for Linux or COM3 or COM4 for Windows" ) if out: self.animatedColors = out['colors'] self.animatedSpeed.setValue(out['speed']) self.animatedApply()
def alternatingApply(self): self.checkAudio() try: if self.alternatingList.count() != 2: self.error("Alternating must have two colors") else: with serial.Serial(self.portTxt.text(), 256000) as ser: if self.getChannel() == None: hue.power(ser, 0, "off") else: speed = self.alternatingSpeed.value() size = self.alternatingSize.value() direction = 1 if self.alternatingBackwards.isChecked( ) else 0 moving = self.alternatingMoving.isChecked() hue.alternating(ser, 0, self.getChannel(), self.getColors(self.alternatingList), speed, size, moving, direction) except serial.serialutil.SerialException: self.error( "Serial port is invalid. Try /dev/ttyACM0 for Linux or COM3 or COM4 for Windows" )
def timeDaemon(self): pre = previous.list_profile() if 'previous' in pre: pre = 'previous' else: return if self.onTimeTxt != "00:00" and self.offTimeTxt != "00:00": onTime = datetime.datetime.strptime(self.onTimeTxt, '%H:%M').time() offTime = datetime.datetime.strptime(self.offTimeTxt, '%H:%M').time() if time_in_range(offTime, onTime, datetime.datetime.now().time()): if not self.doneOff: self.checkAudio() try: with serial.Serial(self.portTxt.text(), 256000) as ser: print("Turning off") hue.power(ser, 0, 'off') hue.unitled(ser, 'off') self.doneOff = True self.doneOn = False except serial.serialutil.SerialException: self.error( "Serial port is invalid. Try /dev/ttyACM0 for Linux or COM3 or COM4 for Windows" ) else: if not self.doneOn: self.checkAudio() try: with serial.Serial(self.portTxt.text(), 256000) as ser: print("Turning on") hue.profile_apply(ser, pre) hue.unitled(ser, 'on') self.doneOn = True self.doneOff = False except serial.serialutil.SerialException: self.error( "Serial port is invalid. Try /dev/ttyACM0 for Linux or COM3 or COM4 for Windows" )
def audioLevelApply(self): if os.name == 'nt': self.error( "To enable audio mode on Windows, right click on the audio icon, go to recording devices, right click and select show disabled devices, and right click on stereo mix and click enable." ) self.checkAudio() try: ser = serial.Serial(self.portTxt.text(), 256000) if self.getChannel() == None: hue.power(ser, 0, "off") else: tolerance = float(self.audioLevelTolerance.value()) smooth = int(self.audioLevelSmooth.value()) self.audioThread = multiprocessing.Process( target=hue.audio_level, args=(self.portTxt.text(), 0, self.getChannel(), self.getColors(self.audioLevelList), tolerance, smooth)) self.audioThread.start() except serial.serialutil.SerialException: self.error( "Serial port is invalid. Try /dev/ttyACM0 for Linux or COM3 or COM4 for Windows" )