Skip to content

Commit

Permalink
Fix exception when retrieving configured reportings for custom attrib…
Browse files Browse the repository at this point in the history
  • Loading branch information
Koenkk committed Jan 10, 2021
1 parent 54e9e4b commit 71ad17e
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
16 changes: 14 additions & 2 deletions src/controller/model/endpoint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,21 @@ class Endpoint extends Entity {
get configuredReportings(): ConfiguredReporting[] {
return this._configuredReportings.map((entry) => {
const cluster = Zcl.Utils.getCluster(entry.cluster);
let attribute : Zcl.TsType.Attribute;

if (cluster.hasAttribute(entry.attrId)) {
attribute = cluster.getAttribute(entry.attrId);
} else {
attribute = {
ID: entry.attrId,
name: undefined,
type: undefined,
manufacturerCode: undefined
};
}

return {
cluster,
attribute: cluster.getAttribute(entry.attrId),
cluster, attribute,
minimumReportInterval: entry.minRepIntval,
maximumReportInterval: entry.maxRepIntval,
reportableChange: entry.repChange,
Expand Down
5 changes: 5 additions & 0 deletions test/controller.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2673,6 +2673,11 @@ describe('Controller', () => {
expect(call[2]).toBe(1);
expect(deepClone(call[3])).toStrictEqual( {"Header":{"frameControl":{"reservedBits": 0,"frameType":0,"direction":0,"disableDefaultResponse":true,"manufacturerSpecific":false},"transactionSequenceNumber":11,"manufacturerCode":null,"commandIdentifier":6},"Payload":[{"direction":0,"attrId":16387,"dataType":41,"minRepIntval":0,"maxRepIntval":3600,"repChange":25}],"Cluster":getCluster(513)});
expect(call[4]).toBe(10000);

const hvacThermostat = Zcl.Utils.getCluster('hvacThermostat');
expect(deepClone(endpoint.configuredReportings)).toStrictEqual([
{cluster: deepClone(hvacThermostat), attribute: {ID: 0x4003}, minimumReportInterval: 0, maximumReportInterval: 3600, reportableChange: 25}
]);
});

it('Remove endpoint from all groups', async () => {
Expand Down

0 comments on commit 71ad17e

Please sign in to comment.