andreypopov / node-red-contrib-miio-roborock

Xioami Roborock node-red nodes
Apache License 2.0
32 stars 12 forks source link

Handshake timeout - different VLANs #47

Closed Drahos-X closed 2 years ago

Drahos-X commented 2 years ago

I am getting "Miio Roborock Error: Could not connect to device, handshake timeout".

Node-red and Roborock Q7 are on a different VLANs - this is perhaps the reason.

Node-red "Get Token" button works fine and returns the correct token (also verified by other methods). IP address is correct and reachable from Raspberry Pi running Node-red.

Can you help? What could I try to make it work?

Drahos-X commented 2 years ago

The issue is solved by adding this to the uck-config.gateway on the UniFi Controller (UCK):

"nat": {
    "rule": {
        "5000": {
            "description": "MASQ requests to Roborock [IP_ADDRESS]",
            "destination": {
                "address": "IP_ADDRESS"
            },
            "outbound-interface": "eth0.10",
            "protocol": "tcp_udp",
            "type": "masquerade"
        }
    }
}

_Replace IPADDRESS with Roborock IP address; replace eth0.10 with your VLAN with Roborock.

The root cause is the source address in the UDP packet. The device won’t respond to the request, in case the source address of the UDP packet doesn’t belong to the subnet of the device itself.

Useful info: https://python-miio.readthedocs.io/en/latest/troubleshooting.html https://help.ui.com/hc/en-us/articles/204976494-EdgeRouter-Source-NAT-and-Masquerade https://help.ui.com/hc/en-us/articles/215458888-UniFi-USG-Advanced-Configuration-Using-config-gateway-json https://jsonlint.com/

Do not forget to update permisions for the config file (if creating a new one): ssh root@UCK cd /srv/unifi/data/sites/default/ chown unifi:unifi config.gateway.json chmod 640 config.gateway.json