Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add troubleshooting guide for cross-subnet communications #459

Merged
merged 1 commit into from
Jan 20, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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>`_.