Error: global name 'mac' is not defined

Posted on
Thu Jan 21, 2021 2:00 pm
James offline
Posts: 22
Joined: Aug 16, 2011

Error: global name 'mac' is not defined

Hello,

Great work on this plugin. I really appreciate all the work you continue to put into it.

Since a few versions back, my Indigo logs have been flooded with the following error:
Code: Select all
uniFiAP Error                   in Line 6023 has error=global name 'mac' is not defined

After upgrading to the most recent plugin version (7.34.308), I am now getting the following warning:
Code: Select all
uniFiAP Warning                 bad return from unifi controller, no os and / port found

Indigo Version: 7.4
uniFiAP Version: 7.34.308
Controller Version: 6.0.43 (macOS on same machine running Indigo server)

Posted on
Thu Jan 21, 2021 4:52 pm
kw123 offline
User avatar
Posts: 8360
Joined: May 12, 2013
Location: Dallas, TX

Re: Error: global name 'mac' is not defined

1. could you run in a terminal

curl --insecure -I -s --w "%{http_code}" 'https://ip-of-controller:8443'
and
curl --insecure -I -s -w "%{http_code}" 'https://ip-of-controller:443'

naturally replace ip-of-controller with the ip # of your controller

.. and post the result?
you should get something like:
Code: Select all
HTTP/1.1 200 OK   <------- or 302
Vary: Origin
X-DNS-Prefetch-Control: off
X-Frame-Options: SAMEORIGIN
Strict-Transport-Security: max-age=15552000; includeSubDomains
X-Download-Options: noopen
X-Content-Type-Options: nosniff
X-XSS-Protection: 1; mode=block
Accept-Ranges: bytes
X-CSRF-Token: e8cb1e5d-1a49-4a18-88cc-39c4e3c6c8fa
Content-Type: text/html; charset=utf-8
Content-Length: 357
X-Response-Time: 4ms
Set-Cookie: TOKEN=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJjc3JmVG9rZW4iOiJlOGNiMWU1ZC0xYTQ5LTRhMTgtODhjYy0zOWM0ZTNjNmM4ZmEiLCJpYXQiOjE2MTEyNjk0ODAsImV4cCI6MTYxMTI3MzA4MH0.s9TVFsOUSN9kR1d8ucPrJBTdeLLN1ipQwNYnNfB6XfQ; path=/; secure; httponly
Date: Thu, 21 Jan 2021 22:51:20 GMT
Connection: keep-alive
with the right port #


and uniFiAP Error in Line 6023 has error=global name 'mac' is not defined
Screen Shot 2021-01-21 at 16.48.34.png
Screen Shot 2021-01-21 at 16.48.34.png (7.51 KiB) Viewed 3036 times

