• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

YinHangCode/homebridge-mi-aqara: a homebridge plugin for XiaoMi Aqara plugin.

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称:

YinHangCode/homebridge-mi-aqara

开源软件地址:

https://github.com/YinHangCode/homebridge-mi-aqara

开源编程语言:

JavaScript 64.8%

开源软件介绍:

homebridge-mi-aqara

npm version npm version npm version npm version npm version npm version

homebridge plugin for XiaoMi Aqara plugin.
小米/绿米网关的HomeBridge插件。

Thanks for nfarina(the author of homebridge), snOOrz(the author of homebridge-aqara), licuhui, 攀旺智能, magaHH, isundaylee, ileler, myriky, Runc2333, yangliu, wonderfullay, BrianHenryIE, all other developer and testers.
感谢 nfarina(homebridge的作者), snOOrz(homebridge-aqara的作者), licuhui, 攀旺智能, magaHH, isundaylee, ileler, myriky, Runc2333, yangliu, wonderfullay, BrianHenryIE, 以及每一位开发者和测试者.

Note: I have only a part of these devices, so some devices don't have tested. If you find bugs, please submit them to issues or QQ Group: 107927710.
注意: 我只有一部分设备, 所以一些设备没有得到充分的测试。 如果你发现Bug,请提交到 issuesQQ群: 107927710

Note: According to aqara local network protocol use UDP port 9898, please notice the relevant configuration of firewall.
注意: 绿米的局域网协议使用的是UDP的9898端口,请配置好防火墙的相关配置。

Note: 0.5.x update to 0.6.x must be clear register accessories and update configuration file content.
注意: 0.5.x版本升级到0.6.x版本必须清空注册设备信息并且更新配置文件内容.

Note: About AcPartner, This project only provides gateway functionality. If you want the use air conditioning function, please refer to the project for homebridge-mi-acPartner.
注意: 有关空调伴侣,这个项目只提供网关的功能,如果你需要使用空调的功能,请参考项目homebridge-mi-acPartner

Supported Devices(支持的设备)

Device Name
设备名称
Protocol Model Value
协议Model值
1 Gateway(网关) gateway
gateway.v3
2 ContactSensor(门磁感应) magnet
sensor_magnet
3 MotionSensor(人体感应) motion
4 Button(按钮) switch
sensor_switch
5 TemperatureAndHumiditySensor(温度湿度传感器) sensor_ht
6 SingleSwitch(单按钮墙壁开关) ctrl_neutral1
7 DuplexSwitch(双按钮墙壁开关) ctrl_neutral2
8 SingleSwitchLN(单按钮墙壁开关零火版) ctrl_ln1
ctrl_ln1.aq1
9 DuplexSwitchLN(双按钮墙壁开关零火版) ctrl_ln2
ctrl_ln2.aq1
10 SingleButton86(86型无线单按钮开关) 86sw1
sensor_86sw1.aq1
sensor_86sw1
11 DuplexButton86(86型无线双按钮开关) 86sw2
sensor_86sw2.aq1
sensor_86sw2
12 PlugBase(插座) plug
13 PlugBase86(86型墙壁插座) 86plug
ctrl_86plug
ctrl_86plug.aq1
14 MagicSquare(魔方) cube
sensor_cube
sensor_cube.aqgl01
15 SmokeDetector(烟雾报警器) smoke
sensor_smoke
16 NatgasDetector(天然气报警器) natgas
sensor_natgas
17 ElectricCurtain(电动窗帘) curtain
18 ContactSensor2(门磁感应第二代) sensor_magnet.aq2
19 MotionSensor2(人体感应第二代) sensor_motion.aq2
20 Button2(按钮第二代) sensor_switch.aq2
remote.b1acn01
21 TemperatureAndHumiditySensor2(温度湿度传感器第二代) weather.v1
weather
22 WaterDetector(水浸传感器) sensor_wleak.aq1
23 Lock(门锁) lock.aq1
24 AcPartner(空调伴侣升级版) acpartner.v3
25 Button3(按钮第二代升级版) sensor_switch.aq3
26 DuplexButton862(86型无线双按钮开关升级版) remote.b286acn01
27 VibrationSensor(动静贴) vibration
28 ElectricCurtainBattery(电动窗帘锂电池版) curtain.hagl04

