Unifi Network: Better error message in handling of wrong port

Unifi Cloud Keys (and perhaps other controllers?) listen on both port 443 and port 8443 by default. Port 443 is used to manage the Cloud Key itself, while 8443 is where the Unifi Controller is hosted.

The problem is that if you forget to change the port when adding the integration, you’ll get an “Invalid Authentication” error message. This is somewhat correct, as in the logs we can see:

2023-04-09 18:04:54.323 WARNING (MainThread) [homeassistant.components.unifi] Connected to UniFi Network at unifi-cloudkey.local but login required: api.err.LoginRequired

However, it can easily lead users to troubleshoot the wrong thing, thinking it’s a bad password or somehow a 2FA issue.

I think large number of Unifi users are likely using their hardware for the controller, and even if they aren’t may have a different service running on port 443. It would be good if the integration could more specifically detect that it’s not actually connecting to a Unifi controller, and throw an error message like <host>:<port> is not a Unifi Controller application. Double check the host name, and make sure the port number shouldn't be 8443.