Skip to content

Commit

Permalink
V8
Browse files Browse the repository at this point in the history
  • Loading branch information
Luligu committed Jul 2, 2024
1 parent 502f002 commit 5e193c2
Show file tree
Hide file tree
Showing 4 changed files with 111 additions and 91 deletions.
110 changes: 55 additions & 55 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@
"deepCleanRebuild": "npm run deepClean && npm install && npm run build && npm ls rimraf inflight glob",
"prepublishOnly": "npm run wtf:uninstall && npm uninstall matter-history && npm install matter-history && npm run lint && npm run cleanBuild",
"checkDependencies": "npx npm-check-updates",
"updateDepend encies": "npx npm-check-updates -u && npm install & npm run cleanBuild",
"updateDependencies": "npx npm-check-updates -u && npm install & npm run cleanBuild",
"updateMatter:latest": "npm run deepClean && npm install @project-chip/matter-node.js@latest && npm install && npm run build",
"updateMatter:dev": "npm run deepClean && npm install @project-chip/matter-node.js@dev && npm install && npm run build",
"wtf:install": "npm install wtfnode && npm install --save-dev @types/wtfnode",
Expand Down Expand Up @@ -132,7 +132,7 @@
"prettier": "^3.3.2",
"rimraf": "^5.0.7",
"ts-jest": "^29.1.5",
"typescript": "^5.5.2",
"typescript-eslint": "^7.14.1"
"typescript": "^5.5.3",
"typescript-eslint": "^7.15.0"
}
}
37 changes: 15 additions & 22 deletions src/matterbridgeDeviceV8.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ import { AtLeastOne, MakeMandatory, NamedHandler } from '@project-chip/matter-no
import { ClusterId, EndpointNumber, VendorId } from '@project-chip/matter-node.js/datatype';

// Matterbridge imports
import { AnsiLogger, CYAN, TimestampFormat, db, hk, rs, zb } from 'node-ansi-logger';
import { AnsiLogger, CYAN, TimestampFormat, db, debugStringify, hk, rs, zb } from 'node-ansi-logger';
import { BooleanStateConfiguration, BooleanStateConfigurationCluster } from './cluster/BooleanStateConfigurationCluster.js';
import { PowerTopology, PowerTopologyCluster } from './cluster/PowerTopologyCluster.js';
import { ElectricalPowerMeasurement, ElectricalPowerMeasurementCluster } from './cluster/ElectricalPowerMeasurementCluster.js';
Expand Down Expand Up @@ -254,26 +254,17 @@ export class MatterbridgeDeviceV8 extends Endpoint {
*/
addDeviceType(deviceType: DeviceTypeDefinition) {
if (!this.deviceTypes.has(deviceType.code)) {
// Keep the Matterbridge internal map
this.log.debug(`addDeviceType: ${zb}${deviceType.code}${db}-${zb}${deviceType.name}${db}`);
/*
this.lifecycle.ready.on(() => {
this.act((agent) =>
agent.get(DescriptorServer).addDeviceTypes({
deviceType: deviceType.code,
revision: deviceType.revision,
}),
);
});
*/
/*
this.act((agent) =>
agent.get(DescriptorServer).addDeviceTypes({
deviceType: deviceType.code,
revision: deviceType.revision,
}),
);
*/
this.deviceTypes.set(deviceType.code, deviceType);
// Add the device types to the descriptor server
const deviceTypeList = Array.from(this.deviceTypes.values()).map((dt) => ({
deviceType: dt.code,
revision: dt.revision,
}));
this.behaviors.require(DescriptorServer, {
deviceTypeList,
});
}
}

Expand All @@ -286,7 +277,6 @@ export class MatterbridgeDeviceV8 extends Endpoint {
addDeviceTypeWithClusterServer(deviceTypes: AtLeastOne<DeviceTypeDefinition>, includeServerList: ClusterId[]) {
this.log.debug('addDeviceTypeWithClusterServer:');
deviceTypes.forEach((deviceType) => {
this.addDeviceType(deviceType);
this.log.debug(`- with deviceType: ${zb}${deviceType.code}${db}-${zb}${deviceType.name}${db}`);
deviceType.requiredServerClusters.forEach((clusterId) => {
if (!includeServerList.includes(clusterId)) includeServerList.push(clusterId);
Expand All @@ -295,6 +285,9 @@ export class MatterbridgeDeviceV8 extends Endpoint {
includeServerList.forEach((clusterId) => {
this.log.debug(`- with cluster: ${hk}${clusterId}${db}-${hk}${getClusterNameById(clusterId)}${db}`);
});
deviceTypes.forEach((deviceType) => {
this.addDeviceType(deviceType);
});
this.addClusterServerFromList(this, includeServerList);
}

Expand Down Expand Up @@ -343,12 +336,12 @@ export class MatterbridgeDeviceV8 extends Endpoint {
const options: Record<string, any> = {};
for (const attribute of Object.values(cluster.attributes)) {
if ((attribute as AttributeServer<A>).id < 0xfff0) {
// No issue here for value, as cluster is just a definition without getter setter
// No issue here for value, as cluster here is just a definition without getter setter
// eslint-disable-next-line @typescript-eslint/no-explicit-any
options[(attribute as AttributeServer<A>).name] = (attribute as any).value;
}
}
this.log.debug(`addClusterServer: ${cluster.name} with options:${rs}\n`, options);
this.log.debug(`addClusterServer: ${hk}${cluster.id}${db}-${hk}${getClusterNameById(cluster.id)}${db} with options: ${debugStringify(options)}${rs}`);
const behavior = MatterbridgeDeviceV8.getBehaviourTypeFromClusterServerId(cluster.id);
this.behaviors.require(behavior, options);
this.clusterServers.set(cluster.id, cluster);
Expand Down
Loading

0 comments on commit 5e193c2

Please sign in to comment.