dsc-itv2-client 1.0.30 → 2.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/src/constants.js CHANGED
@@ -57,7 +57,7 @@ export const Commands = {
57
57
  PARTITION_STATUS: 0x0812,
58
58
  ZONE_BYPASS_STATUS: 0x0813,
59
59
  SINGLE_ZONE_BYPASS_STATUS: 0x0820,
60
- SYSTEM_TROUBLE_STATUS: 0x0822,
60
+ SYSTEM_TROUBLE_STATUS: 0x0822, // New (0x0814 deprecated)
61
61
  TROUBLE_DETAIL: 0x0823,
62
62
  ZONE_ALARM_STATUS: 0x0840,
63
63
  MISC_ALARM_STATUS: 0x0841,
@@ -65,16 +65,19 @@ export class EventHandler {
65
65
  * @returns {object} Parsed zone status
66
66
  */
67
67
  handleZoneStatus(zoneNum, statusByte) {
68
+ // Bit mapping from neohub ModuleZoneStatus.ZoneStatusEnum:
69
+ // 0x01 = Open, 0x02 = Tamper, 0x04 = Fault, 0x08 = LowBattery,
70
+ // 0x10 = Delinquency, 0x20 = Alarm, 0x40 = AlarmMemory, 0x80 = Bypass
68
71
  const status = {
69
72
  zoneNumber: zoneNum,
70
73
  open: !!(statusByte & 0x01),
71
74
  tamper: !!(statusByte & 0x02),
72
75
  fault: !!(statusByte & 0x04),
73
- bypassed: !!(statusByte & 0x08),
74
- trouble: !!(statusByte & 0x10),
76
+ lowBattery: !!(statusByte & 0x08),
77
+ delinquency: !!(statusByte & 0x10),
75
78
  alarm: !!(statusByte & 0x20),
76
- lowBattery: !!(statusByte & 0x40),
77
- supervisionLoss: !!(statusByte & 0x80),
79
+ alarmInMemory: !!(statusByte & 0x40),
80
+ bypassed: !!(statusByte & 0x80),
78
81
  rawStatus: statusByte,
79
82
  timestamp: new Date()
80
83
  };
@@ -85,7 +88,7 @@ export class EventHandler {
85
88
  // Log change
86
89
  this.log(`[Zone ${zoneNum}] Status: ${status.open ? 'OPEN' : 'CLOSED'} ` +
87
90
  `${status.bypassed ? '[BYPASSED]' : ''} ${status.alarm ? '[ALARM]' : ''} ` +
88
- `${status.trouble ? '[TROUBLE]' : ''}`);
91
+ `${status.lowBattery ? '[LOW-BATT]' : ''} ${status.delinquency ? '[DELINQUENT]' : ''}`);
89
92
 
90
93
  // Emit events
91
94
  this.emit('zone:status', status);
@@ -13,7 +13,7 @@ const config = {
13
13
  integrationId: process.env.INTEGRATION_ID || '123123123123',
14
14
  accessCode: process.env.ACCESS_CODE || '12345678',
15
15
  masterCode: process.env.MASTER_CODE || '5555',
16
- port: parseInt(process.env.UDP_PORT || '3073'),
16
+ port: parseInt(process.env.PORT || '3072'),
17
17
  logLevel: process.env.LOG_LEVEL || 'minimal' // 'silent', 'minimal', 'verbose'
18
18
  };
19
19
 
@@ -9,11 +9,11 @@ import { ITV2Client } from '../index.js';
9
9
 
10
10
  // Configuration - update with your panel's credentials
11
11
  const config = {
12
- integrationId: process.env.INTEGRATION_ID || '123123123123',
13
- accessCode: process.env.ACCESS_CODE || '12345678',
14
- masterCode: process.env.MASTER_CODE || '5555',
15
- port: parseInt(process.env.UDP_PORT || '3073'),
16
- logLevel: process.env.LOG_LEVEL || 'minimal' // 'silent', 'minimal', 'verbose'
12
+ integrationId: process.env.INTEGRATION_ID || '221005294611',
13
+ accessCode: process.env.ACCESS_CODE || '13268451',
14
+ masterCode: process.env.MASTER_CODE || '1234',
15
+ port: parseInt(process.env.PORT || '3072'),
16
+ logLevel: process.env.LOG_LEVEL || 'verbose' // 'silent', 'minimal', 'verbose'
17
17
  };
18
18
 
19
19
  // Create client
@@ -32,7 +32,17 @@ client.on('session:connecting', () => {
32
32
  client.on('session:established', (keys) => {
33
33
  console.log('āœ… Session established!');
34
34
  console.log('šŸ” Encrypted communication enabled\n');
35
- console.log('šŸ“” Monitoring zone changes (open/close a door or window)...\n');
35
+ });
36
+
37
+ client.on('status:ready', ({ zones, partition }) => {
38
+ const openZones = zones.filter(z => z.open);
39
+ console.log(`šŸ“Š Initial status loaded: ${zones.length} zones, ${openZones.length} open`);
40
+ if (partition) {
41
+ const state = partition.awayArmed ? 'AWAY' : partition.stayArmed ? 'STAY' :
42
+ partition.armed ? 'ARMED' : 'DISARMED';
43
+ console.log(`šŸ›”ļø Partition 1: ${state}`);
44
+ }
45
+ console.log('\nšŸ“” Monitoring zone changes (open/close a door or window)...\n');
36
46
  });
37
47
 
38
48
  client.on('session:closed', () => {