Pre-Requirements(前置要求)

  1. Make sure your IOS version is IOS11 or later.
    确保你的IOS设备版本高于IOS11。
  2. Make sure you have gateway v2 or acpartner v3. gateway v1 has limited space so can't support this feature.
    确保你的小米网关是二代版本/空调伴侣是三代。小米网关一代不支持此插件。
  3. Update gateway firmware to 1.4.1_155.0143(gateway v2), 1.4.1_148.019(acpartner v3) or later.
    确保你的网关的固件版本高于1.4.1_155.0143(小米网关二代), 1.4.1_148.019(空调伴侣三代)。

Installation(安装)

  1. Install HomeBridge, please follow it's README.
    安装HomeBridge,请参考如下:README
    If you are using Raspberry Pi, please read Running-HomeBridge-on-a-Raspberry-Pi.
    如果你使用树莓派安装,可以参考文章:在树莓派运行HomeBridge.
  2. Make sure you can see HomeBridge in your iOS devices, if not, please go back to step 1.
    确保在你的IOS设备的家挺app中添加设备里能看到HomeBridge的桥,如果看不到请重复第一步。
  3. Download homebridge-mi-aqara to your HomeBridge path or installation through NPM:
    下载homebridge-mi-aqara插件到你的HomeBridge上,使用如下NPM命令安装:
npm install -g homebridge-mi-aqara

Configuration(配置说明)

Name
名称
Required
是否必填
Value Type
值的数据类型
Description
功能描述
Value Example
参考值
1 platform True
String
字符串
It must be 'MiAqaraPlatform'
必须写'MiAqaraPlatform'
2 gateways True
Object
对象
set gateway information.
网关的信息
{ "6409802da3b3": "02i44k56zrgg578b" }
3 bindAddress False
String
字符串
specified network.
指定工作网络
"10.0.1.1"
4 sendWhoisCmdInterval False
Integer
整型
set send whois cmd interval.
设置多久自动发送一次whois命令
3600000
5 autoRemoveAccessoryInterval False
Integer
整型
set auto remove accessory interval.
指定自动删除配件检测间隔时间
3600000
6 defaultValue False
Object
对象
set device default value.
默认值的配置
7 manage False
Object
对象
open manage and manage configs.
管理页面的配置
{ "port": 11128, "password": "107927710" }
8 mqtt False
Object
对象
open mqtt and mqtt configs.
mqtt相关配置
{ "username": "mqtt", "password": "107927710" }

For more information about config, Please refer to file sampleConfig.json.
有关配置,可以参考配置文件 sampleConfig.json

gateways configuration(网关配置)

Open aqara gateway's settings, enable local network protocol.
在网关的设置页面,打开 局域网控制协议
Please follow the steps in this thread: http://wiki.yinhh.com/Wiki.jsp?page=Homebridge-mi-aqara or http://bbs.xiaomi.cn/t-13198850. It's in Chinese so you might need a translator to read it.
可以参考如下教程:http://wiki.yinhh.com/Wiki.jsp?page=Homebridge-mi-aqarahttp://bbs.xiaomi.cn/t-13198850

On iPhone:
步骤可参考:

  • Open the app
    打开米家app
  • Select the gateway
    选择网关设备
  • Press the top right (…) Settings button
    点击右上角的(…)按钮
  • Select About
    选择关于
  • Tap five times in the blank area to reveal the hidden menu items
    在空白区域中点击五次以显示隐藏菜单项
  • Below the version numbers, choose the first: LAN Communication Protocol
    在版本号下面,选择第一个:局域网通信协议
  • Toggle the LAN Communication Protocol switch to on
    将“LAN通信协议”开关切换到开
  • Take note of the alphanumeric code beside Password
    记下密码旁边的字母数字代码
  • Press OK
    点击OK
  • Go back to the previous menu (About) and select the next option: Gateway Information
    返回上一个菜单(关于)并选择下一个选项:网关信息
  • Take note of the MAC address at mac=
    记下mac=上的MAC地址

