Kane610 / aiounifi

Asynchronous library to communicate with Unifi Controller
MIT License
57 stars 49 forks source link

Handle login non JSON response #640

Closed mkmer closed 2 months ago

mkmer commented 2 months ago

This handles the non JSON response and causes retries until the host is "alive" There may be a better way to handle things. I selected .debug for the log as it "spams" the log file with errors during a "normal" startup

mkmer commented 2 months ago

It looks like the tests are expecting HTML for this part: https://github.com/Kane610/aiounifi/blob/5452ff3eee2279d1ed988abb396e8493802da120/tests/test_controller.py#L41

Not sure if it's a "bad" test, real world testing with my controller makes it through the startup and eventually connects.

I read that wrong :) Sending html not receiving :)

mkmer commented 2 months ago

Sorry about all of the "noise" - this should be the "final answer" - original tests still pass, new test covers the new code AND it actually fixes the startup problem :)

Kane610 commented 2 months ago

Sorry about all of the "noise" - this should be the "final answer" - original tests still pass, new test covers the new code AND it actually fixes the startup problem :)

Awesome! Don't worry about it. I looked through it but will review tonight

Kane610 commented 2 months ago

Thanks

Kane610 commented 2 months ago

Have you validated that this works in reality?

mkmer commented 2 months ago

Yes, I tested with my configuration. As long as the host is returning "starting" with text/html the old code failed, this code triggers HA to retry the integration until it returns the "correct" login info.

Kane610 commented 2 months ago

Great! Will put up a new release tonight