Galorhallen / govee-local-api

Apache License 2.0
12 stars 11 forks source link

Support Discovery Interface #65

Open dspeers opened 1 month ago

dspeers commented 1 month ago

When HA has more than 1 network port available it provides the option to change which interface should be used for discovery.

Settings -> System -> Network -> Network Adapter

This integration should use the specified adapter. Currently it is using the first one which in my case is the wrong one. In the below example, eth0 is the admin network for the UI and net1 is the IoT network where the devices are. I ran reload to initiate discovery during each run of tcpdump.

4: eth0@if774: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1480 qdisc noqueue state UP group default qlen 1000
    link/ether 9e:e4:3c:30:88:b8 brd ff:ff:ff:ff:ff:ff link-netnsid 0
    inet 192.168.53.55/32 scope global eth0
       valid_lft forever preferred_lft forever

5: net1@if2: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default
    link/ether 3a:af:6e:74:6c:b5 brd ff:ff:ff:ff:ff:ff link-netnsid 0
    inet 192.168.1.69/24 brd 192.168.1.255 scope global net1
       valid_lft forever preferred_lft forever

home-assistant-6cfcdd88c5-fc96l:/# tcpdump -i net1 port 4001
tcpdump: verbose output suppressed, use -v[v]... for full protocol decode
listening on net1, link-type EN10MB (Ethernet), snapshot length 262144 bytes
^C
0 packets captured
0 packets received by filter
0 packets dropped by kernel
home-assistant-6cfcdd88c5-fc96l:/# tcpdump -i eth0 port 4001
tcpdump: verbose output suppressed, use -v[v]... for full protocol decode
listening on eth0, link-type EN10MB (Ethernet), snapshot length 262144 bytes
20:51:29.912248 IP home-assistant-6cfcdd88c5-fc96l.4002 > 239.255.255.250.4001: UDP, length 57
20:51:40.274578 IP home-assistant-6cfcdd88c5-fc96l.4002 > 239.255.255.250.4001: UDP, length 57
^C
2 packets captured
2 packets received by filter
0 packets dropped by kernel
home-assistant-6cfcdd88c5-fc96l:/#
dspeers commented 1 month ago

There is a PR against the main ha/core repo that fixes this issue. I have tested this on my system and it works great.