To control the devices, put gateway's MAC address (lower case without colon) and password (keep original and case sensitive) to ~/.homebridge/config.json.
将网关的mac地址(小写字母 去掉冒号)和密码(保持原始 区分大小写)写入到配置文件 ~/.homebridge/config.json。

Warning: gateway's MAC address (lower case without colon) and password (keep original and case sensitive).
警告: 网关的MAC地址 (全部小写 去掉冒号) 密码 (保持原始 区分大小写) 。
Warning: gateway's MAC address (lower case without colon) and password (keep original and case sensitive).
警告: 网关的MAC地址 (全部小写 去掉冒号) 密码 (保持原始 区分大小写) 。
Warning: gateway's MAC address (lower case without colon) and password (keep original and case sensitive).
警告: 网关的MAC地址 (全部小写 去掉冒号) 密码 (保持原始 区分大小写) 。
Important things are to be repeated for 3 times.
重要的事情说三遍。

{
    "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"
        }
    }]
}

Here is a way to search for gateways instead of multicast, because of some friends do not respond to information from gateway in their network environment.
有一些朋友的网络环境有一些问题,无法正常使用组播,这里提供一种配置方式来替代通过组播的方式寻找网关。
That is to say, we can config the IP address of the gateway to replace search gateway by multicast.
也就是说,可以通过配置网关的IP来替换通过组播的方式寻找网关。

{
    "platforms": [{
        "platform": "MiAqaraPlatform",
        "gateways": {
            "6409802da3b3": {
                "password": "02i44k56zrgg578b",
                "ip": "10.3.3.1"
            },
            "f0b4299a5b2b": {
                "password": "2F92E7DA90C66B86",
                "ip": "10.3.3.2"
            },
            "f0b4299a77dd": {
                "password": "syu3oasva3uqd5qd",
                "ip": "10.3.3.3"
            }
        }
    }]
}

It can also be mixed config, but without full configuration of ip, multicast packets will still be sent to search for other gateways which do not config ip.
也可以混合配置,不过只要有一个网关没有配置IP,程序就会发送组播信息来寻找未配置IP的网关。若所有网关全部配置了IP,则程序不发送组播包寻找网关。

{
    "platforms": [{
        "platform": "MiAqaraPlatform",
        "gateways": {
            "6409802da3b3": "02i44k56zrgg578b",
            "f0b4299a5b2b": {
                "password": "2F92E7DA90C66B86",
                "ip": "10.3.3.2"
            },
            "f0b4299a77dd": {
                "password": "syu3oasva3uqd5qd",
                "ip": "10.3.3.3"
            }
        }
    }]
}

bindAddress configuration(监听地址配置)

If your device(which running homebridge) has multiple network, please add the bindAddress configuration item to decide to listen which network, like below:
如果你运行HomeBridge的设备有多块网卡并且在多个网络中,可以通过这个配置来指定使用哪一个网络,配置如下:

{
    "platforms": [{
        "platform": "MiAqaraPlatform",
        "bindAddress": "10.0.1.1",
        "gateways": {
            "6409802da3b3": "02i44k56zrgg578b",
            "f0b4299a5b2b": "2F92E7DA90C66B86",
            "f0b4299a77dd": "syu3oasva3uqd5qd"
        }
    }]
}

sendWhoisCmdInterval configuration(自动发送whois命令间隔时间配置)

If this configuration item is not to configure, it will be send whois command every hour by default.
如果该配置项不填写,默认情况下,每小时发送一次。
If your network has some problems and you can't receive the heartbeat packet, you can use send whois command to replace the heartbeat function. If you use it in this way, you can set the value of the configuration item to 5 seconds, that is 5000. example:
如果你的网络有一些问题,无法收到心跳包,那么你可以使用发送a来替代心跳功能,如果这样使用,可以将配置项的值设为5秒,即5000,例子如下:

