Xiaomi Gateway broke after I moved gateway to a VLAN

Same thing happened to me a couple of months ago. Actually the switch to a new wifi seemed to have switched off the port required by the integration. I checked the XiaomiHub via a port scan and it was closed. Apparently there is a way to open it again by opening the gateway and soldering around… but that was too much trouble for me. I took the chance to migrate everything to a Zigbee Stick i have now running on the NUC. Not sure if the same thing happend to you, but maybe try a portscan on the xiaomi hub.

Here a github issue for reference: https://github.com/home-assistant/core/issues/16407#issuecomment-450794763

Hey Marcus,

Thanks for the heads up. I did actually have this issue a year or so ago when I lost communication with the gateway after deploying Adguard. I hard reset the unit as part of my debugging and this sadly closed the UDP port. I managed to pull the unit apart and follow the guides to flash the unit and re-open the port and I’ve confirmed today that this does not appear to be my issue.

Starting Nmap 7.40 ( https://nmap.org ) at 2020-04-02 16:07 NZDT
Nmap scan report for lumi-gateway-v3_miio57839038 (10.0.40.xx)
Host is up (-0.079s latency).
PORT     STATE         SERVICE
4321/udp open|filtered rwhois
9898/udp open          monkeycom
MAC Address: 34:CE:00

That nmap scan was however done from the same VLAN ID and subnet so I might have to try another scan from the Home Assistant LAN subnet.

Just done a nmap from the LAN and host reports up and port reports as open.

Found the thread on the unifi forum again:

The gist of it: The Xiaomi Gateway using a mix of Multicast and Unicast thats why a igmp proxy seems not to work. Using an aqara hub seems to work though

Thanks. Seems the best answer is to depreciate the Xiaomi Gateway which is a shame as I use the speaker and RGB light feature a lot. I might move the Xiaomi Gateway back to the LAN until I can replace it with another light/sound solution. I have alreadymigrated 95% of my Zigbee devices to DeCONZ/Conbee but I have 6 x smokes still on Xiaomi as the integration is a lot better.

One last thing you could try… not sure anymore if i tried it in the past with the gateway or already switched all to the zigbee2mqtt. Basically i added my HomeAssistant to all of my VLans.

Wow, sounds like I might have bitten off more that I can chew!! My networking understanding is OK but not in-depth so playing around with all this stuff makes me nervous. I’ve just switched the Xiaomi Gateway back to the LAN and for now, everything is working again until I start adding firewall rules!

I appreciate the last post as that looks like it might be the golden egg to get everything working. I think I’ll only attempt that though when I have Home Assistant back on actual hardware as having it sit atop Proxmox just adds another layer of complexity, point of failure and another device to manage/update.

On mine, I’ve added adapters to HA to allow it to access both the internal LAN and the IoT LAN. This allows HA to talk to IoT gear without forwarders (e.g. IGMP). An option to consider if you run HA in a venv.

Thanks for the tip. Are they actual physical adapters?

No just another VLAN, you would need a smart switch.

I have a full UniFi setup. Could you explain your process?

I have smart switches connecting everything up, IoT devices are in IoT VLAN, and the Raspberry Pi running HA I’ve created a 802.1q trunk on the physical NIC and created two VLANs on it; one untagged (native) and one in the IoT VLAN.

I also have two access points trunked to the smart switch, and IoT wireless devices sit on the IoT VLAN (I have IoT SSIDs as well as other SSIDs for normal computers). The two VLANs are connected back to my router which only allows new connections from regular network -> IoT not the other way around. IoT devices that need internet access have it and I’ve blocked the rest.

With the two NICs on the HA Pi, HA can access both simultaneously, but I’ve also put iptables on it and only allowed specific ports required by IoT devices on the IoT adapter.

Thanks @callifo, but that all sounds above my pay grade. I’ve got IoT in one VLAN and Media in another but have left the Xiaomi gateway in the LAN for now. I think I’ll pay someone to remote in at some point and make a few tweaks as I fear that if I start playing with it, I’ll make things worse.

Hello,

someone solved the problem about to move xiaomi gateway into IoT network with VLAN in unifi without soldering the xiaomi gateway only changin configuration in Unifi?

thanks

I have managed to discover Xiaomi Aquara Gateway in Home Assistant using auto-discovery, but entities are not being updated.

I have multiple VLANs, and I used the trunk to connect RPI with the home assistant and configured sub adapters on RPI.

When I sniff traffic in home assistant container with TCP dump, I can see that gateway is sending multicast updates, but aqaura intergration does not update entities accordingly.

root@home-assistant:/home/pluskal# tcpdump -i eth0.11 'port 9898' -vvv -X
tcpdump: listening on eth0.11, link-type EN10MB (Ethernet), capture size 262144 bytes
21:06:15.785318 IP (tos 0x0, ttl 255, id 3909, offset 0, flags [none], proto UDP (17), length 138)
    lumi-gateway-v3_miio259435924.4321 > 224.0.0.50.9898: [udp sum ok] UDP, length 110
        0x0000:  4500 008a 0f45 0000 ff11 5817 0a0b 69c9  E....E....X...i.
        0x0010:  e000 0032 10e1 26aa 0076 5373 7b22 636d  ...2..&..vSs{"cm
        0x0020:  6422 3a22 7265 706f 7274 222c 226d 6f64  d":"report","mod
        0x0030:  656c 223a 2273 656e 736f 725f 6d6f 7469  el":"sensor_moti
        0x0040:  6f6e 2e61 7132 222c 2273 6964 223a 2231  on.aq2","sid":"1
        0x0050:  3538 6430 3030 3538 3237 3638 3322 2c22  58d0005827683","
        0x0060:  7368 6f72 745f 6964 223a 3138 3438 2c22  short_id":1848,"
        0x0070:  6461 7461 223a 227b 5c22 6c75 785c 223a  data":"{\"lux\":
        0x0080:  5c22 3131 335c 227d 227d                 \"113\"}"}
21:06:15.787792 IP (tos 0x0, ttl 255, id 3911, offset 0, flags [none], proto UDP (17), length 144)
    lumi-gateway-v3_miio259435924.4321 > 224.0.0.50.9898: [udp sum ok] UDP, length 116
        0x0000:  4500 0090 0f47 0000 ff11 580f 0a0b 69c9  E....G....X...i.
        0x0010:  e000 0032 10e1 26aa 007c d09a 7b22 636d  ...2..&..|..{"cm
        0x0020:  6422 3a22 7265 706f 7274 222c 226d 6f64  d":"report","mod
        0x0030:  656c 223a 2273 656e 736f 725f 6d6f 7469  el":"sensor_moti
        0x0040:  6f6e 2e61 7132 222c 2273 6964 223a 2231  on.aq2","sid":"1
        0x0050:  3538 6430 3030 3538 3237 3638 3322 2c22  58d0005827683","
        0x0060:  7368 6f72 745f 6964 223a 3138 3438 2c22  short_id":1848,"
        0x0070:  6461 7461 223a 227b 5c22 7374 6174 7573  data":"{\"status
        0x0080:  5c22 3a5c 226d 6f74 696f 6e5c 227d 227d  \":\"motion\"}"}
21:06:20.449830 IP (tos 0x0, ttl 255, id 3918, offset 0, flags [none], proto UDP (17), length 164)
    lumi-gateway-v3_miio259435924.4321 > 224.0.0.50.9898: [udp sum ok] UDP, length 136
        0x0000:  4500 00a4 0f4e 0000 ff11 57f4 0a0b 69c9  E....N....W...i.
        0x0010:  e000 0032 10e1 26aa 0090 ec24 7b22 636d  ...2..&....${"cm
        0x0020:  6422 3a22 6865 6172 7462 6561 7422 2c22  d":"heartbeat","
        0x0030:  6d6f 6465 6c22 3a22 6761 7465 7761 7922  model":"gateway"
        0x0040:  2c22 7369 6422 3a22 3034 6366 3863 6636  ,"sid":"04cf8cf6
        0x0050:  6164 3335 222c 2273 686f 7274 5f69 6422  ad35","short_id"
        0x0060:  3a22 3022 2c22 746f 6b65 6e22 3a22 7646  :"0","token":"vF
        0x0070:  694b 7239 364c 5479 7756 5747 6366 222c  iKr96LTywVWGcf",
        0x0080:  2264 6174 6122 3a22 7b5c 2269 705c 223a  "data":"{\"ip\":
        0x0090:  5c22 3130 2e31 312e 3130 352e 3230 315c  \"10.11.105.201\
        0x00a0:  227d 227d                                "}"}

It is simillar to https://github.com/home-assistant/core/issues/38286 but I have triple check the network configuration that seems fine.


EDIT:

I have managed to make it to work. The integration asks for a interface and defaults to any. No interface name worked for me, but when I passed an IP address assigned to virtual interface belonging to the IoT VLAN, it magically started to work.

2 Likes

Hi. Could you please elaborate a little bit more? You saying that in you HA instance you have two network interfaces, one for your main LAN and another different one for your IoT VLAN? I have the same problem as all ppl here, but I’m trying to understand what you did to have the interface talking to the IoT VLAN directly. Thanks

Hi, just use the IP address of the interface facing the IoT VLAN in the configuration of Xiaomi integration instead of the any string that is the default option.

Thanks. I understand correctly you are saying your hass instance is connected directly to the IoT vlan right? In my case hassio is connected in main vlan and hass access the devices on IoT vlan via routing, so I don’t have any direct interface to IoT on hass… I guess I’m stuck there

Yes! You need to be L2 connected, because as best to my knowledge, Xiaomi uses multicast or broadcast, so routing will not work.

I used trunk on the switch to pass all VLANs I needed to the HASS, and on the HASS instance, I modified network settings and added multiple virtual interfaces according to the VLAN tags I needed.

Works like a charm. Settings are persistent across HASS updates.

Thanks for the tips. I’m keen to give this another try and wondering if you could elaborate a bit more on how to create the virtual interfaces?