is a minor bug, has no real impact beside log entries (does not set the expiration timer default settings (you have selected in config to set exp timer to max of device settings and ap/gw/sw repeat read time)
fixed later today

Karl

Posted on
Thu Jan 21, 2021 5:55 pm
James offline
Posts: 22
Joined: Aug 16, 2011

Re: Error: global name 'mac' is not defined

Unchecking the "Change exp-time automatically..." option worked to stop the errors. Thank you!

Here are the responses to the curl commands:

curl --insecure -I -s -w "%{http_code}" 'https://x.x.x.x:8443'
Code: Select all
HTTP/1.1 302
Location: /manage
Transfer-Encoding: chunked
Date: Thu, 21 Jan 2021 23:48:50 GMT

302

curl --insecure -I -s -w "%{http_code}" 'https://x.x.x.x:443'
Code: Select all
000

Posted on
Thu Jan 21, 2021 6:41 pm
kw123 offline
User avatar
Posts: 8360
Joined: May 12, 2013
Location: Dallas, TX

Re: Error: global name 'mac' is not defined

if you could try: v .309

fixed "mac" error

and add some more checking around the new method to find the proper port and op system on the controller

Karl

Posted on
Thu Jan 21, 2021 6:56 pm
James offline
Posts: 22
Joined: Aug 16, 2011

Re: Error: global name 'mac' is not defined

Wow! You're quick! :)

I just tried .309 and re-enabled the "Change exp-time automatically..." option. Unfortunately the 'mac' error still exists:
Code: Select all
   uniFiAP Error                   in Line 6046 has error=global name 'mac' is not defined

Here is the log output from the plugin when starting. It tried to connect to port 443 and failed (which is to be expected), but then got the same warnings after that.
Code: Select all
   Starting plugin "uniFiAP 7.34.309" (pid 41534)
   uniFiAP                         initializing  ...
   uniFiAP                         path To files:          =================
   uniFiAP                         indigo                  /Library/Application Support/Perceptive Automation/
   uniFiAP                         installFolder           /Library/Application Support/Perceptive Automation/Indigo 7.4/
   uniFiAP                         plugin.py               /Library/Application Support/Perceptive Automation/Indigo 7.4/Plugins/uniFiAP.indigoPlugin/Contents/Server Plugin/
   uniFiAP                         Plugin params           /Library/Application Support/Perceptive Automation/Indigo 7.4/Preferences/Plugins/com.karlwachs.uniFiAP/
   uniFiAP                         logger  enabled for     INFO           ==> TEST ONLY
   uniFiAP Warning                 logger  enabled for     WARNING        ==> TEST ONLY
   uniFiAP Error                   logger  enabled for     ERROR          ==> TEST ONLY
   uniFiAP Critical Error          logger  enabled for     CRITICAL       ==> TEST ONLY
   uniFiAP                         check                   /Library/Application Support/Perceptive Automation/Indigo 7.4/Logs/com.karlwachs.uniFiAP/plugin.log  <<<<    for detailed logging
   uniFiAP                         Plugin short Name       UniFi
   uniFiAP                         my PID                  41534
   uniFiAP                         set params for indigo V 7.4
   Started plugin "uniFiAP 7.34.309"
   uniFiAP                         testing if variable enableTimeTracking_UniFi is == on/off/print-option to enable/end/print time tracking of all functions and methods (option:'',calls,cumtime,pcalls,time)
   uniFiAP                         myLogSet setting parameters -- logFileActive= ; logFile= /Library/Application Support/Perceptive Automation/Indigo 7.4/Preferences/Plugins/com.karlwachs.uniFiAP/plugin.log;  debugLevel= []
   uniFiAP                         MAP2Vendor initializing
   uniFiAP                         MAP2Vendor initializing  finished, read from mac2Vendor.json file
   uniFiAP                         MAP2Vendor initializing  finished, read from mac2Vendor.json file
   uniFiAP Error                   UNIFI executeCMDOnController error no json object: (wrong UID/passwd, ip number?x.x.x.x) ...>><<
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed

  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0curl: (7) Failed to connect to x.x.x.x port 443: Connection refused

   uniFiAP Warning                 bad return from unifi controller, no os and / port found
   uniFiAP Warning                 bad return from unifi controller, no os and / port found
   uniFiAP Warning                 bad return from unifi controller, no os and / port found
   uniFiAP Warning                 bad return from unifi controller, no os and / port found
   uniFiAP Warning                 bad return from unifi controller, no os and / port found
   uniFiAP                          start   runConcurrentThread, initializing loop settings and threads ..
   uniFiAP Warning                 bad return from unifi controller, no os and / port found
   uniFiAP Warning                 bad return from unifi controller, no os and / port found
   uniFiAP Warning                 bad return from unifi controller, no os and / port found
   uniFiAP Warning                 bad return from unifi controller, no os and / port found
   uniFiAP                         initialized ... looping

Posted on
Thu Jan 21, 2021 7:47 pm
kw123 offline
User avatar
Posts: 8360
Joined: May 12, 2013
Location: Dallas, TX

Re: Error: global name 'mac' is not defined

Please check the plugin.log file. There is more info

and also try the terminal curl command!!


Sent from my iPhone using Tapatalk

Posted on
Thu Jan 21, 2021 8:01 pm
kw123 offline
User avatar
Posts: 8360
Joined: May 12, 2013
Location: Dallas, TX

Re: Error: global name 'mac' is not defined

... and try v 310 .. at least the mac not found errno SHOULD be fixed..

Posted on
Thu Jan 21, 2021 8:38 pm
James offline
Posts: 22
Joined: Aug 16, 2011

Re: Error: global name 'mac' is not defined

Yes. Version 310 fixed the 'mac' error. Thank you!

As for the other error, I can see it retying over and over, but it is only trying port 443 and never tries 8443.

Code: Select all
21 21:33:25 getunifiOSAndPort existing  os>< .. ip#>x.x.x.x< .. port>443<
21 21:33:25 getunifiOSAndPort ret code:('000', '')
21 21:33:25 getunifiOSAndPort wrong ret code from curl test:('000', ''), expecting 200 or 302, try again
21 21:33:25 getunifiOSAndPort ret code:('000', '')
21 21:33:25 getunifiOSAndPort wrong ret code from curl test:('000', ''), expecting 200 or 302, try again
21 21:33:26 getunifiOSAndPort existing  os>< .. ip#>x.x.x.x< .. port>443<
21 21:33:26 getunifiOSAndPort ret code:('000', '')
21 21:33:26 getunifiOSAndPort wrong ret code from curl test:('000', ''), expecting 200 or 302, try again
21 21:33:26 getunifiOSAndPort ret code:('000', '')
21 21:33:26 getunifiOSAndPort wrong ret code from curl test:('000', ''), expecting 200 or 302, try again
21 21:33:27 getunifiOSAndPort existing  os>< .. ip#>x.x.x.x< .. port>443<
21 21:33:27 getunifiOSAndPort ret code:('000', '')
21 21:33:27 getunifiOSAndPort wrong ret code from curl test:('000', ''), expecting 200 or 302, try again
21 21:33:27 getunifiOSAndPort ret code:('000', '')
21 21:33:27 getunifiOSAndPort wrong ret code from curl test:('000', ''), expecting 200 or 302, try again
21:33:28 bad return from unifi controller, no os and / port found

Running the cURL command on port 8443 still returns the same 302 redirect.

Posted on
Thu Jan 21, 2021 8:48 pm
James offline
Posts: 22
Joined: Aug 16, 2011

Re: Error: global name 'mac' is not defined

I see on line 4321 in the plugin.py file, the port variable used in the curl command is 'self.unifiCloudKeyPort'.
Code: Select all
cmdOS = self.unfiCurl+u" --insecure  -I -s -o /dev/null -w \"%{http_code}\" 'https://"+self.unifiCloudKeyIP+u":"+self.unifiCloudKeyPort+u"'"


Should it instead be 'port'?
Code: Select all
cmdOS = self.unfiCurl+u" --insecure  -I -s -o /dev/null -w \"%{http_code}\" 'https://"+self.unifiCloudKeyIP+u":"+port+u"'"

Posted on
Thu Jan 21, 2021 9:13 pm
James offline
Posts: 22
Joined: Aug 16, 2011

Re: Error: global name 'mac' is not defined

Changing line 4321 in the plugin.py file to the following indeed fixed the port issue:
Code: Select all
cmdOS = self.unfiCurl+u" --insecure  -I -s -o /dev/null -w \"%{http_code}\" 'https://"+self.unifiCloudKeyIP+u":"+port+u"'"


However, I then started getting login errors; so I changed the login path on line 4335 from '/api/auth/login' to '/api/login'.
Code: Select all
self.unifiApiLoginPath = "/api/login"


Everything is working perfectly now. :)

Posted on
Thu Jan 21, 2021 9:47 pm
kw123 offline
User avatar
Posts: 8360
Joined: May 12, 2013
Location: Dallas, TX

Re: Error: global name 'mac' is not defined

v .311 should have that fixed... mine worked because the default was already set .

it should work for the std op sys now too.

and thanks for your help


Karl

Posted on
Thu Jan 21, 2021 9:50 pm
James offline
Posts: 22
Joined: Aug 16, 2011

Re: Error: global name 'mac' is not defined

No problem. Just tested version 311 and it works great. Thank you!

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 3 guests