Closed antonio-gabriele closed 11 months ago
Hm ... I think i need more from your code to see potential issues, also please check that allyour imports are correct!
I can not reproduce this error locally in my system. I testwise added that line to Onoffdevice ... no error.
Definition of TemperatureMeasurement.Cluster is different from LevelControl.Cluster and OnOff.Cluster.
in OnOff and LevelControl export const Cluster = ClusterFactory.Extensible(
...
in TemperatureMeasurement export const Cluster = ClusterFactory.Definition(
...
ClusterServer method go in error with ClusterFactory.Definition.
Yes and this is because this cluster do not have features, thats all correct ... can you give me a full file please to reproduce this? As said I can not reproduce this typing error you get
This is:
import {
ClusterServer,
ClusterServerHandlers,
Identify,
LevelControl,
OnOff,
TemperatureMeasurement,
createDefaultGroupsClusterServer,
createDefaultIdentifyClusterServer,
createDefaultScenesClusterServer
} from "@project-chip/matter-node.js/cluster";
import { extendPublicHandlerMethods } from "@project-chip/matter-node.js/util";
import { Aggregator, Device, DeviceTypeDefinition, OnOffLightDevice, WrapCommandHandler } from "@project-chip/matter-node.js/device";
type BaseDeviceCommands = {
identify: ClusterServerHandlers<typeof Identify.Cluster>["identify"];
};
export class AbstractionOfDevice extends extendPublicHandlerMethods<typeof Device, BaseDeviceCommands>(Device) {
public name: string;
public uniqueId: string;
constructor(name: string, deviceTypeDefinition: DeviceTypeDefinition, uniqueId: string = null) {
super(deviceTypeDefinition);
this.name = name;
this.uniqueId = uniqueId ?? name.replaceAll(" ", "_").toLocaleLowerCase();;
this.addClusterServer(
createDefaultIdentifyClusterServer({
identify: async data => await this._executeHandler("identify", data),
}),
);
this.addClusterServer(createDefaultGroupsClusterServer());
this.addClusterServer(createDefaultScenesClusterServer());
}
addOnOffServer(onOffClusterHandler: ClusterServerHandlers<typeof OnOff.Base>) {
this.addClusterServer(
ClusterServer(OnOff.Cluster,
{
onOff: false,
},
WrapCommandHandler(onOffClusterHandler, this.commandHandler)));
}
addLevelControlServer(levelControlClusterHandler: ClusterServerHandlers<typeof LevelControl.Base>) {
this.addClusterServer(
ClusterServer(LevelControl.Cluster,
{
currentLevel: 0,
options: { executeIfOff: true, coupleColorTempToLevel: true },
onLevel: 0
},
WrapCommandHandler(levelControlClusterHandler, this.commandHandler)));
}
addTemperatureMeasurementServer() {
this.addClusterServer(
ClusterServer(TemperatureMeasurement.Cluster,
{
currentLevel: 0,
options: { executeIfOff: true, coupleColorTempToLevel: true },
onLevel: 0
}, this.commandHandler));
}
addBridgedDevice(aggregator: Aggregator) {
aggregator.addBridgedDevice(this, {
nodeLabel: this.name,
productName: this.name,
productLabel: this.name,
serialNumber: this.uniqueId,
reachable: true,
});
}
}
Ok, there are several typing issues in this code ...
And then I get mainly this issue
If I paste in your TemperatureCluster code from above I get no error there ...
tsconfig.json error. FYI correct version is:
{
"compilerOptions": {
"composite": true,
"esModuleInterop": true,
"incremental": true,
"target": "es2018",
"module": "node16",
"lib": ["ES2021"],
"moduleResolution": "node16",
"preserveConstEnums": true,
"sourceMap": true,
"declarationMap": true,
"forceConsistentCasingInFileNames": true,
"noImplicitAny": true,
"noImplicitOverride": true,
"noUnusedParameters": true,
"noUnusedLocals": true,
"strict": true,
"outDir": "../dist/esm",
"types": ["node"]
}
}
I got this error:
on this line:
This line works well: