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 profileListFunc(self): self.profileList.clear() profiles = previous.list_profile() if profiles: for p in profiles: self.profileList.addItem(QListWidgetItem(p))