Skip to content

Commit d718aad

Browse files
authored
Merge pull request #176 from athombv/fix/breaking-naming-inconsistencies
fix: unify iasZone zoneType enum to match ZCL spec
2 parents 82d7a8c + 276a85d commit d718aad

4 files changed

Lines changed: 34 additions & 39 deletions

File tree

README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,16 @@ Make sure to take a look at the API documentation: [https://athombv.github.io/no
1515

1616
## Breaking changes
1717

18+
v3.0.0
19+
20+
- **iasZone**: Unified `zoneType` enum keys between attribute and `zoneEnrollRequest` command to match ZCL spec (Table 8-5). See [#176](https://github.com/athombv/node-zigbee-clusters/pull/176) for full impact analysis.
21+
- `cabonMonoxideSensor` -> `carbonMonoxideSensor` (typo fix)
22+
- `keyfob` -> `keyFob` (spec says "Key fob" - two words)
23+
- `standard` -> `standardCIE` (in `zoneEnrollRequest`)
24+
- `invalid` -> `invalidZoneType` (in `zoneEnrollRequest`)
25+
- `keyPad` -> `keypad` (in `zoneEnrollRequest`, spec says "Keypad" - one word)
26+
- Added missing `doorWindowHandle` (0x0016) zone type from spec
27+
1828
v2.0.0
1929

2030
- Changed `Cluster.readAttributes` signature, attributes must now be specified as an array of strings.

index.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -467,7 +467,7 @@ export interface IASWDCluster extends ZCLNodeCluster {
467467

468468
export interface IASZoneClusterAttributes {
469469
zoneState?: 'notEnrolled' | 'enrolled';
470-
zoneType?: 'standardCIE' | 'motionSensor' | 'contactSwitch' | 'fireSensor' | 'waterSensor' | 'cabonMonoxideSensor' | 'personalEmergencyDevice' | 'vibrationMovementSensor' | 'remoteControl' | 'keyfob' | 'keypad' | 'standardWarningDevice' | 'glassBreakSensor' | 'securityRepeater' | 'invalidZoneType';
470+
zoneType?: 'standardCIE' | 'motionSensor' | 'contactSwitch' | 'doorWindowHandle' | 'fireSensor' | 'waterSensor' | 'carbonMonoxideSensor' | 'personalEmergencyDevice' | 'vibrationMovementSensor' | 'remoteControl' | 'keyFob' | 'keypad' | 'standardWarningDevice' | 'glassBreakSensor' | 'securityRepeater' | 'invalidZoneType';
471471
zoneStatus?: Partial<{ alarm1: boolean; alarm2: boolean; tamper: boolean; battery: boolean; supervisionReports: boolean; restoreReports: boolean; trouble: boolean; acMains: boolean; test: boolean; batteryDefect: boolean }>;
472472
iasCIEAddress?: string;
473473
zoneId?: number;
@@ -481,7 +481,7 @@ export interface IASZoneCluster extends ZCLNodeCluster {
481481
once<K extends keyof IASZoneClusterAttributes & string>(eventName: `attr.${K}`, listener: (value: IASZoneClusterAttributes[K]) => void): this;
482482
zoneStatusChangeNotification(args: { zoneStatus: Partial<{ alarm1: boolean; alarm2: boolean; tamper: boolean; battery: boolean; supervisionReports: boolean; restoreReports: boolean; trouble: boolean; acMains: boolean; test: boolean; batteryDefect: boolean }>; extendedStatus: number; zoneId: number; delay: number }, opts?: ClusterCommandOptions): Promise<void>;
483483
zoneEnrollResponse(args: { enrollResponseCode: 'success' | 'notSupported' | 'noEnrollPermit' | 'tooManyZones'; zoneId: number }, opts?: ClusterCommandOptions): Promise<void>;
484-
zoneEnrollRequest(args: { zoneType: 'standard' | 'motionSensor' | 'contactSwitch' | 'fireSensor' | 'waterSensor' | 'carbonMonoxideSensor' | 'personalEmergencyDevice' | 'vibrationMovementSensor' | 'remoteControl' | 'keyFob' | 'keyPad' | 'standardWarningDevice' | 'glassBreakSensor' | 'securityRepeater' | 'invalid'; manufacturerCode: number }, opts?: ClusterCommandOptions): Promise<void>;
484+
zoneEnrollRequest(args: { zoneType: 'standardCIE' | 'motionSensor' | 'contactSwitch' | 'doorWindowHandle' | 'fireSensor' | 'waterSensor' | 'carbonMonoxideSensor' | 'personalEmergencyDevice' | 'vibrationMovementSensor' | 'remoteControl' | 'keyFob' | 'keypad' | 'standardWarningDevice' | 'glassBreakSensor' | 'securityRepeater' | 'invalidZoneType'; manufacturerCode: number }, opts?: ClusterCommandOptions): Promise<void>;
485485
initiateNormalOperationMode(opts?: ClusterCommandOptions): Promise<void>;
486486
}
487487

lib/clusters/iasZone.js

Lines changed: 21 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,25 @@ const { ZCLDataTypes } = require('../zclTypes');
55

66
const ZONE_STATUS_DATA_TYPE = ZCLDataTypes.map16('alarm1', 'alarm2', 'tamper', 'battery', 'supervisionReports', 'restoreReports', 'trouble', 'acMains', 'test', 'batteryDefect');
77

8+
const ZONE_TYPE_VALUES = {
9+
standardCIE: 0x0000,
10+
motionSensor: 0x000d,
11+
contactSwitch: 0x0015,
12+
doorWindowHandle: 0x0016,
13+
fireSensor: 0x0028,
14+
waterSensor: 0x002a,
15+
carbonMonoxideSensor: 0x002b,
16+
personalEmergencyDevice: 0x002c,
17+
vibrationMovementSensor: 0x002d,
18+
remoteControl: 0x010f,
19+
keyFob: 0x0115,
20+
keypad: 0x021d,
21+
standardWarningDevice: 0x0225,
22+
glassBreakSensor: 0x0226,
23+
securityRepeater: 0x0229,
24+
invalidZoneType: 0xffff,
25+
};
26+
827
const ATTRIBUTES = {
928
zoneState: {
1029
id: 0,
@@ -15,24 +34,7 @@ const ATTRIBUTES = {
1534
},
1635
zoneType: {
1736
id: 1,
18-
// Note: enum keys differ from zoneEnrollRequest.zoneType but can't be changed without breaking
19-
type: ZCLDataTypes.enum16({
20-
standardCIE: 0,
21-
motionSensor: 13,
22-
contactSwitch: 21,
23-
fireSensor: 40,
24-
waterSensor: 42,
25-
cabonMonoxideSensor: 43,
26-
personalEmergencyDevice: 44,
27-
vibrationMovementSensor: 45,
28-
remoteControl: 271,
29-
keyfob: 277,
30-
keypad: 541,
31-
standardWarningDevice: 549,
32-
glassBreakSensor: 550,
33-
securityRepeater: 553,
34-
invalidZoneType: 65535,
35-
}),
37+
type: ZCLDataTypes.enum16(ZONE_TYPE_VALUES),
3638
},
3739
zoneStatus: {
3840
id: 2,
@@ -79,24 +81,7 @@ const COMMANDS = {
7981
// Add direction property as "initiateNormalOperationMode" has same command id.
8082
direction: Cluster.DIRECTION_SERVER_TO_CLIENT,
8183
args: {
82-
// Note: enum keys differ from the zoneType attribute but can't be changed without breaking
83-
zoneType: ZCLDataTypes.enum16({
84-
standard: 0x0000,
85-
motionSensor: 0x000d,
86-
contactSwitch: 0x0015,
87-
fireSensor: 0x0028,
88-
waterSensor: 0x002a,
89-
carbonMonoxideSensor: 0x002b,
90-
personalEmergencyDevice: 0x002c,
91-
vibrationMovementSensor: 0x002d,
92-
remoteControl: 0x010f,
93-
keyFob: 0x0115,
94-
keyPad: 0x021d,
95-
standardWarningDevice: 0x0225,
96-
glassBreakSensor: 0x0226,
97-
securityRepeater: 0x0229,
98-
invalid: 0xffff,
99-
}),
84+
zoneType: ZCLDataTypes.enum16(ZONE_TYPE_VALUES),
10085
manufacturerCode: ZCLDataTypes.uint16,
10186
},
10287
},

test/iasZone.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ describe('IAS Zone', function() {
1919
});
2020

2121
node.endpoints[1].clusters.iasZone.onZoneEnrollRequest = data => {
22-
assert.strictEqual(data.zoneType, 'keyPad');
22+
assert.strictEqual(data.zoneType, 'keypad');
2323
assert.strictEqual(data.manufacturerCode, 4117);
2424
done();
2525
};

0 commit comments

Comments
 (0)