Skip to content

Commit

Permalink
Add troubleshooting guide for cross-subnet communications (#459)
Browse files Browse the repository at this point in the history
This troubleshooting guide is the result of the outcome of issue #422.

Please have a look at the issue for more insights:
#422
  • Loading branch information
domibarton authored and rytilahti committed Jan 20, 2019
1 parent 6b2ce47 commit 7eee203
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
1 change: 1 addition & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,4 @@ who have helped to extend this to cover not only the vacuum cleaner.
ceil
eyecare
API <miio>
troubleshooting
37 changes: 37 additions & 0 deletions docs/troubleshooting.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
Troubleshooting
===============

Discover devices across subnets
-------------------------------

Discovering across different subnets may fail for some devices with the following exception:

.. code-block:: text
miio.exceptions.DeviceException: Unable to discover the device x.x.x.x
This behaviour has been experienced on the following device types:

- Xiaomi Zhimi Humidifier (aka ``zhimi.humidifier.v1``)
- Xiaomi Smartmi Evaporative Humidifier 2 (aka ``zhimi.humidifier.ca1``)
- Xiaomi IR Remote (aka ``chuangmi_ir``)

It's currently unclear if this is a bug or a security feature of the Xiaomi device.

.. note::

The root cause is the source address in the UDP packet. The device won't react/respond to the miIO request, in case the source address of the UDP packet doesn't belong to the subnet of the device itself. This behaviour was experienced and described in `this github issue <https://github.com/rytilahti/python-miio/issues/422>`_.

Fortunately there are some workarounds to get the communication working.

The most obvious one would be placing the miIO client & MI device in the same subnet. You can also dual-home your client and put it in multiple subnets. This can be achieved either physically (e.g. multiple ethernet cables) or virtually (multiple VLAN's).

.. hint::

You might have had your reasons for multiple subnets and they're probably security-related. If so, remember to configure a local firewall on your client so that incoming connections from untrusted subnets are restricted.

If you're in control of the router in between, then you have one more chance to get the communication up & running. You can configure IP masquearding on the outgoing routing interface for the subnet where the MI device resides. IP masquerading (NAT) basically changes the source address in the UDP packet to the IP address of the outbound routing interface.

.. note::

Read more about `Network address translation on Wikipedia <https://en.wikipedia.org/wiki/Network_address_translation>`_.

0 comments on commit 7eee203

Please sign in to comment.