homebridge-comelit-doorbell 2.0.2 → 2.0.3
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/CHANGELOG.md +15 -0
- package/README.md +2 -2
- package/dist/accessories/doorbellAccessory.js +6 -2
- package/dist/accessories/lockAccessory.js +19 -6
- package/dist/door.js +26 -5
- package/dist/platform.js +5 -1
- package/dist/vipListener.js +20 -2
- package/package.json +3 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 2.0.3 (2026-11-07)
|
|
4
|
+
|
|
5
|
+
### Fixed
|
|
6
|
+
|
|
7
|
+
- Accessories were registered again on every reconnect after a fresh install. Homebridge rejected the duplicate, and the ring sensor stopped updating until the next restart. Each accessory is now registered once.
|
|
8
|
+
- Unlock reported success even when the intercom refused. The plugin now waits up to 10 s for the intercom's answer: the lock shows Unlocked only once the door actually opens, snaps back to Locked if refused, and the log gives the cause (for example `cause 8, busy`).
|
|
9
|
+
- Only an INVITE from the intercom counts as a ring. Other new connections no longer fire a ring or open the unlock window.
|
|
10
|
+
- Releases are no longer logged as `door_opened` events.
|
|
11
|
+
- The ring window now applies to Unlock only, not Lock.
|
|
12
|
+
- The doorbell trigger URL also works with `https`, with a 5 s timeout.
|
|
13
|
+
|
|
14
|
+
### Added
|
|
15
|
+
|
|
16
|
+
- Tests built from frames captured from a real intercom, run by CI and before each publish.
|
|
17
|
+
|
|
3
18
|
## 2.0.2 (2026-11-07)
|
|
4
19
|
|
|
5
20
|
- Documentation: the README covers every setting, the accessories the plugin creates, migration, the ring-to-open flow and troubleshooting.
|
package/README.md
CHANGED
|
@@ -86,7 +86,7 @@ HomeKit only sends a proper doorbell notification for a doorbell camera. You can
|
|
|
86
86
|
|
|
87
87
|
| Accessory | HomeKit type | Notes |
|
|
88
88
|
|---|---|---|
|
|
89
|
-
| One lock per door | Lock | Read from the intercom's door list, with the names set on the intercom. **Unlock** opens the door. The lock shows Unlocked for 3 seconds, then Locked again. |
|
|
89
|
+
| One lock per door | Lock | Read from the intercom's door list, with the names set on the intercom. **Unlock** opens the door. The lock shows Unlocked for 3 seconds once the intercom confirms, then Locked again. If the intercom refuses, it goes straight back to Locked and the log says why. |
|
|
90
90
|
| Doorbell (named after **Name**) | Motion sensor | Detected for 5 seconds on every ring. Use it in automations. |
|
|
91
91
|
| RTSP cameras listed on the intercom, if any | Motion sensor | Placeholder only: no video yet. Their RTSP URL is written to the log. |
|
|
92
92
|
|
|
@@ -163,7 +163,7 @@ The platform name stays `ComelitIntercom`, so your config block works unchanged,
|
|
|
163
163
|
|---|---|
|
|
164
164
|
| Rings stop reaching HomeKit after a few minutes | Use the default **Registration refresh interval** of 2 minutes. Check the log for `Registration renewed in place` or reconnects. |
|
|
165
165
|
| No rings at all, but the phones ring | Make sure `subaddress` is a user of its own, not shared with a phone, and that `registerPush` is off. On the intercom's Extender page, the Homebridge user should appear under **Registered slaves**. |
|
|
166
|
-
| Unlock shows as failed | Outside the ring window, this is expected (`Open refused` in the log). During a ring,
|
|
166
|
+
| Unlock shows as failed, or snaps back to Locked | Outside the ring window, this is expected (`Open refused` in the log). During a ring, the log shows `intercom refused (cause 8, busy…)`: see [answering the ring](#answering-the-ring-experimental). |
|
|
167
167
|
| `Doorbell camera trigger failed` in the log | camera-ffmpeg isn't reachable at the URL. Fix the URL, or set it to an empty string. |
|
|
168
168
|
| `Authentication failed` / `Token Not Found` | The token doesn't belong to an active user. Download a fresh backup and copy the token again. |
|
|
169
169
|
|
|
@@ -45,8 +45,12 @@ class DoorbellAccessory {
|
|
|
45
45
|
global.__zmanLastRing = Date.now(); // zman: ring window
|
|
46
46
|
// zman: ring the HomeKit doorbell camera (homebridge-camera-ffmpeg, localhost-only)
|
|
47
47
|
try {
|
|
48
|
-
if (global.__zmanDoorbellUrl)
|
|
49
|
-
|
|
48
|
+
if (global.__zmanDoorbellUrl) { // zman: settings - http or https, 5 s timeout
|
|
49
|
+
const u = new URL(global.__zmanDoorbellUrl);
|
|
50
|
+
const req = require(u.protocol === 'https:' ? 'https' : 'http').get(u, { timeout: 5000 }, (res) => res.resume());
|
|
51
|
+
req.on('timeout', () => req.destroy(new Error('timed out after 5 s')));
|
|
52
|
+
req.on('error', (e) => this.platform.log.warn(`Doorbell camera trigger failed: ${e.message}`));
|
|
53
|
+
}
|
|
50
54
|
} catch (e) { this.platform.log.warn(`Doorbell camera trigger failed: ${e.message}`); }
|
|
51
55
|
this.sensorService.updateCharacteristic(this.platform.Characteristic.MotionDetected, true);
|
|
52
56
|
this.active = true;
|
|
@@ -39,7 +39,7 @@ class LockAccessory {
|
|
|
39
39
|
? Characteristic.LockTargetState.UNSECURED
|
|
40
40
|
: Characteristic.LockTargetState.SECURED)
|
|
41
41
|
.onSet((value) => {
|
|
42
|
-
{ const zw = global.__zmanRingWindowMs === undefined ? 90000 : global.__zmanRingWindowMs; // zman: ring window
|
|
42
|
+
if (value === Characteristic.LockTargetState.UNSECURED) { const zw = global.__zmanRingWindowMs === undefined ? 90000 : global.__zmanRingWindowMs; // zman: ring window
|
|
43
43
|
if (zw > 0 && Date.now() - (global.__zmanLastRing || 0) > zw) {
|
|
44
44
|
if (Date.now() - (global.__zmanRefusedLog || 0) > 5000) { global.__zmanRefusedLog = Date.now(); this.platform.log.warn(`Open refused: no ring in the last ${zw / 1000} s`); }
|
|
45
45
|
const zh = this.platform.api && this.platform.api.hap;
|
|
@@ -54,16 +54,29 @@ class LockAccessory {
|
|
|
54
54
|
const { Characteristic } = this.platform;
|
|
55
55
|
const SECURED = Characteristic.LockCurrentState.SECURED;
|
|
56
56
|
const UNSECURED = Characteristic.LockCurrentState.UNSECURED;
|
|
57
|
-
|
|
58
|
-
|
|
57
|
+
const relock = () => {
|
|
58
|
+
this.lockState = SECURED;
|
|
59
|
+
this.service.updateCharacteristic(Characteristic.LockCurrentState, SECURED);
|
|
60
|
+
this.service.updateCharacteristic(Characteristic.LockTargetState, Characteristic.LockTargetState.SECURED);
|
|
61
|
+
};
|
|
62
|
+
// Show Unlocked only once the intercom confirms; otherwise snap back to Locked.
|
|
59
63
|
try {
|
|
60
|
-
await this.platform.openDoor(this.door);
|
|
61
|
-
|
|
64
|
+
const result = await this.platform.openDoor(this.door);
|
|
65
|
+
if (result && result.confirmed === false) {
|
|
66
|
+
this.platform.log.warn(`Door '${this.door.name}': open sent, but the intercom did not confirm it`);
|
|
67
|
+
}
|
|
68
|
+
else {
|
|
69
|
+
this.platform.log.info(`Door '${this.door.name}' opened`);
|
|
70
|
+
}
|
|
62
71
|
}
|
|
63
72
|
catch (e) {
|
|
64
73
|
this.platform.log.error(`Door open failed: ${e.message}`);
|
|
74
|
+
relock();
|
|
75
|
+
return;
|
|
65
76
|
}
|
|
66
|
-
|
|
77
|
+
this.lockState = UNSECURED;
|
|
78
|
+
this.service.updateCharacteristic(Characteristic.LockCurrentState, UNSECURED);
|
|
79
|
+
// Back to Locked after 3 s
|
|
67
80
|
setTimeout(() => {
|
|
68
81
|
this.lockState = SECURED;
|
|
69
82
|
this.service.updateCharacteristic(Characteristic.LockCurrentState, SECURED);
|
package/dist/door.js
CHANGED
|
@@ -8,6 +8,7 @@ const ctpp_1 = require("./ctpp");
|
|
|
8
8
|
const protocol_1 = require("./protocol");
|
|
9
9
|
const DOOR_CTPP_INIT_TIMEOUT_MS = 5_000;
|
|
10
10
|
const DOOR_RESPONSE_TIMEOUT_MS = 2_000;
|
|
11
|
+
const ZMAN_OPEN_REPLY_TIMEOUT_MS = 10_000;
|
|
11
12
|
class DoorOpenError extends Error {
|
|
12
13
|
}
|
|
13
14
|
exports.DoorOpenError = DoorOpenError;
|
|
@@ -22,7 +23,7 @@ async function openDoor(client, config, door) {
|
|
|
22
23
|
ctpp = await openCtppChannel(client, config);
|
|
23
24
|
}
|
|
24
25
|
try {
|
|
25
|
-
await openDoorOnChannel(client, ctpp, config.aptAddress, door, `${config.aptAddress}${config.aptSubaddress}`);
|
|
26
|
+
return await openDoorOnChannel(client, ctpp, config.aptAddress, door, `${config.aptAddress}${config.aptSubaddress}`);
|
|
26
27
|
}
|
|
27
28
|
catch (e) {
|
|
28
29
|
throw new DoorOpenError(`Failed to open door '${door.name}': ${e.message}`);
|
|
@@ -48,11 +49,11 @@ async function openCtppChannel(client, config) {
|
|
|
48
49
|
}
|
|
49
50
|
}
|
|
50
51
|
async function openDoorOnChannel(client, channel, aptAddr, door, ourAddr) {
|
|
51
|
-
|
|
52
|
+
const zr = global.__zmanCallOpen && await global.__zmanCallOpen(door); // zman: answer
|
|
53
|
+
if (zr) return zr;
|
|
52
54
|
// zman: open like comelit-vip - OP_OPEN_DOOR on a fresh connection, sent from our own address
|
|
53
55
|
if (!door.isActuator) {
|
|
54
|
-
await zmanOpenDoor(client, channel, ourAddr, door);
|
|
55
|
-
return;
|
|
56
|
+
return await zmanOpenDoor(client, channel, ourAddr, door);
|
|
56
57
|
}
|
|
57
58
|
// Phase B: Open + Confirm (regular doors only)
|
|
58
59
|
if (!door.isActuator) {
|
|
@@ -92,5 +93,25 @@ async function zmanOpenDoor(client, channel, ourAddr, door) {
|
|
|
92
93
|
head.writeUInt16BE(body.length, 6);
|
|
93
94
|
const pad = Buffer.alloc((4 - (body.length % 4)) % 4);
|
|
94
95
|
const pkt = Buffer.concat([head, body, pad, Buffer.from([0xff, 0xff, 0xff, 0xff]), la(ourAddr), la(door.aptAddress)]);
|
|
95
|
-
|
|
96
|
+
// Wait for the intercom's answer: RELEASE (0x000E) on the peer of our connection, cause 0 = opened.
|
|
97
|
+
// It can take several seconds (the intercom delays it while busy).
|
|
98
|
+
const key = `${head[2] ^ 0x80}:${head[3]}`;
|
|
99
|
+
const waiters = (global.__zmanOpenWaiters = global.__zmanOpenWaiters || new Map());
|
|
100
|
+
const reply = new Promise((resolve) => {
|
|
101
|
+
const t = setTimeout(() => { waiters.delete(key); resolve(null); }, ZMAN_OPEN_REPLY_TIMEOUT_MS);
|
|
102
|
+
waiters.set(key, (cause) => { clearTimeout(t); waiters.delete(key); resolve(cause); });
|
|
103
|
+
});
|
|
104
|
+
try {
|
|
105
|
+
await client.sendBinary(channel, pkt);
|
|
106
|
+
}
|
|
107
|
+
catch (e) {
|
|
108
|
+
waiters.get(key)?.(null);
|
|
109
|
+
throw e;
|
|
110
|
+
}
|
|
111
|
+
const cause = await reply;
|
|
112
|
+
if (cause === null)
|
|
113
|
+
return { confirmed: false };
|
|
114
|
+
if (cause !== 0)
|
|
115
|
+
throw new DoorOpenError(`intercom refused (cause ${cause}${cause === 8 ? ', busy: a call is ringing and was not answered' : ''})`);
|
|
116
|
+
return { confirmed: true };
|
|
96
117
|
}
|
package/dist/platform.js
CHANGED
|
@@ -220,7 +220,7 @@ class ComelitIntercomPlatform {
|
|
|
220
220
|
if (!this.client || !this.config_) {
|
|
221
221
|
throw new Error('Not connected');
|
|
222
222
|
}
|
|
223
|
-
await (0, door_1.openDoor)(this.client, this.config_, door);
|
|
223
|
+
return await (0, door_1.openDoor)(this.client, this.config_, door);
|
|
224
224
|
}
|
|
225
225
|
// ─── Accessory discovery ──────────────────────────────────────────────────
|
|
226
226
|
discoverAccessories(config) {
|
|
@@ -239,6 +239,7 @@ class ComelitIntercomPlatform {
|
|
|
239
239
|
this.lockAccessories.set(uuid, lockAcc);
|
|
240
240
|
if (isNew) {
|
|
241
241
|
this.api.registerPlatformAccessories(settings_1.PLUGIN_NAME, settings_1.PLATFORM_NAME, [accessory]);
|
|
242
|
+
this.cachedAccessories.push(accessory); // register once: later reconnects find it here
|
|
242
243
|
this.log.info(`Registered door: ${door.name}`);
|
|
243
244
|
}
|
|
244
245
|
else {
|
|
@@ -257,6 +258,7 @@ class ComelitIntercomPlatform {
|
|
|
257
258
|
this.doorbellAccessory = new doorbellAccessory_1.DoorbellAccessory(this, accessory);
|
|
258
259
|
if (isNew) {
|
|
259
260
|
this.api.registerPlatformAccessories(settings_1.PLUGIN_NAME, settings_1.PLATFORM_NAME, [accessory]);
|
|
261
|
+
this.cachedAccessories.push(accessory); // register once: later reconnects find it here
|
|
260
262
|
this.log.info('Registered doorbell');
|
|
261
263
|
}
|
|
262
264
|
else {
|
|
@@ -277,6 +279,7 @@ class ComelitIntercomPlatform {
|
|
|
277
279
|
this.cameraAccessories.set(uuid, camAcc);
|
|
278
280
|
if (isNew) {
|
|
279
281
|
this.api.registerPlatformAccessories(settings_1.PLUGIN_NAME, settings_1.PLATFORM_NAME, [accessory]);
|
|
282
|
+
this.cachedAccessories.push(accessory); // register once: later reconnects find it here
|
|
280
283
|
this.log.info(`Registered camera: ${camera.name}`);
|
|
281
284
|
}
|
|
282
285
|
else {
|
|
@@ -287,6 +290,7 @@ class ComelitIntercomPlatform {
|
|
|
287
290
|
const toRemove = this.cachedAccessories.filter((a) => staleUuids.has(a.UUID));
|
|
288
291
|
if (toRemove.length > 0) {
|
|
289
292
|
this.api.unregisterPlatformAccessories(settings_1.PLUGIN_NAME, settings_1.PLATFORM_NAME, toRemove);
|
|
293
|
+
this.cachedAccessories = this.cachedAccessories.filter((a) => !staleUuids.has(a.UUID));
|
|
290
294
|
this.log.info(`Removed ${toRemove.length} stale accessory/accessories`);
|
|
291
295
|
}
|
|
292
296
|
}
|
package/dist/vipListener.js
CHANGED
|
@@ -73,7 +73,9 @@ global.__zmanCallOpen = async (door) => {
|
|
|
73
73
|
const r = await zmanCall.wait(c, 0x002d, 4000);
|
|
74
74
|
vip.log?.info(`zman-call: open reply ${r ? `op=0x${r.op.toString(16)} body=${zmanCall.hex(r.body)}` : 'none within 4 s'}`);
|
|
75
75
|
if (!c.ended) { await new Promise((z) => setTimeout(z, 1500)); await zmanCall.send(vip, c, 0x60, Buffer.from([0x00, 0x0e, 0x00]), 'hang up 000e'); c.ended = true; }
|
|
76
|
-
|
|
76
|
+
if (r && r.op === 0x000e && r.body.length >= 3 && r.body[2] !== 0)
|
|
77
|
+
throw new Error(`intercom refused the open in the call (cause ${r.body[2]})`);
|
|
78
|
+
return { confirmed: !!(r && r.op === 0x000e && r.body[2] === 0) };
|
|
77
79
|
};
|
|
78
80
|
const MIN_MSG_SIZE = 8;
|
|
79
81
|
const DEDUP_WINDOW_MS = 10_000;
|
|
@@ -184,14 +186,30 @@ class VipEventListener {
|
|
|
184
186
|
if (global.__zmanAnswerMode && global.__zmanAnswerMode !== 'off') await zmanCall.onMsg(this, msg).catch((e) => this.log?.warn(`zman-call: ${e.message}`)); // zman: answer
|
|
185
187
|
if (isRetransmit && prefix === PREFIX_VIDEO_EVENT)
|
|
186
188
|
return;
|
|
189
|
+
// Answer to one of our door-open requests: RELEASE (0x000E) carrying the cause
|
|
190
|
+
if (msg.flags === 0x000e && msg.raw.length >= 11) {
|
|
191
|
+
const waiter = global.__zmanOpenWaiters?.get(`${msg.raw[2]}:${msg.raw[3]}`);
|
|
192
|
+
if (waiter) {
|
|
193
|
+
waiter(msg.raw[10]);
|
|
194
|
+
return;
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
// A new call towards us: only an INVITE (opcode 0x0001) is a ring
|
|
187
198
|
if (prefix === PREFIX_CALL_INIT) {
|
|
188
|
-
|
|
199
|
+
if (msg.flags === 0x0001)
|
|
200
|
+
this._fireEvent('doorbell_ring', msg.addresses);
|
|
201
|
+
else
|
|
202
|
+
this.log?.debug(`VIP: new connection from the intercom, opcode 0x${(msg.flags ?? 0).toString(16)} (not a ring)`);
|
|
189
203
|
return;
|
|
190
204
|
}
|
|
191
205
|
if (prefix === PREFIX_VIP_EVENT && action !== 0) {
|
|
192
206
|
if (action === ACTION_IN_ALERTING) {
|
|
193
207
|
this._fireEvent('doorbell_ring', msg.addresses);
|
|
194
208
|
}
|
|
209
|
+
else if (action === ACTION_DOOR_OPENED && msg.flags === 0x000e) {
|
|
210
|
+
// 3-byte body 0x000E + cause: a call or request being released, not a door opening
|
|
211
|
+
this.log?.debug(`VIP: release, cause ${msg.raw[10]}`);
|
|
212
|
+
}
|
|
195
213
|
else if (action === ACTION_DOOR_OPENED) {
|
|
196
214
|
this._fireEvent('door_opened', msg.addresses);
|
|
197
215
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "homebridge-comelit-doorbell",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.3",
|
|
4
4
|
"description": "Homebridge plugin for Comelit ViP intercoms (6701W/6741W Mini): doorbell notifications, door release and an experimental answer, fully local",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"files": [
|
|
@@ -33,7 +33,8 @@
|
|
|
33
33
|
"6741W"
|
|
34
34
|
],
|
|
35
35
|
"scripts": {
|
|
36
|
-
"check": "for f in dist/*.js dist/accessories/*.js; do node --check \"$f\" || exit 1; done"
|
|
36
|
+
"check": "for f in dist/*.js dist/accessories/*.js; do node --check \"$f\" || exit 1; done",
|
|
37
|
+
"test": "node test/frames.test.js && node test/platform.test.js"
|
|
37
38
|
},
|
|
38
39
|
"engines": {
|
|
39
40
|
"homebridge": ">=2.0.0-beta.0",
|