Skip to content

Commit

Permalink
Merge pull request #38 from Luligu/dev
Browse files Browse the repository at this point in the history
Release 1.2.20
  • Loading branch information
Luligu authored Jun 3, 2024
2 parents c8b21f7 + 13d9cdb commit 6fce354
Show file tree
Hide file tree
Showing 8 changed files with 534 additions and 37 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/docker-buildx-main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ jobs:
--platform linux/amd64,linux/arm64,linux/arm/v7 \
-f docker/Dockerfile.main \
-t luligu/matterbridge:latest \
-t luligu/matterbridge:1.2.19 \
-t luligu/matterbridge:1.2.20 \
--push .
docker manifest inspect luligu/matterbridge:latest
timeout-minutes: 60
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,19 @@

All notable changes to this project will be documented in this file.

## [1.2.20] - 2024-06-03

### Changed
- [matter.js]: Update to @project-chip/matter-node.js v. 0.9.1
- [matterbridge]: Updated dependencies

### Fixed
- [matterbridge]: Log level of Plugin already configured is now info

<a href="https://www.buymeacoffee.com/luligugithub">
<img src="./yellow-button.png" alt="Buy me a coffee" width="120">
</a>

## [1.2.19] - 2024-06-01

### Breaking change on Matterbridge start!
Expand Down
89 changes: 60 additions & 29 deletions package-lock.json

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

10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "matterbridge",
"version": "1.2.19",
"version": "1.2.20",
"description": "Matterbridge plugin manager for Matter",
"author": "https://github.com/Luligu",
"license": "Apache-2.0",
Expand Down Expand Up @@ -80,20 +80,20 @@
"devDependencies": {
"@tsconfig/node-lts": "^20.1.3",
"@types/express": "^4.17.21",
"@types/node": "^20.12.13",
"@types/node": "^20.14.0",
"@types/ws": "^8.5.10",
"@typescript-eslint/eslint-plugin": "^7.11.0",
"@typescript-eslint/parser": "^7.11.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-prettier": "^5.1.3",
"prettier": "^3.2.5",
"prettier": "^3.3.0",
"typescript": "^5.4.5"
},
"dependencies": {
"@project-chip/matter-node.js": "^0.9.0",
"@project-chip/matter-node.js": "^0.9.1",
"body-parser": "^1.20.2",
"express": "^4.19.2",
"matter-history": "^1.1.0",
"matter-history": "^1.1.1",
"node-ansi-logger": "^1.9.5",
"node-persist-manager": "^1.0.7",
"ws": "^8.17.0"
Expand Down
Binary file added screenshot/Screenshot HA.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions src/matterbridge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1000,7 +1000,7 @@ export class Matterbridge extends EventEmitter {
Matterbridge.instance = undefined;
this.emit('shutdown');
}
}, 2 * 1000);
}, 2 * 1000); // From 2 to 5 seconds
}, 3 * 1000);
}
}
Expand Down Expand Up @@ -1464,7 +1464,7 @@ export class Matterbridge extends EventEmitter {
return Promise.reject(new Error(`Plugin ${plg}${plugin.name}${er} not loaded or not started or not platform`));
}
if (plugin.configured) {
this.log.error(`Plugin ${plg}${plugin.name}${er} already configured`);
this.log.info(`Plugin ${plg}${plugin.name}${nf} already configured`);
return Promise.resolve();
}
this.log.info(`Configuring plugin ${plg}${plugin.name}${db} type ${typ}${plugin.type}${db}`);
Expand Down
87 changes: 87 additions & 0 deletions src/matterbridgeDeviceV8.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
/* eslint-disable @typescript-eslint/no-unused-vars */
// New API imports
import { Endpoint, EndpointServer } from '@project-chip/matter.js/endpoint';
import { OnOffLightDevice } from '@project-chip/matter.js/devices/OnOffLightDevice';
import { AggregatorEndpoint } from '@project-chip/matter.js/endpoints/AggregatorEndpoint';
import { BridgedNodeEndpoint } from '@project-chip/matter.js/endpoints/BridgedNodeEndpoint';

// Old API imports
import { DeviceTypeDefinition, DeviceTypes, EndpointOptions } from '@project-chip/matter-node.js/device';

// Matterbridge imports
import { AnsiLogger, TimestampFormat, db, hk, zb } from 'node-ansi-logger';
import { AtLeastOne } from '@project-chip/matter-node.js/util';
import { ClusterId } from '@project-chip/matter-node.js/datatype';
import { getClusterNameById } from '@project-chip/matter-node.js/cluster';

export class MatterbridgeDeviceV8 {
public static bridgeMode = '';
log: AnsiLogger;
serialNumber: string | undefined = undefined;
deviceName: string | undefined = undefined;
uniqueId: string | undefined = undefined;

deviceTypes: DeviceTypeDefinition[];

/**
* Represents a Matterbridge device.
* @constructor
* @param {DeviceTypeDefinition} definition - The definition of the device.
* @param {EndpointOptions} [options={}] - The options for the device.
*/
constructor(definition: DeviceTypeDefinition, options: EndpointOptions = {}) {
this.log = new AnsiLogger({ logName: 'MatterbridgeDevice', logTimestampFormat: TimestampFormat.TIME_MILLIS, logDebug: true });
this.deviceTypes = [definition];
}

/**
* Loads an instance of the MatterbridgeDevice class.
*
* @param {DeviceTypeDefinition} definition - The DeviceTypeDefinition of the device.
* @returns MatterbridgeDevice instance.
*/
static async loadInstance(definition: DeviceTypeDefinition, options: EndpointOptions) {
return new MatterbridgeDeviceV8(definition, options);
}

/**
* Adds a device type to the list of device types.
* If the device type is not already present in the list, it will be added.
*
* @param {DeviceTypeDefinition} deviceType - The device type to add.
*/
addDeviceType(deviceType: DeviceTypeDefinition) {
if (!this.deviceTypes.includes(deviceType)) {
this.deviceTypes.push(deviceType);
}
}

/**
* Adds one or more device types with the required cluster servers and the specified cluster servers.
*
* @param {AtLeastOne<DeviceTypeDefinition>} deviceTypes - The device types to add.
* @param {ClusterId[]} includeServerList - The list of cluster IDs to include.
*/
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);
});
});
includeServerList.forEach((clusterId) => {
this.log.debug(`- with cluster: ${hk}${clusterId}${db}-${hk}${getClusterNameById(clusterId)}${db}`);
});
// this.addClusterServerFromList(this, includeServerList);
}

getBridgedNodeEndpointV8() {
// New API
const endpoint = new Endpoint(BridgedNodeEndpoint, { id: 'MatterbridgeDevice' });
const child = new Endpoint(OnOffLightDevice, { id: 'onoff' });
endpoint.add(child);
return endpoint;
}
}
Loading

0 comments on commit 6fce354

Please sign in to comment.