{
    "platforms": [{
        "platform": "MiAqaraPlatform",
        "bindAddress": "10.0.1.1",
        "sendWhoisCmdInterval": 5000,
        "gateways": {
            "6409802da3b3": "02i44k56zrgg578b",
            "f0b4299a5b2b": "2F92E7DA90C66B86",
            "f0b4299a77dd": "syu3oasva3uqd5qd"
        }
    }]
}

autoRemoveAccessoryInterval configuration(自动删除配件检测间隔时间配置)

If you want the plugin to help you automatically delete devices that have not received heartbeat for a long time, you can configure this item. The value is how often to detect. If you don't need to automatically delete accessories, you can not configure this configuration.
如果你希望插件帮你自动删除长时间收不到心跳的设备,则可以配置此项目,该值为多久检测一次。如果不需要自动删除配件功能,可以不配置此配置。
note: long time is defined as: no heartbeat received in more than 7 days.
注:长时间的定义为:超过7天未收到心跳。

{
    "platforms": [{
        "platform": "MiAqaraPlatform",
        "bindAddress": "10.0.1.1",
        "autoRemoveAccessoryInterval": 3600000,
        "gateways": {
            "6409802da3b3": "02i44k56zrgg578b",
            "f0b4299a5b2b": "2F92E7DA90C66B86",
            "f0b4299a77dd": "syu3oasva3uqd5qd"
        }
    }]
}

defaultValue configuration(默认值配置)

If you want to specify the default value, such as specify the name of the accessory, hide the accessory, any other configs. You can add a defaultValue mapping table to your config.json.
如果你想要指定默认值,比如配件的名字,是否隐藏配件以及其他一些配置,你可以在你的配置文件config.json中增加defaultValue配置项。 The config supported are as follows:
这个配置支持如下功能:

Name
名称
Value Type
数据类型
Description
描述
Default Value
默认值
Recommended Value
建议值
Value Example
值举例
1 name String
字符串
set accessory name.
名字
DeviceAccessoryType_device SID last four bits
设备配件类型_设备SID的后四位
"living room temperature"
"卧室的温度"
2 serviceType String
字符串
set accessory type for Switch or Lightbulb.
设置配件类型是开关或者灯。
Currently only supported: SingleSwitch, DuplexSwitch, SingleSwitchLN, DuplexSwitchLN.
当前只支持如下设备:单火线单键墙壁开关,单火线双键墙壁开关,零火单键墙壁开关,零火双键墙壁开关。
"Switch" "Switch" "Lightbulb"
3 disable Boolean
布尔
disable accessory
隐藏设备
false the accessories that do not need to be set to true, such as virtual press.
如果配件不需要时设置为true,如一些设备的虚拟按键。
true
4 syncValue Boolean
布尔
accessory will synchronization value when homebridge call the get function, if it's true.
如果设为true,配件会在HomeBridge每次调用get方法时同步一次值。
false fasle false
5 ignoreWriteResult Boolean
布尔
if set to true, the result of control is not detected.
如果设为true,则忽略控制结果检测。
true If your network is awful, it's recommended to be set true.
如果网络环境不是很好,建议设为true
false
6 disableNoResponse Boolean
布尔
use jump back the last value to replace show NoResponse, you can set it true.
如果设为true,当设备未响应时配件通过自动跳回上一个值的方式来替代显示未响应
false false true

The rules are as follows:
配置规则如下:

{
    "platforms": [{
        "platform": "MiAqaraPlatform",
        "gateways": {
            "6409802da3b3": "02i44k56zrgg578b",
            "f0b4299a5b2b": "2F92E7DA90C66B86",
            "f0b4299a77dd": "syu3oasva3uqd5qd"
        },
        "defaultValue": {
            "device1 sid": {
                "DeviceAccessoryType1": {
                    "config1": "config1 value"
                }
            },
            "device2 sid": {
                "DeviceAccessoryType1": {
                    "config1": "config1 value"
                    "config2": "config2 value"
                },
                "DeviceAccessoryType2": {
                    "config1": "config1 value"
                }
            }
        }
    }]
}

