Wizzard72 / Domoticz-Unifi-Presence

GNU General Public License v3.0
5 stars 7 forks source link

request_online_phones: Invalid login, or login has expired #11

Closed Meulderg closed 3 years ago

Meulderg commented 3 years ago

After setting up all the required fields, i get the following in my log:

021-03-14 22:31:27.377 Status: (uniFI Controller) Stop directive received. 2021-03-14 22:31:27.378 Status: (uniFI Controller) Exiting work loop. 2021-03-14 22:31:27.678 Status: (uniFI Controller) Stopping threads. 2021-03-14 22:31:27.678 Status: (uniFI Controller) Stopped. 2021-03-14 22:31:30.818 Status: (uniFI Controller) Started. 2021-03-14 22:31:31.514 (uniFI Controller) Debug logging mask set to: NONE 2021-03-14 22:31:31.514 (uniFI Controller) setVersionCheck - Plugin allowed to start (triggered by: onStart) 2021-03-14 22:31:31.514 (uniFI Controller) Number of icons loaded = 3 2021-03-14 22:31:31.514 (uniFI Controller) onStart: Items = UnifiPresenceAnyone 2021-03-14 22:31:31.514 (uniFI Controller) onStart: Icon 101 Name = UnifiPresence 2021-03-14 22:31:31.514 (uniFI Controller) onStart: Items = UnifiPresenceOverride 2021-03-14 22:31:31.514 (uniFI Controller) onStart: Icon 102 Name = UnifiPresence 2021-03-14 22:31:31.514 (uniFI Controller) onStart: Items = UnifiPresenceDevice 2021-03-14 22:31:31.514 (uniFI Controller) onStart: Icon 103 Name = UnifiPresence 2021-03-14 22:31:31.865 (uniFI Controller) login: Login successful into Unifi Controller 2021-03-14 22:31:31.876 (uniFI Controller) detect Unifi Devices: Invalid login, or login has expired 2021-03-14 22:31:31.876 (uniFI Controller) create_devices: Found phone to monitor from configuration = Geert-Jan=D4:**:**:**:**:A2 2021-03-14 22:31:31.876 (uniFI Controller) create_devices: Found phone to monitor from configuration = Mariska=AA:**:**:**:**:4E 2021-03-14 22:31:31.877 (uniFI Controller) onStart: Phone Naam = OverRide | 00:00:00:00:00:00 | 255 | Off | No | No 2021-03-14 22:31:31.877 (uniFI Controller) onStart: Phone Naam = Geert-Jan | D4:**:**:**:**:A2 | 50 | Off | No | No 2021-03-14 22:31:31.877 (uniFI Controller) onStart: Phone Naam = Mariska | AA:**:**:**:**:4E | 51 | Off | No | No 2021-03-14 22:31:31.510 Status: (uniFI Controller) Initialized version 2.7.10, author 'Wizzard72' 2021-03-14 22:31:31.509 Status: (uniFI Controller) Entering work loop. 2021-03-14 22:31:41.546 (uniFI Controller) onHeartbeat: Attempting to reconnect Unifi Controller 2021-03-14 22:31:41.813 (uniFI Controller) login: Login successful into Unifi Controller 2021-03-14 22:31:41.831 (uniFI Controller) request_details: Invalid login, or login has expired 2021-03-14 22:31:42.075 (uniFI Controller) login: Login successful into Unifi Controller 2021-03-14 22:31:42.094 (uniFI Controller) request_online_phones: Invalid login, or login has expired 2021-03-14 22:31:42.396 (uniFI Controller) login: Login successful into Unifi Controller 2021-03-14 22:31:46.924 (uniFI Controller) request_details: Invalid login, or login has expired 2021-03-14 22:31:47.258 (uniFI Controller) login: Login successful into Unifi Controller 2021-03-14 22:31:47.276 (uniFI Controller) request_online_phones: Invalid login, or login has expired 2021-03-14 22:31:47.525 (uniFI Controller) login: Login successful into Unifi Controller

My uniFi controller is running 5.13.32 (Build: atag_5.13.32_13646)

Hope you can help me figuring out why i get this message.

Thanks in advance, Meulderg

Wizzard72 commented 3 years ago

Can you provide me the plugin settings? In the Unifi Controller logs do you see a succesful login for the plugin useraccount? Also plugin name with a space in it is not supported. So change "uniFI Controller" to "uniFIController".

Meulderg commented 3 years ago

I removed the space in the plugin name.

The message in the log file is still the same: 2021-03-15 12:31:17.003 (uniFiController) request_details: Invalid login, or login has expired 2021-03-15 12:31:17.279 (uniFiController) login: Login successful into Unifi Controller 2021-03-15 12:31:17.290 (uniFiController) request_online_phones: Invalid login, or login has expired 2021-03-15 12:31:17.567 (uniFiController) login: Login successful into Unifi Controller

Domoticz_Unifi_Plugin

Wizzard72 commented 3 years ago

Can you try to connect to this URL: https://192.168.1.253:8443/api/s/Meulders/stat/device

or https://192.168.1.253:8443/api/s/default/stat/device

If the second one works you have to change your site name to "default"

blaxxor commented 3 years ago

Thanks for the tip about default. I hade the same problem as OP and changing to default solved it for me.

Wizzard72 commented 3 years ago

Somehow the Unifi API don't uses the site name. Maybe this changes when 2 sites are configured. I can't test this as I have only 1 site configured.

blaxxor commented 3 years ago

I have two sites but only one with devices in it. Maybe you can create a new site on your controller only for testing but I don't know if you can catch any data from site two if it's empty tough. It's interesting since none of my sites is named default but the data is being picked up anyway.

