Skip to content

Commit

Permalink
tests: uses non ubisys attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
sjorge committed Apr 27, 2024
1 parent 21df43f commit 847e9a7
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 25 deletions.
20 changes: 10 additions & 10 deletions test/controller.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2894,7 +2894,7 @@ describe('Controller', () => {
const endpoint = device.getEndpoint(1);
mocksendZclFrameToEndpoint.mockClear();
await endpoint.configureReporting('hvacThermostat', [{
attribute: 'ubisysVacationMode',
attribute: 'viessmannWindowOpenInternal',
minimumReportInterval: 1,
maximumReportInterval: 10,
reportableChange: 1,
Expand All @@ -2904,10 +2904,10 @@ describe('Controller', () => {
expect(call[0]).toBe('0x129');
expect(call[1]).toBe(129);
expect(call[2]).toBe(1)
expect({...deepClone(call[3]), cluster: {}}).toStrictEqual({"cluster":{},"command":{"ID":6,"name":"configReport","parameters":[{"name":"direction","type":32},{"name":"attrId","type":33},{"conditions":[{"type":"directionEquals","value":0}],"name":"dataType","type":32},{"conditions":[{"type":"directionEquals","value":0}],"name":"minRepIntval","type":33},{"conditions":[{"type":"directionEquals","value":0}],"name":"maxRepIntval","type":33},{"conditions":[{"type":"directionEquals","value":0},{"type":"dataTypeValueTypeEquals","value":"ANALOG"}],"name":"repChange","type":1000},{"conditions":[{"type":"directionEquals","value":1}],"name":"timeout","type":33}],"response":7},"header":{"commandIdentifier":6,"frameControl":{"direction":0,"disableDefaultResponse":true,"frameType":0,"manufacturerSpecific":true,"reservedBits":0},"manufacturerCode":4338,"transactionSequenceNumber":11},"payload":[{"attrId":18,"dataType":16,"direction":0,"maxRepIntval":10,"minRepIntval":1,"repChange":1}]});
expect({...deepClone(call[3]), cluster: {}}).toStrictEqual({"cluster":{},"command":{"ID":6,"name":"configReport","parameters":[{"name":"direction","type":32},{"name":"attrId","type":33},{"conditions":[{"type":"directionEquals","value":0}],"name":"dataType","type":32},{"conditions":[{"type":"directionEquals","value":0}],"name":"minRepIntval","type":33},{"conditions":[{"type":"directionEquals","value":0}],"name":"maxRepIntval","type":33},{"conditions":[{"type":"directionEquals","value":0},{"type":"dataTypeValueTypeEquals","value":"ANALOG"}],"name":"repChange","type":1000},{"conditions":[{"type":"directionEquals","value":1}],"name":"timeout","type":33}],"response":7},"header":{"commandIdentifier":6,"frameControl":{"direction":0,"disableDefaultResponse":true,"frameType":0,"manufacturerSpecific":true,"reservedBits":0},"manufacturerCode":4641,"transactionSequenceNumber":11},"payload":[{"attrId":16384,"dataType":48,"direction":0,"maxRepIntval":10,"minRepIntval":1,"repChange":1}]});

expect(endpoint.configuredReportings.length).toBe(1);
expect({...endpoint.configuredReportings[0], cluster: undefined}).toStrictEqual({"attribute":{"ID":18,"type":16,"manufacturerCode":4338,"name":"ubisysVacationMode"},"minimumReportInterval":1,"maximumReportInterval":10,"reportableChange":1, "cluster": undefined});
expect({...endpoint.configuredReportings[0], cluster: undefined}).toStrictEqual({"attribute":{"ID":16384,"type":48,"manufacturerCode":4641,"name":"viessmannWindowOpenInternal"},"minimumReportInterval":1,"maximumReportInterval":10,"reportableChange":1, "cluster": undefined});
});

it('Endpoint configure reporting with manufacturer attribute should throw exception', async () => {
Expand All @@ -2927,7 +2927,7 @@ describe('Controller', () => {
reportableChange: 1,
},
{
attribute: 'ubisysRemoteTemperature',
attribute: 'viessmannWindowOpenInternal',
minimumReportInterval: 1,
maximumReportInterval: 10,
reportableChange: 1,
Expand Down Expand Up @@ -3301,13 +3301,13 @@ describe('Controller', () => {
const device = controller.getDeviceByIeeeAddr('0x129');
device._manufacturerID = 0x10f2;
const endpoint = device.getEndpoint(1);
await endpoint.write('hvacThermostat', {'ubisysDefaultOccupiedHeatingSetpoint': 1800});
await endpoint.write('hvacThermostat', {'viessmannWindowOpenInternal': 1});
expect(mocksendZclFrameToEndpoint).toBeCalledTimes(1);
const call = mocksendZclFrameToEndpoint.mock.calls[0];
expect(call[0]).toBe('0x129');
expect(call[1]).toBe(129);
expect(call[2]).toBe(1);
expect({...deepClone(call[3]), cluster: {}}).toStrictEqual({"header":{"frameControl":{"reservedBits":0,"frameType":0,"direction":0,"disableDefaultResponse":true,"manufacturerSpecific":true},"transactionSequenceNumber":11,"manufacturerCode":4338,"commandIdentifier":2},"payload":[{"attrId":17,"attrData":1800,"dataType":41}],"cluster":{},"command":{"ID":2,"name":"write","parameters":[{"name":"attrId","type":33},{"name":"dataType","type":32},{"name":"attrData","type":1000}],"response":4}});
expect({...deepClone(call[3]), cluster: {}}).toStrictEqual({"header":{"frameControl":{"reservedBits":0,"frameType":0,"direction":0,"disableDefaultResponse":true,"manufacturerSpecific":true},"transactionSequenceNumber":11,"manufacturerCode":4641,"commandIdentifier":2},"payload":[{"attrId":16384,"attrData":1,"dataType":48}],"cluster":{},"command":{"ID":2,"name":"write","parameters":[{"name":"attrId","type":33},{"name":"dataType","type":32},{"name":"attrData","type":1000}],"response":4}});
expect(call[4]).toBe(10000);
});

Expand Down Expand Up @@ -3348,7 +3348,7 @@ describe('Controller', () => {
device._manufacturerID = 0x10f2;
const endpoint = device.getEndpoint(1);
let error;
try {await endpoint.write('hvacThermostat', {'occupiedHeatingSetpoint': 2000, 'ubisysDefaultOccupiedHeatingSetpoint': 1800}) } catch (e) {error = e}
try {await endpoint.write('hvacThermostat', {'occupiedHeatingSetpoint': 2000, 'viessmannWindowOpenInternal': 1}) } catch (e) {error = e}
expect(error).toStrictEqual(new Error("Cannot have attributes with different manufacturerCode in single 'write' call"))
});

Expand Down Expand Up @@ -3454,13 +3454,13 @@ describe('Controller', () => {
const device = controller.getDeviceByIeeeAddr('0x129');
device._manufacturerID = 0x10f2;
const endpoint = device.getEndpoint(1);
await endpoint.read('hvacThermostat', ['ubisysDefaultOccupiedHeatingSetpoint']);
await endpoint.read('hvacThermostat', ['viessmannWindowOpenInternal']);
expect(mocksendZclFrameToEndpoint).toBeCalledTimes(1);
const call = mocksendZclFrameToEndpoint.mock.calls[0];
expect(call[0]).toBe('0x129');
expect(call[1]).toBe(129);
expect(call[2]).toBe(1);
expect({...deepClone(call[3]), cluster: {}}).toStrictEqual({"header":{"frameControl":{"reservedBits":0,"frameType":0,"direction":0,"disableDefaultResponse":true,"manufacturerSpecific":true},"transactionSequenceNumber":11,"manufacturerCode":4338,"commandIdentifier":0},"payload":[{"attrId":17}],"cluster":{},"command":{"ID":0,"name":"read","parameters":[{"name":"attrId","type":33}],"response":1}});
expect({...deepClone(call[3]), cluster: {}}).toStrictEqual({"header":{"frameControl":{"reservedBits":0,"frameType":0,"direction":0,"disableDefaultResponse":true,"manufacturerSpecific":true},"transactionSequenceNumber":11,"manufacturerCode":4641,"commandIdentifier":0},"payload":[{"attrId":16384}],"cluster":{},"command":{"ID":0,"name":"read","parameters":[{"name":"attrId","type":33}],"response":1}});
expect(call[4]).toBe(10000);
});

Expand All @@ -3472,7 +3472,7 @@ describe('Controller', () => {
device._manufacturerID = 0x10f2;
const endpoint = device.getEndpoint(1);
let error;
try { await endpoint.read('hvacThermostat', ['localTemp', 'ubisysRemoteTemperature']); } catch (e) { error = e };
try { await endpoint.read('hvacThermostat', ['localTemp', 'viessmannWindowOpenInternal']); } catch (e) { error = e };
expect(error).toStrictEqual(new Error("Cannot have attributes with different manufacturerCode in single 'read' call"))
});

Expand Down
30 changes: 15 additions & 15 deletions test/zcl.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -727,28 +727,28 @@ describe('Zcl', () => {
expect(frame.payload).toStrictEqual(payload);
});

it('ZclFrame with Ubisys (manufacturer specific) cluster create', () => {
const payload = [{attrId: 0x0000, status: 0, attrData: 1, dataType: 32}];
it('ZclFrame with Assa (manufacturer specific) cluster create', () => {
const payload = [{attrId: 0x0012, status: 0, attrData: 1, dataType: 32}];
const frame = Zcl.ZclFrame.create(
FrameType.GLOBAL, Direction.CLIENT_TO_SERVER, false, 0x10f2, 8, 'readRsp', 0xfc00, payload
FrameType.GLOBAL, Direction.CLIENT_TO_SERVER, false, 0x101D, 8, 'readRsp', 0xfc00, payload
);

expect(frame.cluster.name).toBe('manuSpecificUbisysDeviceSetup');
expect(frame.cluster.name).toBe('manuSpecificAssaDoorLock');
});

it('ZclFrame with Ubisys (manufacturer specific) cluster create with non Ubisys manufcode', () => {
const payload = [{attrId: 0x0000, status: 0, attrData: 1, dataType: 32}];
it('ZclFrame with Assa (manufacturer specific) cluster create with non Assa manufcode', () => {
const payload = [{attrId: 0x0012, status: 0, attrData: 1, dataType: 32}];
const frame = Zcl.ZclFrame.create(
FrameType.GLOBAL, Direction.CLIENT_TO_SERVER, false, 0x10f3, 8, 'readRsp', 0xfc00, payload
);

expect(frame.cluster.name).toBe('manuSpecificUbisysDeviceSetup');
expect(frame.cluster.name).toBe('manuSpecificAssaDoorLock');
});

it('ZclFrame with Ubisys (manufacturer specific) cluster fromBuffer', () => {
it('ZclFrame with Assa (manufacturer specific) cluster fromBuffer', () => {
const buffer = Buffer.from([0x04, 0xf2, 0x10, 0x08, 0x01, 0x00, 0x00, 0x00, 0x20, 0x01])
const frame = Zcl.ZclFrame.fromBuffer(0xfc00, Zcl.ZclHeader.fromBuffer(buffer), buffer);
expect(frame.cluster.name).toBe('manuSpecificUbisysDeviceSetup');
expect(frame.cluster.name).toBe('manuSpecificAssaDoorLock');
});

it('ZclFrame to buffer with reservered bits', () => {
Expand Down Expand Up @@ -1294,7 +1294,7 @@ describe('Zcl', () => {
it('Zcl utils get cluster without manufacturerCode', () => {
const cluster = Zcl.Utils.getCluster(0xfc00);
expect(cluster.ID).toBe(0xfc00);
expect(cluster.name).toBe('manuSpecificUbisysDeviceSetup');
expect(cluster.name).toBe('manuSpecificAssaDoorLock');
});

it('Zcl utils get cluster with manufacturerCode', () => {
Expand All @@ -1306,19 +1306,19 @@ describe('Zcl', () => {
it('Zcl utils get cluster manufacturerCode', () => {
const cluster = Zcl.Utils.getCluster(0xfc00, 0x10f2);
expect(cluster.ID).toBe(0xfc00);
expect(cluster.name).toBe('manuSpecificUbisysDeviceSetup');
expect(cluster.name).toBe('manuSpecificAssaDoorLock');
});

it('Zcl utils get cluster manufacturerCode wrong', () => {
const cluster = Zcl.Utils.getCluster(0xfc00, 123);
expect(cluster.ID).toBe(0xfc00);
expect(cluster.name).toBe('manuSpecificUbisysDeviceSetup');
expect(cluster.name).toBe('manuSpecificAssaDoorLock');
});

it('Zcl utils get cluster attributes manufacturerCode', () => {
const cluster = Zcl.Utils.getCluster('closuresWindowCovering', 0x10f2);
const attribute = cluster.getAttribute(0x1000);
expect(attribute).toStrictEqual({"ID": 4096, "manufacturerCode": 4338, "name": "ubisysTurnaroundGuardTime", "type": 32});
const cluster = Zcl.Utils.getCluster('closuresWindowCovering', 0x1021);
const attribute = cluster.getAttribute(0xf004);
expect(attribute).toStrictEqual({"ID": 0xf004, "manufacturerCode": 0x1021, "name": "stepPositionTilt", "type": 48});
});

it('Zcl utils get cluster attributes manufacturerCode wrong', () => {
Expand Down

0 comments on commit 847e9a7

Please sign in to comment.