examples:
例子:

{
    "platforms": [{
        "platform": "MiAqaraPlatform",
        "gateways": {
            "6409802da3b3": "02i44k56zrgg578b",
            "f0b4299a5b2b": "2F92E7DA90C66B86",
            "f0b4299a77dd": "syu3oasva3uqd5qd"
        },
        "defaultValue": {
            "158d0001000001": {
                "ContactSensor_ContactSensor": {
                    "name": "entrance door"
                }
            },
            "158d0001000002": {
                "MotionSensor2_MotionSensor": {
                    "name": "study room motion sensor"
                },
                "MotionSensor2_LightSensor": {
                    "name": "study room light sensor"
                }
            }
        }
    }]
}

The rules of A DeviceAccessoryType:
设备配件类型的规则如下:

DeviceName_HomeBridgeAccessoryType(_ExtraMessage)   
设备名称_HomeBridge的配件类型(_附加信息)

detail:
具体如下:

Device Name
设备名称
DeviceAccessoryType
设备包含的设备配件类型
1 Gateway(网关) Gateway_Lightbulb
Gateway_LightSensor
Gateway_Switch_JoinPermission
2 ContactSensor(门磁感应) ContactSensor_ContactSensor
3 MotionSensor(人体感应) MotionSensor_MotionSensor
4 Button(按钮) Button_StatelessProgrammableSwitch
Button_Switch_VirtualSinglePress
Button_Switch_VirtualDoublePress
5 TemperatureAndHumiditySensor(温度湿度传感器) TemperatureAndHumiditySensor_TemperatureSensor
TemperatureAndHumiditySensor_HumiditySensor
6 SingleSwitch(单按钮墙壁开关) SingleSwitch_Switch
7 DuplexSwitch(双按钮墙壁开关) DuplexSwitch_Switch_Left
DuplexSwitch_Switch_Right
8 SingleSwitchLN(单按钮墙壁开关零火版) SingleSwitchLN_Switch
9 DuplexSwitchLN(双按钮墙壁开关零火版) DuplexSwitchLN_Switch_Left
DuplexSwitchLN_Switch_Right
10 SingleButton86(86型无线单按钮开关) SingleButton86_StatelessProgrammableSwitch
SingleButton86_Switch_VirtualSinglePress
11 DuplexButton86(86型无线双按钮开关) DuplexButton86_StatelessProgrammableSwitch_Left
DuplexButton86_Switch_VirtualSinglePress_Left
DuplexButton86_StatelessProgrammableSwitch_Right
DuplexButton86_Switch_VirtualSinglePress_Right
DuplexButton86_StatelessProgrammableSwitch_Both
DuplexButton86_Switch_VirtualSinglePress_Both
12 PlugBase(插座) PlugBase_Outlet
13 PlugBase86(86型墙壁插座) PlugBase86_Outlet
14 MagicSquare(魔方) MagicSquare_StatelessProgrammableSwitch_Flip90
MagicSquare_StatelessProgrammableSwitch_Flip180
MagicSquare_StatelessProgrammableSwitch_Move
MagicSquare_StatelessProgrammableSwitch_TapTwice
MagicSquare_StatelessProgrammableSwitch_ShakeAir
MagicSquare_StatelessProgrammableSwitch_Rotate
MagicSquare_Switch_VirtualFlip90
MagicSquare_Switch_VirtualFlip180
MagicSquare_Switch_VirtualMove
MagicSquare_Switch_VirtualTapTwice
MagicSquare_Switch_VirtualShakeAir
15 SmokeDetector(烟雾报警器) SmokeDetector_SmokeSensor
16 NatgasDetector(天然气报警器) NatgasDetector_SmokeSensor
17 ElectricCurtain(电动窗帘) ElectricCurtain_WindowCovering
18 ContactSensor2(门磁感应第二代) ContactSensor2_ContactSensor
19 MotionSensor2(人体感应第二代) MotionSensor2_MotionSensor
MotionSensor2_LightSensor
20 Button2(按钮第二代) Button2_StatelessProgrammableSwitch
Button2_Switch_VirtualSinglePress
Button2_Switch_VirtualDoublePress
21 TemperatureAndHumiditySensor2(温度湿度传感器第二代) TemperatureAndHumiditySensor2_TemperatureSensor
TemperatureAndHumiditySensor2_HumiditySensor
22 WaterDetector(水浸传感器) WaterDetector_LeakSensor
23 Lock(门锁) Lock_MotionSensor
Lock_MotionSensor_{UserID}
24 AcPartner(空调伴侣升级版) AcPartner_LightSensor
AcPartner_Switch_JoinPermission
25 Button3(按钮第二代升级版) Button3_StatelessProgrammableSwitch
Button3_StatelessProgrammableSwitch_Shake
Button3_Switch_VirtualSinglePress
Button3_Switch_VirtualDoublePress
Button3_Switch_VirtualShare
26 DuplexButton862(86型无线双按钮开关升级版) DuplexButton862_StatelessProgrammableSwitch_Left
DuplexButton862_Switch_VirtualSinglePress_Left
DuplexButton862_Switch_VirtualDoublePress_Left
DuplexButton862_StatelessProgrammableSwitch_Right
DuplexButton862_Switch_VirtualSinglePress_Right
DuplexButton862_Switch_VirtualDoublePress_Right
DuplexButton862_StatelessProgrammableSwitch_Both
DuplexButton862_Switch_VirtualSinglePress_Both
27 VibrationSensor(动静贴) VibrationSensor_MotionSensor_Vibrate
VibrationSensor_MotionSensor_Tilt
VibrationSensor_MotionSensor_FreeFall
28 ElectricCurtainBattery(电动窗帘锂电池版) ElectricCurtainBattery_WindowCovering

