Skip to content

Commit

Permalink
Merge pull request #265 from MiSchroe:MiSchroe/issue264
Browse files Browse the repository at this point in the history
Warning message Product nn is not responding for nodes after the first 20 nodes
  • Loading branch information
MiSchroe authored Nov 20, 2024
2 parents ad2f92f + 43c60f9 commit 5ab0c11
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 27 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,10 @@ The values of the state provide multiple manipulation modes:
### __WORK IN PROGRESS__
-->
<!-- prettier-ignore -->
### __WORK IN PROGRESS__

- (Michael Schroeder) [#264](https://github.com/MiSchroe/ioBroker.klf200/issues/264) Fixed an issue during startup of the adapter if more than 20 nodes are present.

### 1.3.4 (2024-11-19)

- (Michael Schroeder) [#259](https://github.com/MiSchroe/ioBroker.klf200/issues/259) Fixed issues found by the adapter checker.
Expand Down
54 changes: 27 additions & 27 deletions src/klf200Adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -990,34 +990,34 @@ export class Klf200 extends utils.Adapter implements HasConnectionInterface, Has

private async checkResponsiveProducts(productIds: number[]): Promise<ResponsiveProductResult[]> {
const responsiveProducts: ResponsiveProductResult[] = [];
let sessionId = -1;
let handler: Disposable | undefined = undefined;
const handlerPromise = timeout(
new Promise<ResponsiveProductResult[]>((resolve, reject) => {
try {
handler = this._Connection?.on(
(event) => {
if (event instanceof GW_SESSION_FINISHED_NTF && event.SessionID === sessionId) {
handler?.dispose();
handler = undefined;
resolve(responsiveProducts.sort());
} else if (event instanceof GW_STATUS_REQUEST_NTF && event.SessionID === sessionId) {
responsiveProducts.push({
NodeID: event.NodeID,
FPs: event.ParameterData?.map((parameter) => parameter.ID) || [],
});
}
},
[GatewayCommand.GW_SESSION_FINISHED_NTF, GatewayCommand.GW_STATUS_REQUEST_NTF],
);
} catch (error) {
reject(error);
}
}),
30_000,
);
const chunkSize = 20;
for (let i = 0; i < Math.ceil(productIds.length / chunkSize); i++) {
let sessionId = -1;
let handler: Disposable | undefined = undefined;
const handlerPromise = timeout(
new Promise<ResponsiveProductResult[]>((resolve, reject) => {
try {
handler = this._Connection?.on(
(event) => {
if (event instanceof GW_SESSION_FINISHED_NTF && event.SessionID === sessionId) {
handler?.dispose();
handler = undefined;
resolve(responsiveProducts);
} else if (event instanceof GW_STATUS_REQUEST_NTF && event.SessionID === sessionId) {
responsiveProducts.push({
NodeID: event.NodeID,
FPs: event.ParameterData?.map((parameter) => parameter.ID) || [],
});
}
},
[GatewayCommand.GW_SESSION_FINISHED_NTF, GatewayCommand.GW_STATUS_REQUEST_NTF],
);
} catch (error) {
reject(error);
}
}),
30_000,
);
const statusRequestReq = new GW_STATUS_REQUEST_REQ(
productIds.slice(i * chunkSize, (i + 1) * chunkSize),
StatusType.RequestCurrentPosition,
Expand All @@ -1031,7 +1031,7 @@ export class Klf200 extends utils.Adapter implements HasConnectionInterface, Has
return Promise.reject(new Error(statusRequestCfm?.getError()));
}
}
return responsiveProducts;
return responsiveProducts.sort();
}

private async disposeOnConnectionClosed(): Promise<void> {
Expand Down
10 changes: 10 additions & 0 deletions test/integration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -606,6 +606,16 @@ tests.integration(path.join(__dirname, ".."), {
expect(sut).to.have.property("val", 0);
expect(sut).to.have.property("ack", true);
});

it("Should have limitation states for product 30", async function () {
const sut = await Promise.resolve(
getState(harness, `${harness.adapterName}.0.products.30.limitationMPMinRaw`),
);
expect(sut).not.to.be.undefined;
expect(sut).not.to.be.null;
expect(sut).to.be.an("object");
expect(sut).to.have.property("val");
});
});
});
},
Expand Down

0 comments on commit 5ab0c11

Please sign in to comment.