homebridge-xiaomi-gateway
v1.2.3
Published
XiaomiGateway plugins for HomeBridge(https://github.com/nfarina/homebridge).
Downloads
104
Readme
!!!WORK IN PROGRESS DO NOT USE IT YET TESTCOPY!!!
homebridge-xiaomi-gateway
New built-in/user-uploaded melodies playing functionality available
npm install -g homebridge-xiaomi-gateway
or
git clone https://github.com/theo-69/homebridge-xiaomi-gateway.git
cd homebridge-xiaomi-gateway
npm link
homebridge plugin for Aqara Xiaomi Gateway plugin.
This repository contains the Aqara plugin for homebridge. Aqara Xiaomi Gateway is a ZigBee gateway with a lot of sensors.
Supported Devices
- Gateway
- ContactSensor
- MotionSensor
- Button
- TemperatureAndHumiditySensor
- SingleSwitch
- DuplexSwitch
- SingleSwitchLN
- DuplexSwitchLN
- SingleButton86
- DuplexButton86
- PlugBase
- PlugBase86
- MagicSquare
- SmokeDetector
- NatgasDetector
- ElectricCurtain
- ContactSensor2
- MotionSensor2
- Button2
- TemperatureAndHumiditySensor2
- WaterDetector
Pre-Requirements
- Make sure you have V2 of the gateway. V1 has limited space so can't support this feature.
- Update gateway firmware to 1.4.1_150.0143 or later.
Installation
- Install HomeBridge, please follow it's README.
If you are using Raspberry Pi, please read Running-HomeBridge-on-a-Raspberry-Pi. - Make sure you can see HomeBridge in your iOS devices, if not, please go back to step 1.
- Download homebridge-mi-aqara to your local folder.
Configuration
- Open Aqara gateway's settings, enable local network protocol.
Please follow the steps in this thread: http://bbs.xiaomi.cn/t-13198850. It's in Chinese so you might need a translator to read it. - To control the devices, put gateway's MAC address (lower case without colon) and password (keep original and case sensitive) to ~/.homebridge/config.json.
{
"platforms": [{
"platform": "XiaomiGatewayPlatform",
"gateways": {
"6409802da3b3": "02i44k56zrgg578b"
}
}]
}
If you have more than one gateways, fill them in right order, like below.
{
"platforms": [{
"platform": "XiaomiGatewayPlatform",
"gateways": {
"6409802da3b3": "02i44k56zrgg578b",
"f0b4299a5b2b": "2F92E7DA90C66B86",
"f0b4299a77dd": "syu3oasva3uqd5qd"
}
}]
}
If you want to specify the default name of the device, add a mapping table to your config.json like this.
For more information about default name, Please refer to file sampleConfig.json
.
{
"platforms": [{
"platform": "XiaomiGatewayPlatform",
"gateways": {
"6409802da3b3": "02i44k56zrgg578b",
"f0b4299a5b2b": "2F92E7DA90C66B86",
"f0b4299a77dd": "syu3oasva3uqd5qd"
},
"melodies":
[
{
"id": 10001,
"volume": 5,
"name": "Button to play melody 1"
},
{
"id":10002,
"volume":3,
"name":"Button to play melody 2",
"gateway":"f0b223a3484"
}
],
"defaultValue": {
"158d0001000001": {
"ContactSensor_ContactSensor": {
"name": "entrance door"
}
},
"158d0001000002": {
"MotionSensor2_MotionSensor": {
"name": "study room motion sensor"
},
"MotionSensor2_LightSensor": {
"name": "study room light sensor"
}
},
"158d0001000004": {
"TemperatureAndHumiditySensor_TemperatureSensor": {
"name": "living room temperature"
},
"TemperatureAndHumiditySensor_HumiditySensor": {
"name": "living room humidity"
}
}
}
}]
}
If you like to use Light Bulb type for Light Switch to make grandma Siri happy, like snOOrz, you can set the following in the config.
Currently only supported: SingleSwitch, DuplexSwitch, SingleSwitchLN, DuplexSwitchLN.
If you changed serviceType config, Please clear register accessories.
New melodies section allows to create virtual buttons for playing system/user-recorded melodies: Volume can be specified by 'volume' parameter, and 'id' is identifier of the internal or user-uploaded melody. 'id' can be: 8,1013,20,21,22,23,24,25,26,27,28,29 - for gateway's default melodies 10000 - stops any playing melodies 10001 and above - user-uploaded melodies Optionally, if you have several gateways you can specify 'gateway' parameter for each melody.
{
"platforms": [{
"platform": "XiaomiGatewayPlatform",
"gateways": {
"6409802da3b3": "02i44k56zrgg578b",
"f0b4299a5b2b": "2F92E7DA90C66B86",
"f0b4299a77dd": "syu3oasva3uqd5qd"
},
"defaultValue": {
"158d0001000007": {
"SingleSwitch_Switch": {
"name": "living room light",
"serviceType": "Lightbulb"
}
},
"158d0001000008": {
"Global": {
"serviceType": "Lightbulb"
},
"DuplexSwitch_Switch_Left": {
"name": "master bedroom room light"
},
"DuplexSwitch_Switch_Right": {
"name": "study room light"
}
},
"158d10010000001": {
"DuplexSwitch_Switch_Left": {
"name": "master bedroom room light",
"serviceType": "Lightbulb"
},
"DuplexSwitch_Switch_Right": {
"name": "study room light"
}
}
}
}]
}
If you want to disable accessories, you can add disable attribute to config.
{
"platforms": [{
"platform": "XiaomiGatewayPlatform",
"gateways": {
"6409802da3b3": "02i44k56zrgg578b",
"f0b4299a5b2b": "2F92E7DA90C66B86",
"f0b4299a77dd": "syu3oasva3uqd5qd"
},
"defaultValue": {
"158d0001000007": {
"SingleSwitch_Switch": {
"name": "living room light",
"serviceType": "Lightbulb"
}
},
"158d0001000008": {
"DuplexSwitch_Switch_Left": {
"name": "master bedroom room light",
"serviceType": "Lightbulb",
"disable": false
},
"DuplexSwitch_Switch_Right": {
"name": "study room light",
"serviceType": "Lightbulb",
"disable": true
}
},
"158d0001000004": {
"TemperatureAndHumiditySensor_TemperatureSensor": {
"name": "living room temperature"
},
"TemperatureAndHumiditySensor_HumiditySensor": {
"name": "living room humidity",
"disable": true
}
},
"158d0001000012": {
"Global": {
"disable": true
}
},
"158d0001000015": {
"Global": {
"disable": true
},
"MagicSquare_StatelessProgrammableSwitch_Flip90": {
"name": "study room magic square flip90",
"disable": false
}
}
}
}]
}
If you want to accessory value exact, you can set syncValue is true.
{
"platforms": [{
"platform": "XiaomiGatewayPlatform",
"gateways": {
"6409802da3b3": "02i44k56zrgg578b",
"f0b4299a5b2b": "2F92E7DA90C66B86",
"f0b4299a77dd": "syu3oasva3uqd5qd"
},
"defaultValue": {
"158d0001000007": {
"SingleSwitch_Switch": {
"name": "living room light",
"serviceType": "Lightbulb",
"syncValue": true
}
}
}
}]
}
when syncValue is true, accessory will synchronization value when homebridge call the get function. At the same time, it's going to waste more time.
when syncValue is false, accessory will use the device last reported value. It's going to respond quickly.
If you don't like "No Response", you can set disableNoResponse is true.
When the device is no pesponse and disableNoResponse is true, the accessory value will auto jump back to before the control.
{
"platforms": [{
"platform": "XiaomiGatewayPlatform",
"gateways": {
"6409802da3b3": "02i44k56zrgg578b",
"f0b4299a5b2b": "2F92E7DA90C66B86",
"f0b4299a77dd": "syu3oasva3uqd5qd"
},
"defaultValue": {
"Global": {
"disableNoResponse": true
}
"158d0001000007": {
"SingleSwitch_Switch": {
"name": "living room light",
"serviceType": "Lightbulb",
"syncValue": true
}
}
}
}]
}
Some explanation
Button/Button2 StatelessProgrammableSwitch support SinglePress, DoublePress, LongPress.
SingleButton86/DuplexButton86(Left, Right, Both) StatelessProgrammableSwitch only support SinglePress.
MagicSquare(Flip90, Flip180, Move, TapTwice, ShakeAir, Rotate) StatelessProgrammableSwitch only support SinglePress.
Run it
homebridge -D
Clear register accessories
cd ~/.homebridge/accessories/
mv cachedAccessories cachedAccessories_`date '+%Y%m%d_%H%M%S'`.bak
echo [] > cachedAccessories
Version Logs
New built-in/user-uploaded melodies playing functionality available*