darnfish / homebridge-unifi-wap-light

Control the light rings on your UniFi Wireless Access Point(s) with HomeKit
Apache License 2.0
2 stars 1 forks source link

Is the built-in access point supported by the Unifi Dream Router #4

Open daywalkeraut opened 2 months ago

daywalkeraut commented 2 months ago

Describe Your Problem: Would it work on the Unifi Dream Router access point?

Logs:

[UniFi WAP Lights] Initializing UnifiWAPLight platform...

Plugin Config:

{
            "name": "UniFi WAP Lights",
            "host": "192.168.1.1",
            "username": "XXXX",
            "password": "XXXX",
            "platform": "UnifiWAPLight" 
}

Screenshots:

Environment:

pizzalorddex commented 1 month ago

Hi there!

I am not the author of this homebridge plugin and I don't know much about the UniFi API to answer this 100%, but I did refactor the code completely in my own branch to make this plugin even work for me. So I think I can at least sort of answer.

This plugin communicates with the Unifi API from your UniFi controller and asks it for any devices which are marked as "UAP"s. So this plugin will work if the UniFi Dream Router reports as a UAP in the API. Unfortunately, I don't know if the Dream Machine does or not.

You could check by running some API calls to the UniFi controller.

Before doing that, it looks like your plugin settings are not quite right. For the host you also need to include the port number. For you it should look like 192.168.1.1:8443

So I would suggest adding the port number into the config and then check the logs to see if anything else happens and report back :)

daywalkeraut commented 1 month ago

Hello pizzalorddex

thank you very much trying to help me.

When i use the IP with the Port 8443 the homebrigde crash and not go run. See here the log.

AxiosError: Request failed with status code 404 at settle (/homebridge/node_modules/homebridge-unifi-wap-light/node_modules/axios/lib/core/settle.js:19:12) at IncomingMessage.handleStreamEnd (/homebridge/node_modules/homebridge-unifi-wap-light/node_modules/axios/lib/adapters/http.js:589:11) at IncomingMessage.emit (node:events:530:35) at endReadableNT (node:internal/streams/readable:1696:12) at processTicksAndRejections (node:internal/process/task_queues:82:21) at Axios.request (/homebridge/node_modules/homebridge-unifi-wap-light/node_modules/axios/lib/core/Axios.js:45:41) at processTicksAndRejections (node:internal/process/task_queues:95:5) at UnifiWAPLight.auth (/homebridge/node_modules/homebridge-unifi-wap-light/src/platform.ts:73:23) at UnifiWAPLight.discoverDevices (/homebridge/node_modules/homebridge-unifi-wap-light/src/platform.ts:105:3)

Sorry I don´t know so good about Coding, Unifi, Network and so on.

How can I run some API calls to the UniFi controller?

Just for information I bought last week an UAP-AC-IW that I can control from HomeBridge (HomeKit) but the in Build AC from the Dream Router I not see in HB (HK)

best regards and thanks

pizzalorddex commented 1 month ago

Thanks for the reply!

So with the UAP-AC-IW this plugin was working to control the light? I think this would be interesting to know.

I believe the 404 error means the plugin wasn’t able to find the UniFi Controller at this address. It crashes because the plugin’s code doesn’t handle this nicely.

At least according to the code and documentation the port number needs to be included with the host address. If the UAP-AC-IW worked for you before then that means the settings you used before should be ok. Just make sure the host address is the one where the UniFi Controller is running (either directly on the Dream Machine or from a raspberry pi/somewhere else).

To see if the API is reachable at all you can try a command from a Linux machine, such as a raspberry pi.

Try either this: curl -k -X POST https://<UNIFIHOST>:8443/api/auth/login -H "Content-Type: application/json" -d '{"username":"<USERNAME>","password":"<PASSWORD>"}'

Or this: curl -k -X POST https://<UNIFIHOST>:8443/api/login -H "Content-Type: application/json" -d '{"username":"<USERNAME>","password":"<PASSWORD>"}'

Make sure to replace <UNIFIHOST>, <USERNAME>, and <PASSWORD> with your actual information.

If the API is reachable you will get a response back that looks like: {"meta":{"rc":"ok"},"data":[]}

