Open ghost opened 4 years ago
It will only respond to requests on the same subnet. You need to set up a 1:1 NAT so that the device running your code can have a local address on the same subnet as the purifier. This worked fine for me.
AFAIK it should work if you configure a UDP proxy on the same network as the target device. An alternate way would be like @Steve-Wax said, to use NAT to translate the packets so the target device sees the gateway as the source. I wouldn't use 1:1 NAT for this as you only need to translate traffic destined to UDP 54321, and this won't work if you have more than one device to connect to on that network. Rather, it would be best to configure a source NAT rule for all UDP packets destined to 54321 on that network to get translated to the interface address of the router/gateway. Tested this in a setup of mine and it worked.
Thanks @ekrekeler that is a much more limited rule. The way I implemented the 1:1 NAT is by creating an IP for my raspberry pi that sends commands to the Mi Devices on the sub-net with the devices. I also limited traffic to only the Mi devices by using an alias that included all the devices. That way I could limit any comms from the subnet to the pi. I'm going to change my setup to your suggestion.
I have a zhimi.airpurifier.v6 which works nicely. However, I had the briliant idea to segment out all my IOT device onto a separate iot-only network. Turns out, the purifier only talks locally on the same network segment, which is a bummer since it does a great job of reporting the temperature to my home assistant setup. Any idea if a udp proxy will do the job, or is there something magical in the packets?