2018-01-02 11:54:08 +01:00
# node-red-contrib-mi-devices
2017-07-03 22:41:43 +02:00
This module contains the following nodes to provide easy integration of the Xiaomi devices into node-red.
2018-01-02 11:54:08 +01:00
This module is a fork of [Harald Rietman module, node-red-contrib-xiaomi-devices ](https://github.com/hrietman/node-red-contrib-xiaomi-devices )
2017-07-03 22:41:43 +02:00
The following devices are currently supported:
* Temperature/humidity sensor
2017-12-31 23:10:06 +01:00
* Aqara temperature/humidity/pressure sensor
2017-07-03 22:41:43 +02:00
* Magnet switch
2017-12-31 23:10:06 +01:00
* Aqara window/door sensor
2017-07-03 22:41:43 +02:00
* Button switch
2017-12-31 23:10:06 +01:00
* Aqara smart wireless switch
2017-07-03 22:41:43 +02:00
* Motion sensor
* Power plug (zigbee)
2017-07-11 22:58:15 +02:00
* Power plug (wifi)
2017-07-03 22:41:43 +02:00
## Preperation
2018-01-02 11:54:08 +01:00
To interact with the gateway, you need to enable the developer mode, aka LAN mode in the gateway (see below).
2017-07-03 22:41:43 +02:00
2018-01-02 11:54:08 +01:00
To control the Wifi-Plug, extensive use is made of the miio library created by [Andreas Holstenson ](https://github.com/aholstenson/miio ).
Make sure to check his page for compatible devices.
2017-07-03 22:41:43 +02:00
## Install
```
2018-01-02 11:54:08 +01:00
npm install node-red-contrib-mi-devices
2017-07-03 22:41:43 +02:00
```
## Usage
2017-07-05 08:49:36 +02:00
From the Xiaomi configurator screen add your different devices by selecting the type of device and a readable description. The readable discription is used on the different edit screen of the nodes to easily select the device you associate to the node.
2017-07-03 22:41:43 +02:00
2017-12-31 23:10:06 +01:00
Note that the Wifi power plug is not configured through the configurator as it is not connected to the gateway.
2017-07-11 22:58:15 +02:00
2017-07-07 07:53:40 +02:00
The Xiaomi configurator screen with ease of use to configure your different devices.
2018-01-03 13:05:01 +01:00

2017-07-07 07:53:40 +02:00
2017-07-05 08:49:36 +02:00
Tip: use the configurator from the side-panel (hamburger menu, configuration nodes) to manage your devices. Node-red doesn't update underlying edit screens if the configuration panel is opened / closed from the edit node screen. (If you do, you need to first close the edit node screen and reopen it by double-clicking the node you want to edit the properties for.)
2018-01-02 12:39:00 +01:00
### How to use different nodes
2017-07-05 08:49:36 +02:00
2018-01-03 15:36:23 +01:00
Here an example of how to use the different nodes (screenshot of [importable flows-overview.json ](flows-overview.json "Mi Devices overview" )):
2018-01-03 13:05:01 +01:00

2017-07-05 08:49:36 +02:00
2018-01-02 12:39:00 +01:00
### Sample flows
2018-01-03 15:36:23 +01:00
Here are different flow (screenshot of [importable flows-sample.json ](flows-sample.json "Different flows using Mi Devices" )):
2018-01-03 13:05:01 +01:00

2017-07-07 07:53:40 +02:00
2018-01-02 11:54:08 +01:00
## Enable LAN mode
### Gateway
1. Install MiHome App
2. Make sure you set your region to: Mainland China under settings -> Locale - required for the moment.
Mainland China and language can set on English.
3. Select your Gateway in Mi Home
4. Then the 3 dots at the top right of the screen
5. Then click on about
6. Tap under Tutorial menu (on the blank part) repeatedly
2018-01-02 12:39:00 +01:00
7. You should see now 3 extra options listed in Chinese until you did now enable the developer mode (like the first screenshot below, if not try all steps again!)
2018-01-02 11:54:08 +01:00
8. Choose the second new option
2018-01-02 12:39:00 +01:00
9. Then tap the first toggle switch to enable LAN functions. Note down the password (`A4D81977ED8A4177` in the second screenshot)
10. Make sure you hit the OK button (to the right of the cancel button) to save your changes
2018-01-02 11:54:08 +01:00
If you change here something, you lose your password!
2018-01-03 13:05:01 +01:00


2017-07-07 07:53:40 +02:00
2018-01-02 11:54:08 +01:00
## Sources
* [Harald Rietman node-red module ](https://github.com/hrietman/node-red-contrib-xiaomi-devices )
* [Domoticz Instructions ](https://www.domoticz.com/wiki/Xiaomi_Gateway_(Aqara ))
* [louisZl Gateway Local API ](https://github.com/louisZL/lumi-gateway-local-api )
* [Domoticz Gateway Code ](https://github.com/domoticz/domoticz/blob/development/hardware/XiaomiGateway.cpp )
* [Node-red UDP nodes ](https://github.com/node-red/node-red/blob/master/nodes/core/io/32-udp.js )
2018-01-03 15:36:23 +01:00
## Credits
* [Switch icons by Setyo Ari Wibowo ](https://thenounproject.com/seochan.art/ )
* ["All" icon by Fatahillah ](https://thenounproject.com/fatahillah/ )
* [Bulb icon by Mello ](https://thenounproject.com/stonuiiuntk/ )
* [Glasses icon by Agrahara ](https://thenounproject.com/agrahara4/ )
* [Volume icons by krishna ](https://thenounproject.com/krishanayuga/ )
* [List icon by Landan Lloyd ](https://thenounproject.com/landan/ )
* [Clicks icons by Adrien Coquet ](https://thenounproject.com/coquet_adrien/ )