home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
72.61k stars 30.37k forks source link

Unifi discovery polling wrong ip #69686

Closed prilly-dev closed 2 years ago

prilly-dev commented 2 years ago

The problem

It seems unifi discovery is polling the Gateway IP adress 172.16.0.1 when this address is a router that is NONE Unifi. My unifi network server is running on IP 172.16.0.205.

Unifi discovery has no buisness of polling the gateway adress, it will ofcourse not get any respons from my gateway.

What version of Home Assistant Core has the issue?

2022.04.01

What was the last working version of Home Assistant Core?

2022.03

What type of installation are you running?

Home Assistant Container

Integration causing the issue

Unifi

Link to integration documentation on our website

https://www.home-assistant.io/integrations/unifi/

Diagnostics information

No response

Example YAML snippet

No response

Anything in the logs that might be useful for us?

2022-04-08 17:05:08 ERROR (MainThread) [unifi_discovery] Failed to get system info for 172.16.0.1
Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/unifi_discovery/__init__.py", line 432, in _probe_services_and_system
    system = await system_response.json()
  File "/usr/local/lib/python3.9/site-packages/aiohttp/client_reqrep.py", line 1103, in json
    raise ContentTypeError(
aiohttp.client_exceptions.ContentTypeError: 0, message='Attempt to decode JSON with unexpected mimetype: text/html; charset=utf-8', url=URL('https://172.16.0.1/api/system')

Additional information

No response

probot-home-assistant[bot] commented 2 years ago

Hey there @kane610, mind taking a look at this issue as it has been labeled with an integration (unifi) you are listed as a code owner for? Thanks! (message by CodeOwnersMention)


unifi documentation unifi source (message by IssueLinks)

probot-home-assistant[bot] commented 2 years ago

unifiprotect documentation unifiprotect source (message by IssueLinks)

probot-home-assistant[bot] commented 2 years ago

Hey there @briis, @angellusmortis, @bdraco, mind taking a look at this issue as it has been labeled with an integration (unifiprotect) you are listed as a code owner for? Thanks! (message by CodeOwnersMention)

AngellusMortis commented 2 years ago

This may seem contradictory as unifi_discovery is for the UniFi Discovery protocol, which UniFi Network does not use. The discovery protocol is used by all of the other UniFi apps (Protect, Access, Talk, etc.).

So unifi_discovery is looking for a UniFi Protect install for the unifiprotect integration, not a UniFi Network install for the unifi integration. The most common case for that is that you are using a UniFiOS console that is capable of running both Protect and Network (i.e. a UDM Pro or UDM SE). In that case it would be your gateway.

bdraco commented 2 years ago

We should suppress that error since it's not going to respond with valid data for some versions

bdraco commented 2 years ago

I'll adjust the discovery library when I have some free time

prilly-dev commented 2 years ago

This is the problem; as i initialy wrote in the bug report i do not use any ubnt products as gateway, i do have a uck g2 running protect only. I run HA in a docker inside a vm from xcp-ng. What i see is that the HA server with the unifi protect adon is polling my gateway with unifi-discovery. My uck-g2 is not on the same subnet as the ha server and has nothing to do with any gateway

There is a discovery prosess running that is doing more then just talk to my protect instant and i would like to know why.

bdraco commented 2 years ago

Your gateway is sending out discovery packets and the discover listener is seeing them so it's polling it.

It's possible that your gateway is rewriting the source address and they are really coming from your g2 but there isn't anything we can do about that since we have to take the data as we get it

prilly-dev commented 2 years ago

Your gateway is sending out discovery packets and the discover listener is seeing them so it's polling it

That would be a problem, my gateway is a cisco asr 1001, it do not have any ubnt discovery, it might be the uck g2, as it is on a different subnet routed by the asr, it might be the asr is traversing it, then the respons from ha would be to poll the gateway, this is the only explanation

I will block this unifi discovery once and for all by a fw rule in the gateway and iptables on the HA host