Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,16 @@ Make sure to take a look at the API documentation: [https://athombv.github.io/no

## Breaking changes

v3.0.0

- **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.
- `cabonMonoxideSensor` -> `carbonMonoxideSensor` (typo fix)
- `keyfob` -> `keyFob` (spec says "Key fob" - two words)
- `standard` -> `standardCIE` (in `zoneEnrollRequest`)
- `invalid` -> `invalidZoneType` (in `zoneEnrollRequest`)
- `keyPad` -> `keypad` (in `zoneEnrollRequest`, spec says "Keypad" - one word)
- Added missing `doorWindowHandle` (0x0016) zone type from spec

v2.0.0

- Changed `Cluster.readAttributes` signature, attributes must now be specified as an array of strings.
Expand Down
4 changes: 2 additions & 2 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,7 @@ export interface IASWDCluster extends ZCLNodeCluster {

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

Expand Down
57 changes: 21 additions & 36 deletions lib/clusters/iasZone.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,25 @@ const { ZCLDataTypes } = require('../zclTypes');

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

const ZONE_TYPE_VALUES = {
standardCIE: 0x0000,
motionSensor: 0x000d,
contactSwitch: 0x0015,
doorWindowHandle: 0x0016,
fireSensor: 0x0028,
waterSensor: 0x002a,
carbonMonoxideSensor: 0x002b,
personalEmergencyDevice: 0x002c,
vibrationMovementSensor: 0x002d,
remoteControl: 0x010f,
keyFob: 0x0115,
keypad: 0x021d,
standardWarningDevice: 0x0225,
glassBreakSensor: 0x0226,
securityRepeater: 0x0229,
invalidZoneType: 0xffff,
};

const ATTRIBUTES = {
zoneState: {
id: 0,
Expand All @@ -15,24 +34,7 @@ const ATTRIBUTES = {
},
zoneType: {
id: 1,
// Note: enum keys differ from zoneEnrollRequest.zoneType but can't be changed without breaking
type: ZCLDataTypes.enum16({
standardCIE: 0,
motionSensor: 13,
contactSwitch: 21,
fireSensor: 40,
waterSensor: 42,
cabonMonoxideSensor: 43,
personalEmergencyDevice: 44,
vibrationMovementSensor: 45,
remoteControl: 271,
keyfob: 277,
keypad: 541,
standardWarningDevice: 549,
glassBreakSensor: 550,
securityRepeater: 553,
invalidZoneType: 65535,
}),
type: ZCLDataTypes.enum16(ZONE_TYPE_VALUES),
},
zoneStatus: {
id: 2,
Expand Down Expand Up @@ -79,24 +81,7 @@ const COMMANDS = {
// Add direction property as "initiateNormalOperationMode" has same command id.
direction: Cluster.DIRECTION_SERVER_TO_CLIENT,
args: {
// Note: enum keys differ from the zoneType attribute but can't be changed without breaking
zoneType: ZCLDataTypes.enum16({
standard: 0x0000,
motionSensor: 0x000d,
contactSwitch: 0x0015,
fireSensor: 0x0028,
waterSensor: 0x002a,
carbonMonoxideSensor: 0x002b,
personalEmergencyDevice: 0x002c,
vibrationMovementSensor: 0x002d,
remoteControl: 0x010f,
keyFob: 0x0115,
keyPad: 0x021d,
standardWarningDevice: 0x0225,
glassBreakSensor: 0x0226,
securityRepeater: 0x0229,
invalid: 0xffff,
}),
zoneType: ZCLDataTypes.enum16(ZONE_TYPE_VALUES),
manufacturerCode: ZCLDataTypes.uint16,
},
},
Expand Down
2 changes: 1 addition & 1 deletion test/iasZone.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ describe('IAS Zone', function() {
});

node.endpoints[1].clusters.iasZone.onZoneEnrollRequest = data => {
assert.strictEqual(data.zoneType, 'keyPad');
assert.strictEqual(data.zoneType, 'keypad');
assert.strictEqual(data.manufacturerCode, 4117);
done();
};
Expand Down
Loading