Meulderg commented 3 years ago

Sorry for my late response. I have tried the links you mentioned, they give me the following result.

https://192.168.1.253:8443/api/s/Meulders/stat/device {"meta":{"rc":"error","msg":"api.err.LoginRequired"},"data":[]}

and https://192.168.1.253:8443/api/s/default/stat/device {"meta":{"rc":"error","msg":"api.err.LoginRequired"},"data":[]}

I tried the links with and without being logged in to the uniFi controller. I also tried to change the Site Name in the settings. Then the log looks like. 2021-03-26 19:30:01.118 Status: (uniFiController) Stop directive received. 2021-03-26 19:30:01.118 Status: (uniFiController) Exiting work loop. 2021-03-26 19:30:01.919 Status: (uniFiController) Stopping threads. 2021-03-26 19:30:01.919 Status: (uniFiController) Stopped. 2021-03-26 19:30:01.919 Status: (uniFiController) Started. 2021-03-26 19:30:03.015 Status: (uniFiController) Entering work loop. 2021-03-26 19:30:03.017 Status: (uniFiController) Initialized version 2.7.10, author 'Wizzard72' 2021-03-26 19:30:03.019 Error: (uniFiController) 'onStart' failed 'KeyError'. 2021-03-26 19:30:03.019 Error: (uniFiController) ----> Line 1209 in '/home/pi/domoticz/plugins/Domoticz-Unifi-Presence/plugin.py', function onStart 2021-03-26 19:30:03.019 Error: (uniFiController) ----> Line 177 in '/home/pi/domoticz/plugins/Domoticz-Unifi-Presence/plugin.py', function onStart 2021-03-26 19:30:05.519 (uniFiController) Pushing 'onHeartbeatCallback' on to queue 2021-03-26 19:30:05.522 (uniFiController) Processing 'onHeartbeatCallback' message 2021-03-26 19:30:05.522 (uniFiController) Calling message handler 'onHeartbeat'. 2021-03-26 19:30:05.523 (uniFiController) onHeartbeat: called 2021-03-26 19:30:05.523 (uniFiController) onHeartbeat: Requesting Unifi Controller details 2021-03-26 19:30:05.537 (uniFiController) request_details: Invalid login, or login has expired 2021-03-26 19:30:05.537 (uniFiController) login: called 2021-03-26 19:30:05.856 (uniFiController) login: Login successful into Unifi Controller 2021-03-26 19:30:05.867 (uniFiController) request_online_phones: Invalid login, or login has expired

And from the log of my uniFi controller, i can see that your software can login to the controller. Admin ADM@@@E ingelogd vanaf 192.168.1.17 07:31 pm 26/03/2021
Admin ADM@@@E ingelogd vanaf 192.168.1.17 07:31 pm 26/03/2021
Admin ADM@@@E ingelogd vanaf 192.168.1.17 07:31 pm 26/03/2021
Admin ADM@@@E ingelogd vanaf 192.168.1.17 07:31 pm 26/03/2021
Admin ADM@@@E ingelogd vanaf 192.168.1.17 07:31 pm 26/03/2021
Admin ADM@@@E ingelogd vanaf 192.168.1.17 07:31 pm 26/03/2021
Admin ADM@@@E ingelogd vanaf 192.168.1.17 07:31 pm 26/03/2021
Admin ADM@@@E ingelogd vanaf 192.168.1.17 07:31 pm 26/03/2021
Admin ADM@@@E ingelogd vanaf 192.168.1.17 07:31 pm 26/03/2021
Admin ADM@@@E ingelogd vanaf 192.168.1.17 07:31 pm 26/03/2021
Admin ADM@@@E ingelogd vanaf 192.168.1.17 07:31 pm 26/03/2021
Admin ADM@@@E ingelogd vanaf 192.168.1.17 07:31 pm 26/03/2021
Admin ADM@@@E ingelogd vanaf 192.168.1.17 07:31 pm 26/03/2021
Admin ADM@@@E ingelogd vanaf 192.168.1.17 07:31 pm 26/03/2021
Admin ADM@@@E ingelogd vanaf 192.168.1.17 07:31 pm 26/03/2021
Admin ADM@@@E ingelogd vanaf 192.168.1.17 07:31 pm 26/03/2021
Admin ADM@@@E ingelogd vanaf 192.168.1.17 07:31 pm 26/03/2021
Admin ADM@@@E ingelogd vanaf 192.168.1.17 07:31 pm 26/03/2021
Admin ADM@@@E ingelogd vanaf 192.168.1.17 07:30 pm 26/03/2021 There are no other log files with error on the uniFi controller.

Wizzard72 commented 3 years ago

If you login first to the Unifi controller. When the UI is loaded then try to access these URL's (in the same browser and tab):

https://192.168.1.253:8443/api/s/Meulders/stat/device

or https://192.168.1.253:8443/api/s/default/stat/device

Meulderg commented 3 years ago

I did what you asked "If you login first to the Unifi controller" then used https://192.168.1.253:8443/api/s/default/stat/device. That gave me a whole list of settings.

Wizzard72 commented 3 years ago

If that is the case, then try the following:

If that's not working check username and password. Maybe there is a typo or a space at the end? Can also check if there is a space at the end of the IP Address.

Meulderg commented 3 years ago

Found it, the field " Site Name" is case sensitive. So lower case only.

Wizzard72 commented 3 years ago

Didn't think of that. Great it's solved. I'm going to add the case sensitive to the plugin hardware page.

Thanks for sorting this out.