From f1ae19991a9cbef871e67860daf20d4fa07fcfc2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20Chac=C3=B3n?= Date: Thu, 27 Oct 2022 14:21:00 -0600 Subject: [PATCH] Handle cases where device is AP but has no reported capacity --- v1.3/integrationUISP.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/v1.3/integrationUISP.py b/v1.3/integrationUISP.py index 6eb25708..0ba53b26 100644 --- a/v1.3/integrationUISP.py +++ b/v1.3/integrationUISP.py @@ -105,8 +105,18 @@ def createNetworkJSON(): headers = {'accept':'application/json', 'x-auth-token': uispAuthToken} r = requests.get(url, headers=headers) thisAPairmax = r.json() - downloadCap = int(round(thisAPairmax['overview']['downlinkCapacity']/1000000)) - uploadCap = int(round(thisAPairmax['overview']['uplinkCapacity']/1000000)) + # See if there is a reported capacity of the AP we can use. If not, use a default (1000 Mbit) + defaultCap = 1000 + if ('downlinkCapacity' in thisAPairmax['overview']) and ('uplinkCapacity' in thisAPairmax['overview']): + if thisAPairmax['overview']['downlinkCapacity'] != None: + downloadCap = int(round(thisAPairmax['overview']['downlinkCapacity']/1000000)) + uploadCap = int(round(thisAPairmax['overview']['uplinkCapacity']/1000000)) + else: + downloadCap = defaultCap + uploadCap = defaultCap + else: + downloadCap = defaultCap + uploadCap = defaultCap # If operator already included bandwidth definitions for this ParentNode, do not overwrite what they set if name not in listOfTopLevelParentNodes: print("Found " + name)