Skip to content

Commit

Permalink
fix: Fix wrong manufacturer code when configuring reporting for manuf…
Browse files Browse the repository at this point in the history
…acturer specific attribute (#844)

* fix: add test for ep.configureReporting with manufacturerCode

When defining a manufacturerCode in the ZCL cluster definition, it should be used when configuring reporting, even when not specified.

* fix: endpoint.configureReporting should use manufacturerCode when defined

Fixes #843

* Update endpoint.ts

* Update endpoint.ts

---------

Co-authored-by: Koen Kanters <koenkanters94@gmail.com>
  • Loading branch information
sjorge and Koenkk authored Dec 27, 2023
1 parent 9d122f3 commit 9951d44
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/controller/model/endpoint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -633,6 +633,9 @@ class Endpoint extends Entity {
const attribute = cluster.getAttribute(item.attribute);
dataType = attribute.type;
attrId = attribute.ID;
if (attribute.hasOwnProperty('manufacturerCode')) {
options.manufacturerCode = attribute.manufacturerCode;
}
}
}

Expand Down
24 changes: 24 additions & 0 deletions test/controller.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2733,6 +2733,30 @@ describe('Controller', () => {
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 for manufacturer specific attribute from definition', async () => {
await controller.start();
await mockAdapterEvents['deviceJoined']({networkAddress: 129, ieeeAddr: '0x129'});
const device = controller.getDeviceByIeeeAddr('0x129');
device._manufacturerID = 0x10f2;
const endpoint = device.getEndpoint(1);
mocksendZclFrameToEndpoint.mockClear();
await endpoint.configureReporting('hvacThermostat', [{
attribute: 'ubisysVacationMode',
minimumReportInterval: 1,
maximumReportInterval: 10,
reportableChange: 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({"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(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});
});

it('Save endpoint configure reporting', async () => {
await controller.start();
await mockAdapterEvents['deviceJoined']({networkAddress: 129, ieeeAddr: '0x129'});
Expand Down

0 comments on commit 9951d44

Please sign in to comment.