rootnegativ1 / unifi-wifi

Home Assistant integration to change wireless passwords on UniFi Network controllers
MIT License
3 stars 0 forks source link

api.err.LoginRequired #19

Closed backisen closed 6 months ago

backisen commented 6 months ago

I get this error when adding unifi-wifi to configuration.yaml:

Logger: custom_components.unifi_wifi.coordinator
Source: helpers/update_coordinator.py:353
Integration: Unifi Wifi (documentation, issues)
First occurred: 10:52:00 (1 occurrences)
Last logged: 10:52:00

Authentication failed while fetching klubben319 data: {'meta': {'rc': 'error', 'msg': 'api.err.LoginRequired'}, 'data': []}

unifi-wifi installed via HACS. Running latest stable version of HAOS and Home Assistant.

configuration.yaml:

unifi_wifi:
  - name: klubben319
    host: wifi.klubben319.se
    port: 443
    username: REDACTED
    password: REDACTED

The unifi controller can be accessed at the adress stated in host. I have double and triple checked username and password.

rootnegativ1 commented 6 months ago

When I entered your host:port in a browser the login screen was available. That login screen indicates your controller is not using UniFi OS. If this is the case, try including unifi_os: false in your YAML.

Is the controller supposed to be widely accessible on the internet?

backisen commented 6 months ago

When I entered your host:port in a browser the login screen was available. That login screen indicates your controller is not using UniFi OS. If this is the case, try including unifi_os: false in your YAML.

Is the controller supposed to be widely accessible on the internet?

Thanks, that was the problem.

Running the services doesn't change anything. Nothing to be found in homeassistant logs. Is there relevant logs somewhere else?

service: unifi_wifi.random_password
data:
  target:
    entity_id: image.klubben319_guest_qr_code
  method: xkcd

Is there something regarding the wifi settings that need to be changed berfore using the service: image

rootnegativ1 commented 6 months ago

That's intriguing. Are you accessing the controller from outside your own network? I wonder if something in your firewall / setup may be blocking the HTTP PUT method used when attempting to change the wireless password. Maybe try using the IP address of the controller from within your network.

backisen commented 6 months ago

That's intriguing. Are you accessing the controller from outside your own network? I wonder if something in your firewall / setup may be blocking the HTTP PUT method used when attempting to change the wireless password. Maybe try using the IP address of the controller from within your network.

I´ve tried accessing it using the local ip. Login seems to work but I still can't change password nor enable/disable WLANs. Is it possible to set debug log or access log some kind of logile?

Dzanar commented 6 months ago

That's intriguing. Are you accessing the controller from outside your own network? I wonder if something in your firewall / setup may be blocking the HTTP PUT method used when attempting to change the wireless password. Maybe try using the IP address of the controller from within your network.

I´ve tried accessing it using the local ip. Login seems to work but I still can't change password nor enable/disable WLANs. Is it possible to set debug log or access log some kind of logile?

Add this to your configuration.yaml logger: default: info logs: custom_components.unifi_wifi: debug

If you need more verbose log open the file /homeassistant/custom_components/unifi_wifi/coordinator.py and set the DEBUG varriable to True (line 65)

EDIT: After the changes you need to restart home assistant.

backisen commented 6 months ago

That's intriguing. Are you accessing the controller from outside your own network? I wonder if something in your firewall / setup may be blocking the HTTP PUT method used when attempting to change the wireless password. Maybe try using the IP address of the controller from within your network.

I´ve tried accessing it using the local ip. Login seems to work but I still can't change password nor enable/disable WLANs. Is it possible to set debug log or access log some kind of logile?

Add this to your configuration.yaml logger: default: info logs: custom_components.unifi_wifi: debug

If you need more verbose log open the file /homeassistant/custom_components/unifi_wifi/coordinator.py and set the DEBUG varriable to True (line 65)

EDIT: After the changes you need to restart home assistant.

Thanks. Maybe one step closer to the solution:

2024-01-03 22:22:32.580 DEBUG (MainThread) [custom_components.unifi_wifi.services] Entity ID image.klubben319_guest_qr_code does not belong to platform unifi_wifi

image.klubben319_guest_qr_code is the entity created by the unifi integration.

rootnegativ1 commented 6 months ago

2024-01-03 22:22:32.580 DEBUG (MainThread) [custom_components.unifi_wifi.services] Entity ID image.klubben319_guest_qr_code does not belong to platform unifi_wifi

image.klubben319_guest_qr_code is the entity created by the unifi integration.

That is unexpected. I noticed the entity ID being different that what the component generates, however when I made similar changes on my test system, the entity continued belonging to the unifi_wifi platform. I'm not sure how that would have happened. Could you try one of the following:

backisen commented 6 months ago

2024-01-03 22:22:32.580 DEBUG (MainThread) [custom_components.unifi_wifi.services] Entity ID image.klubben319_guest_qr_code does not belong to platform unifi_wifi image.klubben319_guest_qr_code is the entity created by the unifi integration.

That is unexpected. I noticed the entity ID being different that what the component generates, however when I made similar changes on my test system, the entity continued belonging to the unifi_wifi platform. I'm not sure how that would have happened. Could you try one of the following:

  • delete the entity and restart
  • remove the component from your install (comment out the yaml), restart, remove any lingering image entities, restart, uncomment the yaml, and then restart one last time

I've solved this. I was using the image from the native Unifi integration, not this custome component. Changed this and now everything works. Thanks for support! Great component!

Dzanar commented 6 months ago

2024-01-03 22:22:32.580 DEBUG (MainThread) [custom_components.unifi_wifi.services] Entity ID image.klubben319_guest_qr_code does not belong to platform unifi_wifi image.klubben319_guest_qr_code is the entity created by the unifi integration.

That is unexpected. I noticed the entity ID being different that what the component generates, however when I made similar changes on my test system, the entity continued belonging to the unifi_wifi platform. I'm not sure how that would have happened. Could you try one of the following:

  • delete the entity and restart
  • remove the component from your install (comment out the yaml), restart, remove any lingering image entities, restart, uncomment the yaml, and then restart one last time

I've solved this. I was using the image from the native Unifi integration, not this custome component. Changed this and now everything works. Thanks for support! Great component!

Great. :)

Can you check whether the service that turns a given network on and off works from your home assistant? It doesn't work for me.

backisen commented 6 months ago

2024-01-03 22:22:32.580 DEBUG (MainThread) [custom_components.unifi_wifi.services] Entity ID image.klubben319_guest_qr_code does not belong to platform unifi_wifi image.klubben319_guest_qr_code is the entity created by the unifi integration.

That is unexpected. I noticed the entity ID being different that what the component generates, however when I made similar changes on my test system, the entity continued belonging to the unifi_wifi platform. I'm not sure how that would have happened. Could you try one of the following:

  • delete the entity and restart
  • remove the component from your install (comment out the yaml), restart, remove any lingering image entities, restart, uncomment the yaml, and then restart one last time

I've solved this. I was using the image from the native Unifi integration, not this custome component. Changed this and now everything works. Thanks for support! Great component!

Great. :)

Can you check whether the service that turns a given network on and off works from your home assistant? It doesn't work for me.

Checked and it doesn't work for me either. Change password works like a charm now.