If the command fails (it could fail for many reasons such as incorrect address, incorrect password, or incorrect API URL for example) it will look something like this: {"meta":{"rc":"error","msg":"<THEERRORTHATHAPPENED>"},"data":[]}

Good luck! Hopefully we can figure out where the problem is.

daywalkeraut commented 1 month ago

Hi pizzalorddex again.

Thank you so much for your interest and helping.

Sorry my English is not so good maybe sometimes you will understand me wrong.

Yes the UAP-AC-IW is working with this Plugin and I can control the Light in HomeKit. I used the Plugin Config what I post without the Port 8443 { "name": "UniFi WAP Lights", "host": "192.168.1.1", "username": "XXXX", "password": "XXXX", "platform": "UnifiWAPLight" }

I only get an answer when I use this: curl -k -X POST https:///api/auth/login -H "Content-Type: application/json" -d '{"username":"","password":""}'

without the port 8443, with port 8443 I get nothing back.

Can I send you the response in private because I don´t know if there are any sensitive information that not should be public.

i don´t get any message with meta, rc, ...

Thank you so much for your Time

pizzalorddex commented 1 month ago

No worries I am glad to help!

Thank you for the further information. That helps me understand what is going on. Also, I want to say sorry as I also don't fully understand everything about UniFi and the API.

I am glad you were able to try some things out! If you need more explanation on anything please feel free to ask :)

These are my thoughts:

What this means for you: Unfortunately, this plugin will not work as-is to control the UDP because it is not an "AP". The author would have to modify the code to be able to support your device. However, they haven't been online for awhile so that will probably not happen any time soon.

I would be willing to try and modify the code in my own repository to try and support the UDP for you. As I don't have a UDP of my own I would need you to test the code to see if it works. I am not sure if it is possible to make it work, but if you are willing to test it I would try.

daywalkeraut commented 1 month ago

Oh man you a Hero.

Yes I think about the same Problem because the AP is built in the Dream Router and is so different. Only wireless AP I think not because the UAP-AC-IW is on cable by me.

When you have time and desire would be nice if you can try to change the Code.

I would tip you some for your help and time

pizzalorddex commented 1 month ago

It is no problem! This is sort of a hobby for me and it would be cool to support more devices. I think I have everything I need to get started. I just have one more question: In the UniFi app can you turn the LED of the Dream Machine on and off like with the AP?

daywalkeraut commented 1 month ago

You are Amazing.

Yes under OS-Settings > Console Settings > I can set hook for LED on or not and then apply.

How can I instal you already existing repository in HomeBrigde? pizzalorddex/homebridge-unifi-wap-light

best greetings my Hero

pizzalorddex commented 1 month ago

ok, perfect. I will work on the code later today. I already changed a lot from this plugin so I hope it still works for you.

I haven't made my repo publicly available in homebridge yet because I thought the creator would use my changes. I will also make my code installable later as well.

I will message again when everything is ready for you to test. It should only take 1 day at most.

pizzalorddex commented 1 month ago

Hey again @daywalkeraut!

I finished and published my code. You can search for it in homebridge under Homebridge Unifi Ap Light and install it that way.

I must warn you that my code to connect to your UDM via the API is untested so far, so it may not work. Also, I hope the internet was right with how to find your device via the API.

If you have any problems or feedback please post on my repo

To the author, @darnfish: sorry to sort of take over the repo. As you haven't been around for a few months I really wanted to make the code work for me and share my work for others to use. Please still feel free to integrate my pull request into your repo.

daywalkeraut commented 1 month ago

Hello again.

Thank you so much for published it

Sorry the post before I make a mistake by the config..... I use "platform": "UnifiWAPLight" but it is without the W

Now the Plugin in run and HomeBrigde too.

But I get this Message with Port 8443 [UniFi AP Lights] Both authentication methods failed: AxiosError: Request failed with status code 404 [UniFi AP Lights] Device discovery failed: Request failed with status code 404

and this Message without Port [UniFi AP Lights] Device discovery failed: Request failed with status code 404

And sorry that I Answer her again but I can not open a Pull request or Issues at your repo. I am to stupid for it :-)

THANKS A LOT

pizzalorddex commented 1 month ago

Sorry @daywalkeraut i forgot to enable issues, but you can open an issue now here. I don’t want to do troubleshooting here because that wouldn’t be good manners. I will look at the problem soon.