dsc-itv2-client 2.0.5 → 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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/ITV2Client.js +20 -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.5",
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
@@ -1219,6 +1219,10 @@ export class ITV2Client extends EventEmitter {
1219
1219
  rawBytes: statusBytes.toString('hex'),
1220
1220
  };
1221
1221
 
1222
+ // Check alarm state change before updating event handler
1223
+ const prevPartState = this.eventHandler.getPartitionState(partitionNum);
1224
+ const wasInAlarm = prevPartState?.alarm || false;
1225
+
1222
1226
  // Update event handler
1223
1227
  const armedState = partStatus.awayArmed ? 0x02 :
1224
1228
  partStatus.stayArmed ? 0x01 :
@@ -1226,6 +1230,22 @@ export class ITV2Client extends EventEmitter {
1226
1230
  partStatus.armed ? 0x01 : 0x00;
1227
1231
  this.eventHandler.handlePartitionArming(partitionNum, armedState);
1228
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
+
1229
1249
  this.emit('partition:statusResponse', partitionNum, partStatus);
1230
1250
  this._resolvePendingRequest(CMD.PARTITION_STATUS, partStatus);
1231
1251
  } catch (e) {