Skip to content

Commit 574309d

Browse files
committed
1-7-22 - Debugging an error with the power/channel return status
To troubleshoot Issue #15, a shorter set of information returned from a light will not crash the program now, but will print the information that *was* returned from the light.
1 parent e71379f commit 574309d

File tree

1 file changed

+18
-12
lines changed

1 file changed

+18
-12
lines changed

NeewerLite-Python.py

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1052,19 +1052,25 @@ async def getLightChannelandPower(selectedLight):
10521052

10531053
powerInfo = await readNotifyCharacteristic(selectedLight, [120, 133, 0, 253])
10541054

1055-
if powerInfo != "" and powerInfo[3] == 1:
1056-
returnInfo[0] = "ON"
1055+
try:
1056+
if powerInfo != "" and powerInfo[3] == 1:
1057+
returnInfo[0] = "ON"
10571058

1058-
# IF THE LIGHT IS ON, THEN ATTEMPT TO READ THE CURRENT CHANNEL
1059-
chanInfo = await readNotifyCharacteristic(selectedLight, [120, 132, 0, 252])
1060-
1061-
if chanInfo != "": # if we got a result from the query
1062-
try:
1063-
returnInfo[1] = chanInfo[3] # set the current channel to the returned result
1064-
except IndexError:
1065-
pass # if we have an index error (the above value doesn't exist), then just return -1
1066-
elif powerInfo != "" and powerInfo[3] == 2:
1067-
returnInfo[0] = "STBY"
1059+
# IF THE LIGHT IS ON, THEN ATTEMPT TO READ THE CURRENT CHANNEL
1060+
chanInfo = await readNotifyCharacteristic(selectedLight, [120, 132, 0, 252])
1061+
1062+
if chanInfo != "": # if we got a result from the query
1063+
try:
1064+
returnInfo[1] = chanInfo[3] # set the current channel to the returned result
1065+
except IndexError:
1066+
pass # if we have an index error (the above value doesn't exist), then just return -1
1067+
elif powerInfo != "" and powerInfo[3] == 2:
1068+
returnInfo[0] = "STBY"
1069+
except IndexError:
1070+
# if we have an IndexError (the information returned isn't blank, but also isn't enough to descipher the status)
1071+
# then just error out, but print the information that *was* returned for debugging purposes
1072+
printDebugString("We don't have enough information from light [" + availableLights[selectedLight][0].name + "] to get the status.")
1073+
print(powerInfo)
10681074

10691075
availableLights[selectedLight][7][0] = returnInfo[0]
10701076

0 commit comments

Comments
 (0)