Xiaomi MiHome Plugin

Download: intraHouse.plugin-xiaomi.zip  (18 KB)

License: MIT

Author: intraHouse

The Xiaomi MiHome Plugin is designed to work with wireless equipment Xiaomi Smart Home.

Tested on the following devices:

  1. gateway – Xiaomi GateWay 2
  2. motion – Xiaomi Smart Motion Sensor
  3. sensor_motion.aq2 – Xiaomi Smart Motion Sensor and Illumination
  4. weather.v1 – Xiaomi Weather
  5. sensor_ht – Xiaomi Temperature/Humidity
  6. sensor_magnet.aq2 – Xiaomi Door Sensor
  7. magnet – Xiaomi Door Sensor
  8. smoke – Xiaomi Smoke Detector
  9. natgas – Xiaomi Gas Detector
  10. plug – Xiaomi Smart Plug
  11. ctrl_86plug.aq1 – Aqara Smart Socket
  12. ctrl_ln1.aq1 – Aqara 1 Channel Wall Switch (LN)
  13. ctrl_neutral1 – Xiaomi Wired Single Wall Switch (N)
  14. ctrl_neutral2 – Xiaomi Wired Dual Wall Switch (N)
  15. ctrl_ln2.aq1 – Aqara Wall Switch Double (LN)
  16. switch – Xiaomi Wireless Switch
  17. 86sw2 – Xiaomi Wireless Dual Wall Switch
  18. cube – Xiaomi Cube
  19. sensor_wleak.aq1 – Aqara Water sensor

Plugin installation

The plugin installation procedure is shown here

Gateway Setup

Before setting up the plugin, you need configure the Xiaomi Gateway

To configure the Xiaomi Gateway, you need to install MiHome applications on your smartphone.

After installing the MiHome application, you need to switch the gateway to “developer mode”:

  1. In the Mi Home app, choose your gateway.
  2. Press the three dots in the upper right corner of the screen.
  3. Click the About item
  4. Several times (3-4) click on the caption at the bottom of the screen “Version: xxx” at the very bottom,
    until the popup message appears in Chinese. Click on it and then new hidden options appear: “communication protocol” and “hub info”
  5. Select item: Wireless communication protocol
  6. Enable feature: Wireless communication protocol.  Click OK
  7. Select Hub info
  8. Find token and carefully rewrite this key.

Plugin setup

Double click on the plugin line to open the plugin properties window.
On the Parameters tab, complete the following fields:

  1. Xiaomi Gateway IP Address
  2. Port (leave default 9898)
  3. Token – enter the token received when configuring the gateway.

Click the Save button.

Press the button to call the Additional menu and select “Launch plugin”:

Adding channels (devices)

All Xiaomi devices can be added by means of the intraHouse system without the MiHome application.

The procedure for adding devices is shown in the video:

Channel configure

Press the button to call the channel list and select “Channel List”:

In the channel list you will see all the devices that are registered in the Xiaomi gateway.
If the list is empty, check the plugin settings (ip address and token). Then restart the plugin.

To bind a plugin channel to a virtual device of the system:
– double click to open the channel properties window
– select a device from the list of available devices of the system.

To process the value coming from the channel, you can apply the formula:

For example, the temperature sensor receives the value 2130.
For conversion, divide by 100:

As a result, the value of 21.3 will come from this channel.

Note. If you change the formula, the converted value is not immediately reflected in the user interface. Only when receiving a new value from the channel (from the sensor).