homebridge-taichuan-u9 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.idea/U9.iml +12 -0
- package/.idea/modules.xml +8 -0
- package/.idea/vcs.xml +6 -0
- package/LICENSE +176 -0
- package/README.md +111 -0
- package/config.schema.json +22 -0
- package/dist/accessory.d.ts +4 -0
- package/dist/accessory.d.ts.map +1 -0
- package/dist/accessory.js +98 -0
- package/dist/accessory.js.map +1 -0
- package/dist/protocol.d.ts +7 -0
- package/dist/protocol.d.ts.map +1 -0
- package/dist/protocol.js +29 -0
- package/dist/protocol.js.map +1 -0
- package/package.json +40 -0
package/.idea/U9.iml
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<module type="WEB_MODULE" version="4">
|
|
3
|
+
<component name="NewModuleRootManager">
|
|
4
|
+
<content url="file://$MODULE_DIR$">
|
|
5
|
+
<excludeFolder url="file://$MODULE_DIR$/temp" />
|
|
6
|
+
<excludeFolder url="file://$MODULE_DIR$/.tmp" />
|
|
7
|
+
<excludeFolder url="file://$MODULE_DIR$/tmp" />
|
|
8
|
+
</content>
|
|
9
|
+
<orderEntry type="inheritedJdk" />
|
|
10
|
+
<orderEntry type="sourceFolder" forTests="false" />
|
|
11
|
+
</component>
|
|
12
|
+
</module>
|
package/.idea/vcs.xml
ADDED
package/LICENSE
ADDED
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
package/README.md
ADDED
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
# Homebridge Taichuan U9
|
|
2
|
+
|
|
3
|
+
通过 **HomeKit** 解锁太川 Taichuan U9 小区单元楼门禁。
|
|
4
|
+
搭配 **Home Hub**(Apple TV / HomePod / iPad)可实现 **远程解锁小区门禁**。
|
|
5
|
+
|
|
6
|
+
> 本插件通过模拟门禁 Pad 的呼叫与解锁流程,使门禁在 HomeKit 中表现为一个可控设备。
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
本项目仅用于技术研究与个人自用,请确保你的使用行为 **符合当地法律法规及物业管理规定**。
|
|
10
|
+
作者不对因不当使用造成的任何后果负责。
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
## 所需材料
|
|
14
|
+
|
|
15
|
+
- [ ] 一台可运行 **Homebridge** 的设备
|
|
16
|
+
- 树莓派
|
|
17
|
+
- NAS
|
|
18
|
+
- x86 主机等
|
|
19
|
+
- [ ] 一台 **支持双 WAN / 多接口的路由器**
|
|
20
|
+
- 已刷 **OpenWRT**
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
## 网络与设备准备
|
|
25
|
+
|
|
26
|
+
### 1. 获取门禁 Pad 的 IP 地址
|
|
27
|
+
|
|
28
|
+
- 门禁 Pad 在 **WiFi 设置** 或 **工程设置** 中通常配置为 **静态 IP**
|
|
29
|
+
- 记录该 IP 地址
|
|
30
|
+
- 工程设置默认密码一般为:
|
|
31
|
+
- `1234` 或 `123456`
|
|
32
|
+
- 若无法进入工程设置,请联系物业确认
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
### 2. 获取单元楼门禁主机的 IP 地址
|
|
37
|
+
|
|
38
|
+
- 在门禁 Pad 的 **工程设置** 中可查看
|
|
39
|
+
- 记录对应的单元楼门禁 IP 地址
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
### 3. 路由器配置(OpenWRT)
|
|
44
|
+
|
|
45
|
+
> 该步骤是整个方案的关键,用于接管门禁专用 VLAN 网络。
|
|
46
|
+
|
|
47
|
+
1. 光猫上通常存在一个 **绑定门禁系统的特殊接口(VLAN)**
|
|
48
|
+
2. 将该接口连接至路由器的 **WAN1**
|
|
49
|
+
- **WAN0**:继续用于正常家庭宽带
|
|
50
|
+
3. WAN1 配置为 **静态 IP**
|
|
51
|
+
- IP 地址填写为 **门禁 Pad 的静态 IP**
|
|
52
|
+
4. 配置策略路由:
|
|
53
|
+
- 将 **门禁相关 IP 段** 路由至 WAN1
|
|
54
|
+
- 其余流量仍然走 WAN0(正常上网)
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
### 4. 配置门禁 Pad(可选)
|
|
59
|
+
|
|
60
|
+
> 如果 **不需要门铃 / 视频通话功能**,可跳过此步骤。
|
|
61
|
+
|
|
62
|
+
1. 将门禁 Pad 连接至家庭 WiFi
|
|
63
|
+
2. 清除门禁 Pad 中的 **静态网络配置**
|
|
64
|
+
3. 设置为 **DHCP**
|
|
65
|
+
4. 在路由器中为门禁 Pad **绑定静态 IP**
|
|
66
|
+
5. 配置端口转发:
|
|
67
|
+
- 将 **WAN1 的 UDP 30303** 转发至门禁 Pad
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
## 插件安装
|
|
72
|
+
|
|
73
|
+
### 通过 Homebridge UI 安装
|
|
74
|
+
|
|
75
|
+
1. 打开 Homebridge 管理界面
|
|
76
|
+
2. 搜索插件名称:`homebridge-taichuan-u9`
|
|
77
|
+
3. 安装完成后重启 Homebridge
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
### 配置样本
|
|
82
|
+
|
|
83
|
+
```json
|
|
84
|
+
{
|
|
85
|
+
"accessory": "U9AccessControl",
|
|
86
|
+
"name": "车库门禁",
|
|
87
|
+
"ip": "172.16.2.1"
|
|
88
|
+
}
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
## 工作原理说明
|
|
92
|
+
|
|
93
|
+
> 太川门禁系统 **必须在呼叫状态下才能解锁**
|
|
94
|
+
|
|
95
|
+
插件在解锁流程中会按顺序执行:
|
|
96
|
+
|
|
97
|
+
1. 向门禁发起 **模拟呼叫**
|
|
98
|
+
2. 短暂等待系统进入可解锁状态
|
|
99
|
+
3. 发送 **解锁指令**
|
|
100
|
+
4. 门禁执行开门动作
|
|
101
|
+
|
|
102
|
+
整个过程对 HomeKit 用户而言表现为一次普通的“解锁”操作。
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
## 注意事项
|
|
107
|
+
|
|
108
|
+
* 门禁 IP、路由配置错误将导致无法解锁
|
|
109
|
+
* 某些小区 VLAN 配置存在差异,请自行确认光猫端口用途
|
|
110
|
+
* 本插件仅用于 **个人合法使用场景**
|
|
111
|
+
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
{
|
|
2
|
+
"pluginAlias": "U9AccessControl",
|
|
3
|
+
"pluginType": "platform",
|
|
4
|
+
"singular": true,
|
|
5
|
+
"schema": {
|
|
6
|
+
"type": "object",
|
|
7
|
+
"properties": {
|
|
8
|
+
"name": {
|
|
9
|
+
"title": "门禁名称",
|
|
10
|
+
"type": "string",
|
|
11
|
+
"required": true,
|
|
12
|
+
"default": "小区门禁"
|
|
13
|
+
},
|
|
14
|
+
"ip": {
|
|
15
|
+
"title": "IP地址",
|
|
16
|
+
"type": "string",
|
|
17
|
+
"required": true,
|
|
18
|
+
"default": "172.16.0.1"
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"accessory.d.ts","sourceRoot":"","sources":["../src/accessory.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,GAAG,EAIJ,MAAM,YAAY,CAAC;8BASL,GAAG;AAAlB,kBAGE"}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
const protocol_1 = __importDefault(require("./protocol"));
|
|
6
|
+
let hap;
|
|
7
|
+
class U9AccessControl {
|
|
8
|
+
constructor(log, config, api) {
|
|
9
|
+
this.isUnlocked = false;
|
|
10
|
+
this.isExpectedUnlocked = false;
|
|
11
|
+
this.log = log;
|
|
12
|
+
this.name = config.name;
|
|
13
|
+
this.ip = config.ip;
|
|
14
|
+
this._api = api;
|
|
15
|
+
this.lockService = new hap.Service.LockMechanism(this.name);
|
|
16
|
+
this.lockService.getCharacteristic(hap.Characteristic.LockCurrentState)
|
|
17
|
+
.onGet(this.handleLockCurrentStateGet.bind(this));
|
|
18
|
+
this.lockService.getCharacteristic(hap.Characteristic.LockTargetState)
|
|
19
|
+
.onGet(this.handleLockTargetStateGet.bind(this))
|
|
20
|
+
.onSet(this.handleLockTargetStateSet.bind(this));
|
|
21
|
+
this.informationService = new hap.Service.AccessoryInformation()
|
|
22
|
+
.setCharacteristic(hap.Characteristic.Manufacturer, 'Taichuan')
|
|
23
|
+
.setCharacteristic(hap.Characteristic.Model, 'U9')
|
|
24
|
+
.setCharacteristic(hap.Characteristic.SerialNumber, '')
|
|
25
|
+
.setCharacteristic(hap.Characteristic.FirmwareRevision, '0.0.0');
|
|
26
|
+
this.protocol = new protocol_1.default();
|
|
27
|
+
log.info(this.name + '@' + this.ip + ' finished initializing!');
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Handle requests to get the current value of the "Lock Current State" characteristic
|
|
31
|
+
*/
|
|
32
|
+
handleLockCurrentStateGet() {
|
|
33
|
+
this.log.debug('Triggered GET LockCurrentState');
|
|
34
|
+
if (this.isUnlocked) {
|
|
35
|
+
return hap.Characteristic.LockCurrentState.UNSECURED;
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
return hap.Characteristic.LockCurrentState.SECURED;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Handle requests to get the current value of the "Lock Target State" characteristic
|
|
43
|
+
*/
|
|
44
|
+
handleLockTargetStateGet() {
|
|
45
|
+
this.log.debug('Triggered GET LockTargetState');
|
|
46
|
+
if (this.isExpectedUnlocked) {
|
|
47
|
+
return hap.Characteristic.LockTargetState.UNSECURED;
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
return hap.Characteristic.LockTargetState.SECURED;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Handle requests to set the "Lock Target State" characteristic
|
|
55
|
+
*/
|
|
56
|
+
handleLockTargetStateSet(value) {
|
|
57
|
+
this.log.debug('Triggered SET LockTargetState:' + value);
|
|
58
|
+
if (value === hap.Characteristic.LockCurrentState.UNSECURED) {
|
|
59
|
+
try {
|
|
60
|
+
this.isExpectedUnlocked = true;
|
|
61
|
+
this.protocol.unlock(this.ip, () => {
|
|
62
|
+
this.isUnlocked = true;
|
|
63
|
+
setTimeout(() => {
|
|
64
|
+
this.isExpectedUnlocked = false;
|
|
65
|
+
this.isUnlocked = false;
|
|
66
|
+
}, 5000);
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
catch (e) {
|
|
70
|
+
this.log.error(JSON.stringify(e));
|
|
71
|
+
this.isUnlocked = false;
|
|
72
|
+
this.isExpectedUnlocked = false;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
/*
|
|
77
|
+
* This method is optional to implement. It is called when HomeKit ask to identify the accessory.
|
|
78
|
+
* Typical this only ever happens at the pairing process.
|
|
79
|
+
*/
|
|
80
|
+
identify() {
|
|
81
|
+
this.log('Identify!');
|
|
82
|
+
}
|
|
83
|
+
/*
|
|
84
|
+
* This method is called directly after creation of this instance.
|
|
85
|
+
* It should return all services which should be added to the accessory.
|
|
86
|
+
*/
|
|
87
|
+
getServices() {
|
|
88
|
+
return [
|
|
89
|
+
this.informationService,
|
|
90
|
+
this.lockService,
|
|
91
|
+
];
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
module.exports = (api) => {
|
|
95
|
+
hap = api.hap;
|
|
96
|
+
api.registerAccessory('U9AccessControl', U9AccessControl);
|
|
97
|
+
};
|
|
98
|
+
//# sourceMappingURL=accessory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"accessory.js","sourceRoot":"","sources":["../src/accessory.ts"],"names":[],"mappings":";;;;AAQA,0DAAuC;AAGvC,IAAI,GAAQ,CAAC;AAUb,MAAM,eAAe;IAYjB,YAAY,GAAY,EAAE,MAAuB,EAAE,GAAQ;QANnD,eAAU,GAAG,KAAK,CAAC;QACnB,uBAAkB,GAAG,KAAK,CAAC;QAMjC,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC;QACxB,IAAI,CAAC,EAAE,GAAG,MAAM,CAAC,EAAE,CAAC;QACpB,IAAI,CAAC,IAAI,GAAG,GAAG,CAAC;QAEhB,IAAI,CAAC,WAAW,GAAG,IAAI,GAAG,CAAC,OAAO,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC5D,IAAI,CAAC,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EJ;AAhHD,iBAAS,CAAC,GAAQ,EAAE,EAAE;IACpB,GAAG,GAAG,GAAG,CAAC,GAAG,CAAC;IACd,GAAG,CAAC,iBAAiB,CAAC,iBAAiB,EAAE,eAAe,CAAC,CAAC;AAC5D,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"protocol.d.ts","sourceRoot":"","sources":["../src/protocol.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,OAAO,OAAO,aAAa;IAC9B,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAS;IACrC,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAS;;IAShC,MAAM,CAAC,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,IAAI;CAajD"}
|
package/dist/protocol.js
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const dgram_1 = __importDefault(require("dgram"));
|
|
7
|
+
class U9UDPProtocol {
|
|
8
|
+
constructor() {
|
|
9
|
+
/* eslint-disable-next-line max-len */
|
|
10
|
+
this.callCommand = Buffer.from('0654d6f84c00000000000000000000003032c6da3230b6b03034b5a5d4aa303332c6da3230b6b034b5a5d4aa33b2e337b7bf000000000000000000000000000003000000010000004001f000', 'hex');
|
|
11
|
+
/* eslint-disable-next-line max-len */
|
|
12
|
+
this.unlockCommand = Buffer.from('0e4a009c4c00000000000000040000003032c6da3230b6b03034b5a5d4aa303332c6da3230b6b034b5a5d4aa33b2e337b7bf000000000000000000000000000003000000010000004001f000', 'hex');
|
|
13
|
+
}
|
|
14
|
+
unlock(ip, callback) {
|
|
15
|
+
const client = dgram_1.default.createSocket('udp4');
|
|
16
|
+
client.connect(7800, ip, () => {
|
|
17
|
+
client.send(this.callCommand, () => {
|
|
18
|
+
setTimeout(() => {
|
|
19
|
+
client.send(this.unlockCommand, () => {
|
|
20
|
+
callback();
|
|
21
|
+
client.close();
|
|
22
|
+
});
|
|
23
|
+
}, 300);
|
|
24
|
+
});
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
exports.default = U9UDPProtocol;
|
|
29
|
+
//# sourceMappingURL=protocol.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"protocol.js","sourceRoot":"","sources":["../src/protocol.ts"],"names":[],"mappings":";;;;;AAAA,kDAA0B;AAE1B,MAAqB,aAAa;IAI9B;QACE,sCAAsC;QACtC,IAAI,CAAC,WAAW,GAAG,MAAM,CAAC,IAAI,CAAC,0JAA0J,EAAE,KAAK,CAAC,CAAC;QAClM,sCAAsC;QACtC,IAAI,CAAC,aAAa,GAAG,MAAM,CAAC,IAAI,CAAC,0JAA0J,EAAE,KAAK,CAAC,CAAC;IACtM,CAAC;IAEM,MAAM,CAAC,EAAU,EAAE,QAAoB;QAC5C,MAAM,MAAM,GAAG,eAAK,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC;QAC1C,MAAM,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,EAAE,GAAG,EAAE;YAC5B,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,GAAG,EAAE;gBACjC,UAAU,CAAC,GAAG,EAAE;oBACd,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE,GAAG,EAAE;wBACnC,QAAQ,EAAE,CAAC;wBACX,MAAM,CAAC,KAAK,EAAE,CAAC;oBACjB,CAAC,CAAC,CAAC;gBACL,CAAC,EAAE,GAAG,CAAC,CAAC;YACV,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC;CACJ;AAxBD,gCAwBC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
{
|
|
2
|
+
"displayName": "Homebridge Taichuan U9",
|
|
3
|
+
"name": "homebridge-taichuan-u9",
|
|
4
|
+
"version": "1.0.0",
|
|
5
|
+
"description": "Homebridge support for Taichuan U9 door access.",
|
|
6
|
+
"license": "Apache-2.0",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "git://github.com/hqy2000/homebridge-taichuan-u9.git"
|
|
10
|
+
},
|
|
11
|
+
"bugs": {
|
|
12
|
+
"url": "https://github.com/hqy2000/homebridge-taichuan-u9/issues"
|
|
13
|
+
},
|
|
14
|
+
"engines": {
|
|
15
|
+
"node": ">=10.17.0",
|
|
16
|
+
"homebridge": ">=1.3.0"
|
|
17
|
+
},
|
|
18
|
+
"main": "dist/index.js",
|
|
19
|
+
"scripts": {
|
|
20
|
+
"lint": "eslint src/**.ts --max-warnings=0",
|
|
21
|
+
"watch": "npm run build && npm link && nodemon",
|
|
22
|
+
"build": "rimraf ./dist && tsc",
|
|
23
|
+
"prepublishOnly": "npm run lint && npm run build"
|
|
24
|
+
},
|
|
25
|
+
"keywords": [
|
|
26
|
+
"homebridge-plugin"
|
|
27
|
+
],
|
|
28
|
+
"dependencies": {},
|
|
29
|
+
"devDependencies": {
|
|
30
|
+
"@types/node": "^14.14.31",
|
|
31
|
+
"@typescript-eslint/eslint-plugin": "^4.16.1",
|
|
32
|
+
"@typescript-eslint/parser": "^4.16.1",
|
|
33
|
+
"eslint": "^7.21.0",
|
|
34
|
+
"homebridge": "^1.3.1",
|
|
35
|
+
"nodemon": "^2.0.7",
|
|
36
|
+
"rimraf": "^3.0.2",
|
|
37
|
+
"ts-node": "^9.1.1",
|
|
38
|
+
"typescript": "^4.2.2"
|
|
39
|
+
}
|
|
40
|
+
}
|