About Global:
有关全局配置方式:
Some similar configurations and repeated multiple copies are boring things. So I provided a global writing method.
一些类似的配置和重复的多次拷贝是件比较烦的事情,所以我提供了一个全局的功能:
The following two methods of writing are equivalent:
下面两段配置的效果是等同的:

....
"158d0001000008": {
    "DuplexSwitch_Switch_Left": {
        "name": "master bedroom room light",
        "serviceType": "Lightbulb"
    },
    "DuplexSwitch_Switch_Right": {
        "name": "study room light",
        "serviceType": "Lightbulb"
    }
}
....
....
"158d0001000008": {
    "Global": {
        "serviceType": "Lightbulb"
    },
    "DuplexSwitch_Switch_Left": {
        "name": "master bedroom room light"
    },
    "DuplexSwitch_Switch_Right": {
        "name": "study room light"
    }
}
....

In the same way, the following two kinds of writing are alse equivalent:
同样的方式,下面两段配置的效果也是等同的:

....
"158d0001000003": {
    "Button_StatelessProgrammableSwitch": {
        "name": "living room button"
    },
    "Button_Switch_VirtualSinglePress": {
        "name": "living room button virtual single press",
        "disable": true
    },
    "Button_Switch_VirtualDoublePress": {
        "name": "living room button virtual double press",
        "disable": true
    }
}
....
....
"158d0001000003": {
    "Global": {
        "disable": true 
    },
    "Button_StatelessProgrammableSwitch": {
        "name": "living room button",
        "disable": false
    },
    "Button_Switch_VirtualSinglePress": {
        "name": "living room button virtual single press"
    },
    "Button_Switch_VirtualDoublePress": {
        "name": "living room button virtual double press"
    }
}
....

It also provides a higher level of way, the following three kinds of writing are alse equivalent:
更高层级的配置也可适用,如下三段配置的效果均是等同的:

{
    "platforms": [{
        "platform": "MiAqaraPlatform",
        "gateways": {
            "6409802da3b3": "02i44k56zrgg578b",
            "f0b4299a5b2b": "2F92E7DA90C66B86",
            "f0b4299a77dd": "syu3oasva3uqd5qd"
        },
        "defaultValue": {
            "158d0001000007": {
                "SingleSwitch_Switch": {
                    

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap