dsc-itv2-client 2.0.4 → 2.0.6
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/package.json +1 -1
- package/src/ITV2Client.js +25 -0
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsc-itv2-client",
|
|
3
3
|
"author": "fajitacat",
|
|
4
|
-
"version": "2.0.
|
|
4
|
+
"version": "2.0.6",
|
|
5
5
|
"description": "Reverse engineered DSC ITV2 Protocol Client Library for TL280/TL280E - Monitor and control DSC Neo alarm panels with real-time zone/partition status, arming, and trouble detail",
|
|
6
6
|
"main": "src/index.js",
|
|
7
7
|
"type": "module",
|
package/src/ITV2Client.js
CHANGED
|
@@ -270,6 +270,11 @@ export class ITV2Client extends EventEmitter {
|
|
|
270
270
|
} catch (_) {}
|
|
271
271
|
|
|
272
272
|
throw new Error('Arm/disarm not confirmed - panel may have open zones or troubles');
|
|
273
|
+
} finally {
|
|
274
|
+
// Arm/disarm clears zone bypass state — refresh zone status after a brief settle
|
|
275
|
+
setTimeout(() => {
|
|
276
|
+
this.queryZoneStatus().catch(() => {});
|
|
277
|
+
}, 2000);
|
|
273
278
|
}
|
|
274
279
|
}
|
|
275
280
|
|
|
@@ -1214,6 +1219,10 @@ export class ITV2Client extends EventEmitter {
|
|
|
1214
1219
|
rawBytes: statusBytes.toString('hex'),
|
|
1215
1220
|
};
|
|
1216
1221
|
|
|
1222
|
+
// Check alarm state change before updating event handler
|
|
1223
|
+
const prevPartState = this.eventHandler.getPartitionState(partitionNum);
|
|
1224
|
+
const wasInAlarm = prevPartState?.alarm || false;
|
|
1225
|
+
|
|
1217
1226
|
// Update event handler
|
|
1218
1227
|
const armedState = partStatus.awayArmed ? 0x02 :
|
|
1219
1228
|
partStatus.stayArmed ? 0x01 :
|
|
@@ -1221,6 +1230,22 @@ export class ITV2Client extends EventEmitter {
|
|
|
1221
1230
|
partStatus.armed ? 0x01 : 0x00;
|
|
1222
1231
|
this.eventHandler.handlePartitionArming(partitionNum, armedState);
|
|
1223
1232
|
|
|
1233
|
+
// Store alarm flag in partition state
|
|
1234
|
+
const currentPartState = this.eventHandler.getPartitionState(partitionNum);
|
|
1235
|
+
if (currentPartState) {
|
|
1236
|
+
currentPartState.alarm = partStatus.alarm;
|
|
1237
|
+
currentPartState.alarmInMemory = partStatus.alarmInMemory;
|
|
1238
|
+
}
|
|
1239
|
+
|
|
1240
|
+
// Emit alarm events on state change
|
|
1241
|
+
if (partStatus.alarm && !wasInAlarm) {
|
|
1242
|
+
this._logMinimal(`[Partition ${partitionNum}] ALARM!`);
|
|
1243
|
+
this.emit('partition:alarm', { partition: partitionNum, ...partStatus });
|
|
1244
|
+
} else if (!partStatus.alarm && wasInAlarm) {
|
|
1245
|
+
this._logMinimal(`[Partition ${partitionNum}] Alarm restored`);
|
|
1246
|
+
this.emit('partition:alarm:restored', { partition: partitionNum, ...partStatus });
|
|
1247
|
+
}
|
|
1248
|
+
|
|
1224
1249
|
this.emit('partition:statusResponse', partitionNum, partStatus);
|
|
1225
1250
|
this._resolvePendingRequest(CMD.PARTITION_STATUS, partStatus);
|
|
1226
1251
|
} catch (e) {
|