def setBrightness(self, action, device): try: self.debugLog(u"setBrightness: device: " + device.name + u", action:\n" + unicode(action)) bulb = WifiLedBulb(device.address) bulb.refreshState() # get RGB rgb = bulb.getRgb() self.debugLog("RGB Read as: " + str(rgb)) r=rgb[0] g=rgb[1] b=rgb[2] #Convert RGB to HSV #hsb = RGBColor(red, green, blue, rgb_type='wide_gamut_rgb').convert_to('hsv') #hue = int(round(hsb.hsv_h * 1.0)) #saturation = int(round(hsb.hsv_s * 100.0)) #brightness = int(round(hsb.hsv_v * 100.0)) #Change V #Update bulb self.debugLog(u"Setting RGB: " + str(r) + "|" + str(g) + "|" + str(b) ) bulb.setRgb(r,g,b,True,action.actionValue * 2.55) except Exception: t, v, tb = sys.exc_info() self.handle_exception(t,v,tb)
def connect(self): self.scanner.scan(timeout=4) # Specific ID/MAC of the bulb to set bulb_info = self.scanner.getBulbInfoByID(self.macAddr) if bulb_info: self.ledDevice = WifiLedBulb(bulb_info["ipaddr"]) self.ledDevice.refreshState()
def switch_off(ipaddress): flux_bulb = WifiLedBulb(ipaddr=ipaddress) flux_bulb.turnOff() # if __name__ == '__main__': # ipaddr = scan_bulb() # switch_on(ipaddr) # switch_off(ipaddr)
def main(): # Find the bulb on the LAN scanner = BulbScanner() scanner.scan(timeout=4) # Specific ID/MAC of the bulb to set bulb_info = scanner.getBulbInfoByID('ACCF235FFFFF') if bulb_info: bulb = WifiLedBulb(bulb_info['ipaddr']) color_time = 5 # seconds on each color red = (255, 0, 0) orange = (255, 125, 0) yellow = (255, 255, 0) springgreen = (125, 255, 0) green = (0, 255, 0) turquoise = (0, 255, 125) cyan = (0, 255, 255) ocean = (0, 125, 255) blue = (0, 0, 255) violet = (125, 0, 255) magenta = (255, 0, 255) raspberry = (255, 0, 125) colorwheel = [ red, orange, yellow, springgreen, green, turquoise, cyan, ocean, blue, violet, magenta, raspberry ] # use cycle() to treat the list in a circular fashion colorpool = cycle(colorwheel) # get the first color before the loop color = next(colorpool) while True: bulb.refreshState() # set to color and wait # (use non-persistent mode to help preserve flash) bulb.setRgb(*color, persist=False) time.sleep(color_time) #fade from color to next color next_color = next(colorpool) crossFade(bulb, color, next_color) # ready for next loop color = next_color else: print "Can't find bulb"
def getBulbStatus(self, deviceId): # Get device status. try: device = indigo.devices[deviceId] bulb = WifiLedBulb(device.address) bulb.refreshState() self.debugLog(str(bulb)) except Exception: t, v, tb = sys.exc_info() self.handle_exception(t,v,tb)
def _add_device(self, dev): """ Add the given device, if necessary. dev -- the device object """ _id = 'magichome-' + dev['id'] if _id not in self.devices: device = MagicHomeBulb(self, _id, WifiLedBulb(dev['ipaddr'])) self.handle_device_added(device)
def _scan(self): while not self._stop.is_set(): with self._lock: new_lights = {} print('Scanning for bulbs') old_names = tuple(self._lights.keys()) found_names = [] if not self._fake: self._scanner.scan(timeout=4) for scanned in self._scanner.getBulbInfo(): bid = scanned['id'] if bid in self._bulb_map: print('Found real bulb: %s' % (self._bulb_map[bid], )) new_lights[self._bulb_map[bid]] = {'info': scanned} found_names.append(self._bulb_map[bid]) else: for i, id in enumerate(self._bulb_map): print('Found fake bulb: %s' % (self._bulb_map[id], )) new_lights[self._bulb_map[id]] = { 'info': { 'ipaddr': '10.0.0.%d' % i } } found_names.append(self._bulb_map[id]) # Clear out any bulbs that went missing for name in old_names: if name not in found_names: print('Removing missing light: ', name) for name in found_names: if name not in old_names: print('Adding new bulb: ', name) for name, l in new_lights.items(): if not l['info']: print('Did not find expected bulb', name) sys.exit(1) if not self._fake: l['bulb'] = WifiLedBulb(l['info']['ipaddr']) else: l['bulb'] = FakeBulb(name) if len(new_lights) != len(self._bulb_map): print("Warning: didn't find all the lights") self._lights = new_lights # Sleep, but keep checking for quit while we do. for i in range(0, self._period): if self._stop.is_set(): return time.sleep(1)
def _connect(self): """Connect to Flux light.""" self._bulb = WifiLedBulb(self._ipaddr, timeout=5) if self._protocol: self._bulb.setProtocol(self._protocol) # After bulb object is created the status is updated. We can # now set the correct mode if it was not explicitly defined. if not self._mode: if self._bulb.rgbwcapable: self._mode = MODE_RGBW else: self._mode = MODE_RGB
def setPreset(self, action, device): try: self.debugLog(u"setPreset: device: " + device.name + ", action:\n" + unicode(action)) preset = int(action.props.get('preset', 0),0) speed = int(action.props.get('speed', 0),0) bulb = WifiLedBulb(device.address) bulb.refreshState() bulb.setPresetPattern(preset, speed) bulb.turnOn() except Exception: t, v, tb = sys.exc_info() self.handle_exception(t,v,tb)
def connectLED(ip): try: #led_to_connect = scanner.getBulbInfoByID(args.led_mac) #bulb = WifiLedBulb(led_to_connect['ipaddr']) bulb = WifiLedBulb(ip) print("Connected to LED strip with IP: " + ip) ipAddress.set("IP: " + ip) except: print( "No valid MAC address provided, attempting to use first one discovered: " + scanner.found_bulbs[0]['id']) print("Unable to connect to " + ip) #first_discovered_bulb = scanner.getBulbInfoByID(scanner.found_bulbs[0]['id']) #bulb = WifiLedBulb(first_discovered_bulb['ipaddr']) return bulb
def __init__(self, mode: LEDControlMode = LEDControlMode.AUDIO_STEREO_MIX, rgb_buffer_len: int = 8, alpha_buffer_length=8, silence_buffer_length=1.5): self.mode = mode if self.mode == LEDControlMode.AUDIO_STEREO_MIX: self.controller = AudioController() self.audio_stream = AudioStream( audio_device=AudioInputDevices.STEREO_MIX, chunk=self.controller.nperseg) elif self.mode == LEDControlMode.MONITOR_COLOR: self.controller = MonitorColorController() rgb_buffer_len = 2 self.hue_buffer = deque([0 for _ in range(rgb_buffer_len)], maxlen=rgb_buffer_len) self.alpha_buffer = deque([2 for _ in range(alpha_buffer_length)], maxlen=alpha_buffer_length) self.silence_buffer = deque( [ 'music' for _ in range( int(silence_buffer_length / self.controller.nperseg * self.controller.fs)) ], maxlen=int(silence_buffer_length / self.controller.nperseg * self.controller.fs)) self.state = 'music' # scan available LED devices scanner = BulbScanner() scanner.scan(timeout=4) print("Found LED controllers:") [print(bulb) for bulb in scanner.found_bulbs] self.bulbs = [] for bulb in scanner.found_bulbs: bulb_info = scanner.getBulbInfoByID(bulb['id']) self.bulbs.append(WifiLedBulb(bulb_info['ipaddr']))
def setRGB(self, action, device): try: self.debugLog(u"setRGB: device: " + device.name + ", action:\n" + unicode(action)) red = action.props.get('red', 0) green = action.props.get('green', 0) blue = action.props.get('blue', 0) bulb = WifiLedBulb(device.address) bulb.mode = 'color' bulb.pattern_code = 0x61 if red+green+blue >0: bulb.turnOn() bulb.setRgb(red, green, blue) except Exception: t, v, tb = sys.exc_info() self.handle_exception(t,v,tb)
def _addNode(self, d): try: name = 'mh ' + d['ipaddr'].replace('.',' ') address = str(d['id']).lower() address = address[-14:] if address not in self.nodes: led = WifiLedBulb(d['ipaddr']) if led.rgbwcapable: LOGGER.info('Adding new MagicHome RGBW LED: %s(%s)', name, address) self.addNode(MagicHomeLED(self, self.address, address, name, device = led)) #Two node types merged, both kept herein for backwards compatability BF 30Jan2020 else: LOGGER.info('Adding new MagicHome RGB LED: %s(%s)', name, address) self.addNode(MagicHomeLED(self, self.address, address, name, device = led)) else: LOGGER.debug('MagicHome LED with IP address "%s" and MAC address "%s" already in ISY', name, address) return False except Exception as ex: LOGGER.error('Error adding Bulb: %s', str(ex)) return False return True
def __init__(self, driver, display_name, ip, logger=None): super().__init__(driver, display_name) self.logger = logger self._wifi_bulb = WifiLedBulb(ip) service = self.add_preload_service('Lightbulb', chars=[ 'On', 'Brightness', 'Hue', 'Saturation', ]) # configure callbacks service.configure_char( 'On', setter_callback=self.set_on, ) # Set our instance variables self.on = 0
def command_handler(sentence, info): scanner = BulbScanner() coms, classify = commands() msg = sentence + " is not a know flux lightbulb command" function = None print("scanner scan: ", end="") print(scanner.scan(timeout=4)) try: #specific ID/MAC of bulb my_light = scanner.getBulbInfoByID("D8F15BA2EE72") except: msg = "flux lightbulb not detected!" return msg, function print("success!") bulb = WifiLedBulb(my_light["ipaddr"]) for i in coms[0]: #lightbulb color changer res = parse(i, sentence) if res: msg, function = colorChanger(bulb, res[0]) return msg, function if sentence in coms[1]: #turn lightbulb off msg = "turning the flux lightbulb off" function = bulb.turnOff() return msg, function if sentence in coms[2]: #turn the lightbulb on msg = "turning the flux lightbulb on" function = bulb.turnOn() return msg, function for i in coms[3]: #change brightness of lightbulb res = parse(i, sentence) if res: msg, function = brightnessChanger(bulb, res[0]) return msg, function return msg, function
def actionControlDimmerRelay(self, action, device): try: try: self.debugLog(u"actionControlDimmerRelay called for device " + device.name + u". actionValue: " + str(action) ) except Exception, e: self.debugLog(u"actionControlDimmerRelay called for device " + device.name + u". (Unable to display action or device data due to error: " + str(e) + u")") currentBrightness = device.states['brightnessLevel'] currentOnState = device.states['onOffState'] self.debugLog("current brightness: " + str(currentBrightness)) bulb = WifiLedBulb(device.address) bulb.refreshState() self.debugLog(str(bulb)) # Get key variables command = action.deviceAction ##### TURN ON ##### if command == indigo.kDeviceAction.TurnOn: try: self.debugLog(u"device on:\n%s" % action) except Exception, e: self.debugLog(u"device on: (Unable to display action data due to error: " + str(e) + u")") # Turn it on. bulb.turnOn()
def updateStatus(self, device): #self.debugLog(u"Updating device: " + device.name) try: keyValueList = [] bulb = WifiLedBulb(device.address) keyValueList.append({'key':"online", 'value':True}) currentRGBW = bulb.getRgbw() device.pluginProps["supportsWhite"] = bulb.rgbwcapable device.pluginProps["supportsWhiteTemperature"] = False #self.debugLog(str(currentRGBW)) channelKeys = [] if bulb.rgbwcapable: channelKeys.extend(['whiteLevel']) brightness= int(round(RGBColor(currentRGBW[0],currentRGBW[1],currentRGBW[2]).convert_to('hsv').hsv_v*100)) keyValueList.append({'key':"onOffState", 'value':bulb.isOn()}) keyValueList.append({'key':"redLevel", 'value':currentRGBW[0]}) keyValueList.append({'key':"greenLevel", 'value':currentRGBW[1]}) keyValueList.append({'key':"blueLevel", 'value':currentRGBW[2]}) keyValueList.append({'key':'brightnessLevel','value':brightness}) if bulb.rgbwcapable: keyValueList.append({'key':"whiteLevel", 'value':currentRGBW[3]}) device.updateStatesOnServer(keyValueList) except Exception,e: self.errorLog("Error updating device: " + device.name +". Is the IP address correct?") t, v, tb = sys.exc_info() self.handle_exception(t,v,tb)
def __init__(self, mode: LEDControlMode = LEDControlMode.AUDIO_STEREO_MIX, rgb_buffer_len: int = 5): self.mode = mode if self.mode == LEDControlMode.AUDIO_STEREO_MIX: self.controller = AudioController() self.audio_stream = AudioStream( audio_device=AudioInputDevices.STEREO_MIX, chunk=self.controller.nperseg) elif self.mode == LEDControlMode.MONITOR_COLOR: self.controller = MonitorColorController() rgb_buffer_len = 2 self.rgb_buffer = { 'r': deque([255 for _ in range(rgb_buffer_len)], maxlen=rgb_buffer_len), 'g': deque([255 for _ in range(rgb_buffer_len)], maxlen=rgb_buffer_len), 'b': deque([255 for _ in range(rgb_buffer_len)], maxlen=rgb_buffer_len) } # scan available LED devices scanner = BulbScanner() scanner.scan(timeout=4) print("Found LED controllers:") [print(bulb) for bulb in scanner.found_bulbs] self.bulbs = [] for bulb in scanner.found_bulbs: bulb_info = scanner.getBulbInfoByID(bulb['id']) self.bulbs.append(WifiLedBulb(bulb_info['ipaddr']))
import sys import time from itertools import cycle this_folder = os.path.dirname(os.path.realpath(__file__)) sys.path.append(this_folder) from flux_led import WifiLedBulb, BulbScanner, LedTimer scanner = BulbScanner() scanner.scan(timeout=4) # Specific ID/MAC of the bulb to set bulb_info = scanner.getBulbInfoByID('6001948A4F89') print "bulb_info: " + str(bulb_info) bulb = WifiLedBulb(bulb_info['ipaddr']) color_time = 2 # seconds on each color red = (255, 0, 0) orange = (255, 125, 0) yellow = (255, 255, 0) springgreen = (125, 255, 0) green = (0, 255, 0) turquoise = (0, 255, 125) cyan = (0, 255, 255) ocean = (0, 125, 255) blue = (0, 0, 255) violet = (125, 0, 255) magenta = (255, 0, 255) raspberry = (255, 0, 125)
print sys.argv try: address = sys.argv[1] id = sys.argv[2] action = sys.argv[3].lower() values = sys.argv[4:] except: sys.exit(1) #scanner = BulbScanner() #scanner.scan(timeout=4) #bulb_info = scanner.getBulbInfoByID(address) #address = bulb_info['ipaddr'] bulb = WifiLedBulb(address) msg = 'MagicLED bulb at %s ' % address if action == 'on': val = int(values[0]) if val > 0: msg += 'turned on' bulb.turnOn() else: msg += 'turned off' bulb.turnOff() if action == 'color': r = int(values[0]) g = int(values[1]) b = int(values[2])
def do_command(self, e, cmd, test_str): c = self.connection # Poll the API to get current game. if cmd == "game": url = 'https://api.twitch.tv/kraken/channels/' + self.channel_id headers = { 'Client-ID': self.client_id, 'Accept': 'application/vnd.twitchtv.v5+json' } r = requests.get(url, headers=headers).json() c.privmsg(self.channel, r['display_name'] + ' is currently playing ' + r['game']) # Poll the API the get the current status of the stream elif cmd == "title": url = 'https://api.twitch.tv/kraken/channels/' + self.channel_id headers = { 'Client-ID': self.client_id, 'Accept': 'application/vnd.twitchtv.v5+json' } r = requests.get(url, headers=headers).json() c.privmsg( self.channel, r['display_name'] + ' channel title is currently ' + r['status']) # Provide basic information to viewers for specific commands # OLD WAY TO DO HEX CODE # Hex input as command # elif cmd[0] == '#': # if len(cmd) == 7: # newcmd = cmd.replace("#", "") # try: # int(newcmd, 16) # bulb_info = autoScan() # message = "Bulb color changed to " + cmd # c.privmsg(self.channel, message) # if bulb_info: # bulb = WifiLedBulb(bulb_info['ipaddr']) # bulb.turnOn() # rgb = struct.unpack('BBB', newcmd.decode('hex')) #convert hex to tuple # bulb.setRgb(rgb[0], rgb[1], rgb[2], persist=False) # except ValueError: # c.privmsg(self.channel, cmd + " is not a valid color code!") # else: # message = "Invalid command: color format example: #12D4F6" # c.privmsg(self.channel, message) # Test Color Change elif cmd == "off": message = "Bulb has been turned off" bulb_info = autoScan() if bulb_info: bulb = WifiLedBulb(bulb_info['ipaddr']) bulb.turnOff() c.privmsg(self.channel, message) elif cmd == "warm": # Warm white big-command bulb_info = autoScan() if bulb_info: bulb = WifiLedBulb(bulb_info['ipaddr']) bulb.turnOn() # Will Be Direct Color Command or Fail else: try: rgb = generateRGB(cmd) # try to turn it into RGB bulb_info = autoScan() # at this point it worked if bulb_info: # change the bulb colors bulb = WifiLedBulb(bulb_info['ipaddr']) bulb.turnOn() bulb.setRgb(rgb[0], rgb[1], rgb[2], persist=False) message = "Bulb color changed to " + cmd c.privmsg(self.channel, message) except ValueError: # If value doesn't exist, it's neither a color or a command c.privmsg(self.channel, cmd + " is not a color!") c.privmsg(self.channel, "Did not understand command: " + cmd)
def main(): device = WifiLedBulb('<ip>') print(hex(device.raw_state[1]))
def switch_on(ipaddress): flux_bulb = WifiLedBulb(ipaddr=ipaddress) flux_bulb.turnOn()
def main(): syslog.openlog(sys.argv[0]) # Change location to nearest city. location = 'San Diego' # Get the local sunset/sunrise times a = Astral() a.solar_depression = 'civil' city = a[location] timezone = city.timezone sun = city.sun(date=datetime.datetime.now(), local=True) if debug: print 'Information for {}/{}\n'.format(location, city.region) print 'Timezone: {}'.format(timezone) print 'Latitude: {:.02f}; Longitude: {:.02f}\n'.format( city.latitude, city.longitude) print('Dawn: {}'.format(sun['dawn'])) print('Sunrise: {}'.format(sun['sunrise'])) print('Noon: {}'.format(sun['noon'])) print('Sunset: {}'.format(sun['sunset'])) print('Dusk: {}'.format(sun['dusk'])) # Find the bulbs on the LAN scanner = BulbScanner() scanner.scan(timeout=4) # Specific ID/MAC of the bulbs to set porch_info = scanner.getBulbInfoByID('ACCF235FFFEE') livingroom_info = scanner.getBulbInfoByID('ACCF235FFFAA') if porch_info: bulb = WifiLedBulb(porch_info['ipaddr']) bulb.refreshState() timers = bulb.getTimers() # Set the porch bulb to turn on at dusk using timer idx 0 syslog.syslog( syslog.LOG_ALERT, "Setting porch light to turn on at {}:{:02d}".format( sun['dusk'].hour, sun['dusk'].minute)) dusk_timer = LedTimer() dusk_timer.setActive(True) dusk_timer.setRepeatMask(LedTimer.Everyday) dusk_timer.setModeWarmWhite(35) dusk_timer.setTime(sun['dusk'].hour, sun['dusk'].minute) timers[0] = dusk_timer # Set the porch bulb to turn off at dawn using timer idx 1 syslog.syslog( syslog.LOG_ALERT, "Setting porch light to turn off at {}:{:02d}".format( sun['dawn'].hour, sun['dawn'].minute)) dawn_timer = LedTimer() dawn_timer.setActive(True) dawn_timer.setRepeatMask(LedTimer.Everyday) dawn_timer.setModeTurnOff() dawn_timer.setTime(sun['dawn'].hour, sun['dawn'].minute) timers[1] = dawn_timer bulb.sendTimers(timers) else: print "Can't find porch bulb" if livingroom_info: bulb = WifiLedBulb(livingroom_info['ipaddr']) bulb.refreshState() timers = bulb.getTimers() # Set the living room bulb to turn on at sunset using timer idx 0 syslog.syslog( syslog.LOG_ALERT, "Setting LR light to turn on at {}:{:02d}".format( sun['sunset'].hour, sun['sunset'].minute)) sunset_timer = LedTimer() sunset_timer.setActive(True) sunset_timer.setRepeatMask(LedTimer.Everyday) sunset_timer.setModeWarmWhite(50) sunset_timer.setTime(sun['sunset'].hour, sun['sunset'].minute) timers[0] = sunset_timer # Set the living room bulb to turn off at a fixed time off_timer = LedTimer() off_timer.setActive(True) off_timer.setRepeatMask(LedTimer.Everyday) off_timer.setModeTurnOff() off_timer.setTime(23, 30) timers[1] = off_timer bulb.sendTimers(timers) else: print "Can't find living room bulb"
class Plugin(indigo.PluginBase): ######################################## # Main Functions ###################### def handle_exception(self, exc_type, exc_value, exc_traceback): self.debugLog(u"Sending Exception to RayGun") cl = raygunprovider.RaygunSender("sPaBbBFLS9CjSyQXq8bBbg==") cl.send_exception(exc_info=(exc_type, exc_value, exc_traceback)) sys.excepthook = handle_exception def __init__(self, pluginId, pluginDisplayName, pluginVersion, pluginPrefs): indigo.PluginBase.__init__(self, pluginId, pluginDisplayName, pluginVersion, pluginPrefs) self.updatePrefs(pluginPrefs) self.runUpdateLoop = True sys.excepthook = self.handle_exception def runConcurrentThread(self): self.debugLog(u"runConcurrentThread called") try: while self.runUpdateLoop: #self.debugLog(u"runConcurrentThread loop") for dev in indigo.devices.iter("self"): self.updateStatus(dev) self.sleep(3) except Exception: t, v, tb = sys.exc_info() self.handle_exception(t,v,tb) def stopConcurrentThread(self): self.debugLog(u"stopConcurrentThread called") self.runUpdateLoop = False def updatePrefs(self, prefs): self.debug = prefs.get("showDebugInfo", False) if self.debug == True: self.debugLog("logger debugging enabled") else: self.debugLog("logger debugging disabled") def deviceStartComm(self, device): self.debugLog(u"Starting device: " + device.name) self.updateStatus(device) def updateStatus(self, device): #self.debugLog(u"Updating device: " + device.name) try: keyValueList = [] bulb = WifiLedBulb(device.address) keyValueList.append({'key':"online", 'value':True}) currentRGBW = bulb.getRgbw() device.pluginProps["supportsWhite"] = bulb.rgbwcapable device.pluginProps["supportsWhiteTemperature"] = False #self.debugLog(str(currentRGBW)) channelKeys = [] if bulb.rgbwcapable: channelKeys.extend(['whiteLevel']) brightness= int(round(RGBColor(currentRGBW[0],currentRGBW[1],currentRGBW[2]).convert_to('hsv').hsv_v*100)) keyValueList.append({'key':"onOffState", 'value':bulb.isOn()}) keyValueList.append({'key':"redLevel", 'value':currentRGBW[0]}) keyValueList.append({'key':"greenLevel", 'value':currentRGBW[1]}) keyValueList.append({'key':"blueLevel", 'value':currentRGBW[2]}) keyValueList.append({'key':'brightnessLevel','value':brightness}) if bulb.rgbwcapable: keyValueList.append({'key':"whiteLevel", 'value':currentRGBW[3]}) device.updateStatesOnServer(keyValueList) except Exception,e: self.errorLog("Error updating device: " + device.name +". Is the IP address correct?") t, v, tb = sys.exc_info() self.handle_exception(t,v,tb) try: keyValueList = [] bulb = WifiLedBulb(device.address) keyValueList.append({'key':"online", 'value':True}) currentRGBW = bulb.getRgbw() device.pluginProps["supportsWhite"] = bulb.rgbwcapable device.pluginProps["supportsWhiteTemperature"] = False #self.debugLog(str(currentRGBW)) channelKeys = [] if bulb.rgbwcapable: channelKeys.extend(['whiteLevel']) keyValueList.append({'key':"onOffState", 'value':bulb.isOn()}) keyValueList.append({'key':"redLevel", 'value':currentRGBW[0]}) keyValueList.append({'key':"greenLevel", 'value':currentRGBW[1]}) keyValueList.append({'key':"blueLevel", 'value':currentRGBW[2]}) if bulb.rgbwcapable: keyValueList.append({'key':"whiteLevel", 'value':currentRGBW[3]}) device.updateStatesOnServer(keyValueList) except Exception: t, v, tb = sys.exc_info() self.handle_exception(t,v,tb)
from scapy.all import * import subprocess from flux_led import WifiLedBulb, BulbScanner import datetime import os import sys version = "1.0.3 " # assign version number for debugging bulb = WifiLedBulb('192.168.XX.XX') # assign bulb IP #bulb.refreshState() # refresh state to collect accurate staus logfile = r"/home/pi/SANDBOX/Dash/logfiles.log" # name of my log file WHITE_MAC_ADDRESS = 'XX:XX:XX:XX:XX:XX' # enter Dash Button's MAC Address here. testMAC = 'XX:XX:XX:XX:XX:XX' dashButton = { "whiteDash" : 'XX:XX:XX:XX:XX:XX', "redDash" : 'XX:XX:XX:XX:XX:XX' } whiteBulb = (0,0,0,191) redBulb = (15,0,0,0) #sniff for packets sent from button press def detect_button(pkt): for mac in dashButton: