9898rememberLightsOnExit = False # whether or not to save the currently set light settings (mode/hue/brightness/etc.) when quitting out
9999acceptable_HTTP_IPs = [] # the acceptable IPs for the HTTP server, set on launch by prefs file
100100customKeys = [] # custom keymappings for keyboard shortcuts, set on launch by the prefs file
101+ whiteListedMACs = [] # whitelisted list of MAC addresses to add to NeewerLite-Python
101102enableTabsOnLaunch = False # whether or not to enable tabs on startup (even with no lights connected)
102103
103104lockFile = tempfile .gettempdir () + os .sep + "NeewerLite-Python.lock"
@@ -1220,8 +1221,10 @@ async def findDevices():
12201221 for d in devices : # go through all of the devices Bleak just found
12211222 try :
12221223 d .name .index ("NEEWER" ) # try to see if the current device has the name "NEEWER" in it
1223- except ValueError :
1224- pass # if the current device doesn't ^^^^, then this error is thrown
1224+ except ValueError : # if the name doesn't have "NEEWER" in it, then check to see if it's whitelisted
1225+ if d .address in whiteListedMACs : # if the MAC address is in the list of whitelisted addresses, add this device anyway
1226+ printDebugString ("Matching whitelisted address found - " + returnMACname () + " " + d .address + ", adding to the list" )
1227+ currentScan .append (d )
12251228 else :
12261229 currentScan .append (d ) # and if it finds the phrase, add it to this session's available lights
12271230
@@ -2030,7 +2033,8 @@ def formatStringForConsole(theString, maxLength):
20302033
20312034def loadPrefsFile (globalPrefsFile = "" ):
20322035 global findLightsOnStartup , autoConnectToLights , printDebug , maxNumOfAttempts , \
2033- rememberLightsOnExit , acceptable_HTTP_IPs , customKeys , enableTabsOnLaunch
2036+ rememberLightsOnExit , acceptable_HTTP_IPs , customKeys , enableTabsOnLaunch , \
2037+ whiteListedMACs
20342038
20352039 if globalPrefsFile != "" :
20362040 printDebugString ("Loading global preferences from file..." )
@@ -2044,7 +2048,7 @@ def loadPrefsFile(globalPrefsFile = ""):
20442048 "SC_Dec_Bri_Small" , "SC_Inc_Bri_Small" , "SC_Dec_Bri_Large" , "SC_Inc_Bri_Large" , \
20452049 "SC_Dec_1_Small" , "SC_Inc_1_Small" , "SC_Dec_2_Small" , "SC_Inc_2_Small" , "SC_Dec_3_Small" , "SC_Inc_3_Small" , \
20462050 "SC_Dec_1_Large" , "SC_Inc_1_Large" , "SC_Dec_2_Large" , "SC_Inc_2_Large" , "SC_Dec_3_Large" , "SC_Inc_3_Large" , \
2047- "enableTabsOnLaunch" ]
2051+ "enableTabsOnLaunch" , "whiteListedMACs" ]
20482052
20492053 # KICK OUT ANY PARAMETERS THAT AREN'T IN THE "ACCEPTABLE ARGUMENTS" LIST ABOVE
20502054 # THIS SECTION OF CODE IS *SLIGHTLY* DIFFERENT THAN THE CLI KICK OUT CODE
@@ -2099,6 +2103,7 @@ def loadPrefsFile(globalPrefsFile = ""):
20992103 # THESE ARE OPTIONS THAT HELP DEBUG THINGS, BUT AREN'T REALLY USEFUL FOR NORMAL OPERATION
21002104 # enableTabsOnLaunch SHOWS ALL TABS ACTIVE (INSTEAD OF DISABLING THEM) ON LAUNCH SO EVEN WITHOUT A LIGHT, A BYTESTRING CAN BE CALCULATED
21012105 prefsParser .add_argument ("--enableTabsOnLaunch" , default = 0 )
2106+ prefsParser .add_argument ("--whiteListedMACs" , default = [])
21022107
21032108 mainPrefs = prefsParser .parse_args (mainPrefs )
21042109
@@ -2114,6 +2119,9 @@ def loadPrefsFile(globalPrefsFile = ""):
21142119 else : # the return is already a list (the default list), so return it
21152120 acceptable_HTTP_IPs = mainPrefs .acceptableIPs
21162121
2122+ if type (mainPrefs .whiteListedMACs ) is not list : # if we've specified MAC addresses to whitelist, add them to the global list
2123+ whiteListedMACs = mainPrefs .whiteListedMACs .replace (" " , "" ).split (";" )
2124+
21172125 # RETURN THE CUSTOM KEYBOARD MAPPINGS
21182126 customKeys = [mainPrefs .SC_turnOffButton , mainPrefs .SC_turnOnButton , mainPrefs .SC_scanCommandButton , mainPrefs .SC_tryConnectButton , \
21192127 mainPrefs .SC_Tab_CCT , mainPrefs .SC_Tab_HSI , mainPrefs .SC_Tab_SCENE , mainPrefs .SC_Tab_PREFS , \
0 commit comments