ufozone / ha-unifi-voucher

UniFi Hotspot Manager Integration
MIT License
26 stars 3 forks source link

Hotspot user returns invalid credentials #125

Closed cinghialino closed 3 days ago

cinghialino commented 3 days ago

i can't use a "Hotspot Manager" credentials when setting up the integration, it only works with a Administrator role.

ufozone commented 3 days ago

I have tried it with a local user with hotspot manager rights and it works. We need more information:

cinghialino commented 3 days ago

Controller hosting type: Docker container, jacobalberty/unifi:latest Controller network version: 8.4.59 HA integration logs: Login failed '{'meta': {'rc': 'error', 'msg': 'api.err.Invalid'}, 'data': []}'

again, the problem does not appear (and everything works as intended) when using an Administrator account

ufozone commented 3 days ago

The error message comes directly from the controller and not from the integration. A login with an incorrect password is recognized in this way.

With the following settings, I can create a local user with which the integration can log in: grafik

If you can use an admin user, then this might be the right way for you. Your problem is not due to the integration - then a different error message would appear in the logs.

cinghialino commented 3 days ago

got it. Thanks for the explanation. Curiously, when I am setting up an user as a hotspot manager, I do not get the same UI as you. Check this out:

Screenshot 2024-09-15 at 06 47 52
cinghialino commented 3 days ago

also check this

Screenshot 2024-09-15 at 06 51 39
ufozone commented 3 days ago

got it. Thanks for the explanation. Curiously, when I am setting up an user as a hotspot manager, I do not get the same UI as you. Check this out: Screenshot 2024-09-15 at 06 47 52

I don't know the docker version of the controller. But it doesn't actually look that wrong. The integration uses the Unifi library https://github.com/Kane610/aiounifi. It is the same one that is used by the [https://www.home-assistant.io/integrations/unifi/](UniFi Network Core Integration). Try logging into this once with the new user. If this does not work either, it is due to the Docker environment.

also check this Screenshot 2024-09-15 at 06 51 39

I have fixed the typo.

cinghialino commented 3 days ago

just discovered it's a networking issue. The controller in docker uses the container internal ip address (172.17.2.33) that creates the problem and doesn't allow me to see the hotspot manager UI, therefore denying the credentials. This doesn't happen when changing the Hotspot URL IP to the one of the machine itself. I'm currently trying to fix it using macvlan.

cinghialino commented 2 days ago

not solved. I don't understand it as I can login in the hotspot manager interface no problem, but when I use the same information in the integration, it doesn't work. it's not a networking problem, it returns an invalid authentication.

ufozone commented 2 days ago

I don't know the docker version of the controller. But it doesn't actually look that wrong. The integration uses the Unifi library https://github.com/Kane610/aiounifi. It is the same one that is used by the [https://www.home-assistant.io/integrations/unifi/](UniFi Network Core Integration). Try logging into this once with the new user. If this does not work either, it is due to the Docker environment.

can you log into the unifi network integration with this username or not? if not, then it's not the integration but the docker setup

cinghialino commented 2 days ago

I can only setup the integration with my Administrator user (which is also remote accessible), but NOT with the hotspot manager user.

ufozone commented 2 days ago

Yes, I understood that. Then it doesn't seem to work with your Docker setup. Sorry, I can't help you.

cinghialino commented 2 days ago

that's one way to "solve" it. thanks! take care.

ufozone commented 2 days ago

Sure. I have two other ideas to solve it:

  1. create a fork and analyze your issue yourself. If you actually find a bug in the integration, then fix it and create a pull request. That way you are doing something for the community.
  2. create a proper bug report with all the information we need. Don't let people pull everything out of your nose and help to find the problem. This would also help the community.

But what are you doing? A bug report with only "does not work" description, you only provide half of the information I ask you for, and incomplete information at all. Then you get snotty. How the hell are we supposed to help you like that?

Tens of people, including me, have successfully run the integrations with an only hotspot manager user. Your problem is not reproducible, so what should I do without more information????

cinghialino commented 2 days ago

I got snarky when you dismissed it with closing the ticket and telling me "I can't help you". Have you thought for a moment that not everyone has the same knowledge as you?

what do you need? please be specific.

ufozone commented 2 days ago

Sure, nobody has the same knowledge about the integration as I in the moment.

I'll make it clear again: This one log entry you copied in here comes from your controller. Not from HA integration. If it works with the admin and not with the other user, it seems to be due to your controller. Not the HA integration. And without further logs and diagnostic information from the HA integration, there is simply nothing I can do.

And since you don't provide any further information and it looks like it's just your controller, this "issue" is solved here. Until you provide more information that tells us otherwise.

The read me explains how to activate debug mode. Do that. Try it again and paste the logs here (retain passwords first).

It is possible that it does not work due to the docker setup. To find out, you should try it with your hotspot user and the core integration "UniFi Network". Activate the logs there too and see what it says. If that doesn't work either, then it's due to the controller in the docker.