homebridge-mi-aqara-new

XiaoMi Aqara plugins for HomeBridge(https://github.com/nfarina/homebridge).


Keywords
homebridge-plugin
License
ISC
Install
npm install homebridge-mi-aqara-new@1.0.9

Documentation

homebridge-mi-aqara-new

New built-in/user-uploaded melodies playing functionality available

Installation npm version

npm install -g homebridge-mi-aqara-new

or

git clone https://github.com/theo-69/homebridge-mi-aqara-new.git
cd homebridge-mi-aqara-new
npm link

homebridge plugin for XiaoMi Aqara plugin.

This repository contains the Aqara plugin for homebridge.
Aqara is a ZigBee gateway with a few sensors.

Supported Devices

1.Gateway(网关)
2.ContactSensor(门磁感应)
3.MotionSensor(人体感应)
4.Button(按钮)
5.TemperatureAndHumiditySensor(温度湿度传感器)
6.SingleSwitch(单按钮墙壁开关)
7.DuplexSwitch(双按钮墙壁开关)
8.SingleSwitchLN(单按钮墙壁开关零火版)
9.DuplexSwitchLN(双按钮墙壁开关零火版)
10.SingleButton86(86型无线单按钮开关)
11.DuplexButton86(86型无线双按钮开关)
12.PlugBase(插座)
13.PlugBase86(86型墙壁插座)
14.MagicSquare(魔方)
15.SmokeDetector(烟雾报警器)
16.NatgasDetector(天然气报警器)
17.ElectricCurtain(电动窗帘)
18.ContactSensor2(门磁感应第二代)
19.MotionSensor2(人体感应第二代)
20.Button2(按钮第二代)
21.TemperatureAndHumiditySensor2(温度湿度传感器第二代)
22.WaterDetector(水浸传感器)

Pre-Requirements

  1. Make sure you have V2 of the gateway. V1 has limited space so can't support this feature.
  2. Update gateway firmware to 1.4.1_150.0143 or later. You can contact @babymoney666 if your firmware is not up to date.

Installation

  1. Install HomeBridge, please follow it's README.
    If you are using Raspberry Pi, please read Running-HomeBridge-on-a-Raspberry-Pi.
  2. Make sure you can see HomeBridge in your iOS devices, if not, please go back to step 1.
  3. Download homebridge-mi-aqara to your local folder.

Configuration

  1. 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.
  2. 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": "MiAqaraPlatform",
        "gateways": {
            "6409802da3b3": "02i44k56zrgg578b"
        }
    }]
}

If you have more than one gateways, fill them in right order, like below.

{
    "platforms": [{
        "platform": "MiAqaraPlatform",
        "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": "MiAqaraPlatform",
        "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": "MiAqaraPlatform",
        "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": "MiAqaraPlatform",
        "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": "MiAqaraPlatform",
        "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": "MiAqaraPlatform",
        "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*