matterbridge-example-dynamic-platform 1.0.0 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/.eslintrc.json CHANGED
@@ -1,4 +1,5 @@
1
1
  {
2
+ "ignorePatterns":["dist/", "node_modules/"],
2
3
  "plugins": [
3
4
  "@typescript-eslint",
4
5
  "@stylistic",
@@ -22,12 +23,12 @@
22
23
  ],
23
24
  "rules": {
24
25
  "prettier/prettier": ["error"],
25
- "indent": ["error", 2],
26
- "max-len": ["warn", 180],
26
+ "indent": ["error", 2, { "SwitchCase": 1 }],
27
+ "max-len": ["warn", 200],
27
28
  "no-console": ["warn"],
28
29
  "quotes": ["error", "single", { "avoidEscape": true, "allowTemplateLiterals": false }],
29
30
  "comma-spacing": ["error", { "before": false, "after": true }],
30
- "space-before-function-paren": ["error", { "anonymous": "never", "named": "never", "asyncArrow": "always" }],
31
+ "space-before-function-paren": ["error", { "anonymous": "always", "named": "never", "asyncArrow": "always" }],
31
32
  "keyword-spacing": ["error", { "before": true, "after": true }],
32
33
  "no-multi-spaces": "error",
33
34
  "object-curly-spacing": ["error", "always"],
@@ -40,6 +41,6 @@
40
41
  "after": true
41
42
  }
42
43
  }
43
- }]
44
+ }]
44
45
  }
45
46
  }
package/.prettierrc.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "printWidth": 180,
2
+ "printWidth": 200,
3
3
  "semi": true,
4
4
  "tabWidth": 2,
5
5
  "useTabs": false,
package/README.md CHANGED
@@ -1,2 +1,13 @@
1
- # Matterbridge
2
- Matterbridge dynamic platform example plugin
1
+ # <img src="https://github.com/Luligu/matterbridge/blob/main/frontend/public/matterbridge%2064x64.png" alt="Matterbridge Logo" width="64px" height="64px">&nbsp;&nbsp;&nbsp;Matterbridge dynamic platform example plugin
2
+
3
+ [![npm version](https://img.shields.io/npm/v/matterbridge-example-dynamic-platform.svg)](https://www.npmjs.com/package/matterbridge-example-dynamic-platform)
4
+ [![npm downloads](https://img.shields.io/npm/dt/matterbridge-example-dynamic-platform.svg)](https://www.npmjs.com/package/matterbridge-example-dynamic-platform)
5
+
6
+ [![power by](https://img.shields.io/badge/powered%20by-matterbridge-blue)](https://www.npmjs.com/package/matterbridge)
7
+ [![power by](https://img.shields.io/badge/powered%20by-matter--history-blue)](https://www.npmjs.com/package/matter-history)
8
+ [![power by](https://img.shields.io/badge/powered%20by-node--ansi--logger-blue)](https://www.npmjs.com/package/node-ansi-logger)
9
+ [![power by](https://img.shields.io/badge/powered%20by-node--persist--manager-blue)](https://www.npmjs.com/package/node-persist-manager)
10
+
11
+ ---
12
+
13
+ Matterbridge dynamic platform example plugin is a template to develop your own plugin using the dynamic platform.
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { Matterbridge } from '../../matterbridge/dist/index.js';
1
+ import { Matterbridge } from 'matterbridge';
2
2
  import { AnsiLogger } from 'node-ansi-logger';
3
3
  import { ExampleMatterbridgeDynamicPlatform } from './platform.js';
4
4
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,YAAY,EAAE,MAAM,kCAAkC,CAAC;AAChE,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,kCAAkC,EAAE,MAAM,eAAe,CAAC;AAEnE;;;;;GAKG;AACH,MAAM,CAAC,OAAO,UAAU,gBAAgB,CAAC,YAAY,EAAE,YAAY,EAAE,GAAG,EAAE,UAAU,sCAgBnF"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,kCAAkC,EAAE,MAAM,eAAe,CAAC;AAEnE;;;;;GAKG;AACH,MAAM,CAAC,OAAO,UAAU,gBAAgB,CAAC,YAAY,EAAE,YAAY,EAAE,GAAG,EAAE,UAAU,sCAEnF"}
package/dist/index.js CHANGED
@@ -1,6 +1,3 @@
1
- import { MatterServer } from '@project-chip/matter-node.js';
2
- import { Format, Level, Logger } from '@project-chip/matter-node.js/log';
3
- import { StorageBackendJsonFile, StorageManager } from '@project-chip/matter-node.js/storage';
4
1
  import { ExampleMatterbridgeDynamicPlatform } from './platform.js';
5
2
  /**
6
3
  * This is the standard interface for MatterBridge plugins.
@@ -9,16 +6,6 @@ import { ExampleMatterbridgeDynamicPlatform } from './platform.js';
9
6
  * @param matterbridge - An instance of MatterBridge
10
7
  */
11
8
  export default function initializePlugin(matterbridge, log) {
12
- // set matter.js logger level and format
13
- Logger.defaultLogLevel = Level.DEBUG;
14
- Logger.format = Format.ANSI;
15
- // Do nothing just load @project-chip/matter-node.js for the Time Crypto Net Node variant
16
- const storageJson = new StorageBackendJsonFile('matterbridge-example');
17
- const storageManager = new StorageManager(storageJson);
18
- new MatterServer(storageManager);
19
- log.info('Matterbridge dynamic platform plugin example is loading...');
20
- const platform = new ExampleMatterbridgeDynamicPlatform(matterbridge, log);
21
- log.info('Matterbridge dynamic platform plugin example initialized successfully!');
22
- return platform;
9
+ return new ExampleMatterbridgeDynamicPlatform(matterbridge, log);
23
10
  }
24
11
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAC5D,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,kCAAkC,CAAC;AACzE,OAAO,EAAE,sBAAsB,EAAE,cAAc,EAAE,MAAM,sCAAsC,CAAC;AAI9F,OAAO,EAAE,kCAAkC,EAAE,MAAM,eAAe,CAAC;AAEnE;;;;;GAKG;AACH,MAAM,CAAC,OAAO,UAAU,gBAAgB,CAAC,YAA0B,EAAE,GAAe;IAClF,wCAAwC;IACxC,MAAM,CAAC,eAAe,GAAG,KAAK,CAAC,KAAK,CAAC;IACrC,MAAM,CAAC,MAAM,GAAG,MAAM,CAAC,IAAI,CAAC;IAE5B,yFAAyF;IACzF,MAAM,WAAW,GAAG,IAAI,sBAAsB,CAAC,sBAAsB,CAAC,CAAC;IACvE,MAAM,cAAc,GAAG,IAAI,cAAc,CAAC,WAAW,CAAC,CAAC;IACvD,IAAI,YAAY,CAAC,cAAc,CAAC,CAAC;IAEjC,GAAG,CAAC,IAAI,CAAC,4DAA4D,CAAC,CAAC;IAEvE,MAAM,QAAQ,GAAG,IAAI,kCAAkC,CAAC,YAAY,EAAE,GAAG,CAAC,CAAC;IAE3E,GAAG,CAAC,IAAI,CAAC,wEAAwE,CAAC,CAAC;IACnF,OAAO,QAAQ,CAAC;AAClB,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,kCAAkC,EAAE,MAAM,eAAe,CAAC;AAEnE;;;;;GAKG;AACH,MAAM,CAAC,OAAO,UAAU,gBAAgB,CAAC,YAA0B,EAAE,GAAe;IAClF,OAAO,IAAI,kCAAkC,CAAC,YAAY,EAAE,GAAG,CAAC,CAAC;AACnE,CAAC"}
@@ -1,8 +1,11 @@
1
- import { Matterbridge, MatterbridgeDynamicPlatform } from '../../matterbridge/dist/index.js';
1
+ import { Matterbridge, MatterbridgeDevice, MatterbridgeDynamicPlatform } from 'matterbridge';
2
2
  import { AnsiLogger } from 'node-ansi-logger';
3
3
  export declare class ExampleMatterbridgeDynamicPlatform extends MatterbridgeDynamicPlatform {
4
+ cover: MatterbridgeDevice | undefined;
5
+ light: MatterbridgeDevice | undefined;
4
6
  constructor(matterbridge: Matterbridge, log: AnsiLogger);
5
- onStartDynamicPlatform(): void;
6
- onShutdown(): void;
7
+ onStart(reason?: string): Promise<void>;
8
+ onConfigure(): Promise<void>;
9
+ onShutdown(reason?: string): Promise<void>;
7
10
  }
8
11
  //# sourceMappingURL=platform.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"platform.d.ts","sourceRoot":"","sources":["../src/platform.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAsB,2BAA2B,EAAE,MAAM,kCAAkC,CAAC;AACjH,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE9C,qBAAa,kCAAmC,SAAQ,2BAA2B;gBACrE,YAAY,EAAE,YAAY,EAAE,GAAG,EAAE,UAAU;IAI9C,sBAAsB,IAAI,IAAI;IAuC9B,UAAU,IAAI,IAAI;CAG5B"}
1
+ {"version":3,"file":"platform.d.ts","sourceRoot":"","sources":["../src/platform.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,kBAAkB,EAAE,2BAA2B,EAAE,MAAM,cAAc,CAAC;AAC7F,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE9C,qBAAa,kCAAmC,SAAQ,2BAA2B;IACjF,KAAK,EAAE,kBAAkB,GAAG,SAAS,CAAC;IACtC,KAAK,EAAE,kBAAkB,GAAG,SAAS,CAAC;gBAE1B,YAAY,EAAE,YAAY,EAAE,GAAG,EAAE,UAAU;IAIxC,OAAO,CAAC,MAAM,CAAC,EAAE,MAAM;IAsCvB,WAAW;IAoDX,UAAU,CAAC,MAAM,CAAC,EAAE,MAAM;CAG1C"}
package/dist/platform.js CHANGED
@@ -1,45 +1,94 @@
1
- import { DeviceTypes } from '@project-chip/matter-node.js/device';
2
- import { MatterbridgeDevice, MatterbridgeDynamicPlatform } from '../../matterbridge/dist/index.js';
1
+ import { DeviceTypes, OnOffCluster, WindowCovering, WindowCoveringCluster } from 'matterbridge';
2
+ import { MatterbridgeDevice, MatterbridgeDynamicPlatform } from 'matterbridge';
3
3
  export class ExampleMatterbridgeDynamicPlatform extends MatterbridgeDynamicPlatform {
4
+ cover;
5
+ light;
4
6
  constructor(matterbridge, log) {
5
7
  super(matterbridge, log);
6
8
  }
7
- onStartDynamicPlatform() {
8
- this.log.info('onStartDynamicPlatform called');
9
- const cover = new MatterbridgeDevice(DeviceTypes.WINDOW_COVERING);
10
- cover.createDefaultIdentifyClusterServer();
11
- cover.createDefaultGroupsClusterServer();
12
- cover.createDefaultScenesClusterServer();
13
- cover.createDefaultBridgedDeviceBasicInformationClusterServer('BridgedDevice1', 'BridgedDevice1 0x01020564', 0xfff1, 'Luligu', 'BridgedDevice1');
14
- cover.createDefaultPowerSourceRechargableBatteryClusterServer(86);
15
- cover.createDefaultWindowCoveringClusterServer();
16
- this.registerDevice(cover);
17
- cover.addCommandHandler('identify', async ({ request: { identifyTime } }) => {
18
- this.log.warn(`Command identify called identifyTime:${identifyTime}`);
9
+ async onStart(reason) {
10
+ this.log.info('onStart called with reason:', reason ?? 'none');
11
+ this.cover = new MatterbridgeDevice(DeviceTypes.WINDOW_COVERING);
12
+ this.cover.createDefaultIdentifyClusterServer();
13
+ this.cover.createDefaultGroupsClusterServer();
14
+ this.cover.createDefaultScenesClusterServer();
15
+ this.cover.createDefaultBridgedDeviceBasicInformationClusterServer('Bridged device 1', '0x01020564', 0xfff1, 'Luligu', 'Dynamic device 1');
16
+ this.cover.createDefaultPowerSourceRechargableBatteryClusterServer(86);
17
+ this.cover.createDefaultWindowCoveringClusterServer();
18
+ await this.registerDevice(this.cover);
19
+ this.cover.addCommandHandler('identify', async ({ request: { identifyTime } }) => {
20
+ this.log.info(`Command identify called identifyTime:${identifyTime}`);
19
21
  });
20
- cover.addCommandHandler('goToLiftPercentage', async ({ request: { liftPercent100thsValue } }) => {
21
- this.log.warn(`Command goToLiftPercentage called liftPercent100thsValue:${liftPercent100thsValue}`);
22
+ this.cover.addCommandHandler('goToLiftPercentage', async ({ request: { liftPercent100thsValue } }) => {
23
+ this.log.info(`Command goToLiftPercentage called liftPercent100thsValue:${liftPercent100thsValue}`);
22
24
  });
23
- const light = new MatterbridgeDevice(DeviceTypes.ON_OFF_LIGHT);
24
- light.createDefaultIdentifyClusterServer();
25
- light.createDefaultGroupsClusterServer();
26
- light.createDefaultScenesClusterServer();
27
- light.createDefaultBridgedDeviceBasicInformationClusterServer('BridgedDevice2', 'BridgedDevice2 0x23023304', 0xfff1, 'Luligu', 'BridgedDevice2');
28
- light.createDefaultPowerSourceReplaceableBatteryClusterServer(70);
29
- light.createDefaultOnOffClusterServer();
30
- this.registerDevice(light);
31
- light.addCommandHandler('identify', async ({ request: { identifyTime } }) => {
32
- this.log.warn(`Command identify called identifyTime:${identifyTime}`);
25
+ this.light = new MatterbridgeDevice(DeviceTypes.ON_OFF_LIGHT);
26
+ this.light.createDefaultIdentifyClusterServer();
27
+ this.light.createDefaultGroupsClusterServer();
28
+ this.light.createDefaultScenesClusterServer();
29
+ this.light.createDefaultBridgedDeviceBasicInformationClusterServer('Bridged device 2', '0x23480564', 0xfff1, 'Luligu', 'Dynamic device 2');
30
+ this.light.createDefaultPowerSourceReplaceableBatteryClusterServer(70);
31
+ this.light.createDefaultOnOffClusterServer();
32
+ await this.registerDevice(this.light);
33
+ this.light.addCommandHandler('identify', async ({ request: { identifyTime } }) => {
34
+ this.log.info(`Command identify called identifyTime:${identifyTime}`);
33
35
  });
34
- light.addCommandHandler('on', async () => {
35
- this.log.warn('Command on called');
36
+ this.light.addCommandHandler('on', async () => {
37
+ this.log.info('Command on called');
36
38
  });
37
- light.addCommandHandler('off', async () => {
38
- this.log.warn('Command off called');
39
+ this.light.addCommandHandler('off', async () => {
40
+ this.log.info('Command off called');
39
41
  });
40
42
  }
41
- onShutdown() {
42
- this.log.info('onShutdown called');
43
+ async onConfigure() {
44
+ this.log.info('onConfigure called');
45
+ if (!this.cover)
46
+ return;
47
+ const coverCluster = this.cover.getClusterServer(WindowCoveringCluster.with(WindowCovering.Feature.Lift, WindowCovering.Feature.PositionAwareLift));
48
+ if (coverCluster && coverCluster.getCurrentPositionLiftPercent100thsAttribute) {
49
+ const position = coverCluster.getCurrentPositionLiftPercent100thsAttribute();
50
+ if (position === null)
51
+ return;
52
+ this.log.debug(`**onConfigure called. Current PositionLiftPercent100ths is ${position}. Set target and status.`);
53
+ coverCluster.setTargetPositionLiftPercent100thsAttribute(position);
54
+ coverCluster.setOperationalStatusAttribute({
55
+ global: WindowCovering.MovementStatus.Stopped,
56
+ lift: WindowCovering.MovementStatus.Stopped,
57
+ tilt: WindowCovering.MovementStatus.Stopped,
58
+ });
59
+ }
60
+ setInterval(() => {
61
+ if (!this.cover)
62
+ return;
63
+ const coverCluster = this.cover.getClusterServer(WindowCoveringCluster.with(WindowCovering.Feature.Lift, WindowCovering.Feature.PositionAwareLift));
64
+ if (coverCluster && coverCluster.getCurrentPositionLiftPercent100thsAttribute) {
65
+ let position = coverCluster.getCurrentPositionLiftPercent100thsAttribute();
66
+ if (position === null)
67
+ return;
68
+ position = position >= 9000 ? 0 : position + 1000;
69
+ coverCluster.setTargetPositionLiftPercent100thsAttribute(position);
70
+ coverCluster.setCurrentPositionLiftPercent100thsAttribute(position);
71
+ coverCluster.setOperationalStatusAttribute({
72
+ global: WindowCovering.MovementStatus.Stopped,
73
+ lift: WindowCovering.MovementStatus.Stopped,
74
+ tilt: WindowCovering.MovementStatus.Stopped,
75
+ });
76
+ this.log.info(`Set PositionLiftPercent100ths to ${position}`);
77
+ }
78
+ }, 60 * 1000 + 500);
79
+ setInterval(() => {
80
+ if (!this.light)
81
+ return;
82
+ const lightCluster = this.light.getClusterServer(OnOffCluster);
83
+ if (lightCluster) {
84
+ const status = lightCluster.getOnOffAttribute();
85
+ lightCluster.setOnOffAttribute(!status);
86
+ this.log.info(`Set onOff to ${!status}`);
87
+ }
88
+ }, 60 * 1000 + 200);
89
+ }
90
+ async onShutdown(reason) {
91
+ this.log.info('onShutdown called with reason:', reason ?? 'none');
43
92
  }
44
93
  }
45
94
  //# sourceMappingURL=platform.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"platform.js","sourceRoot":"","sources":["../src/platform.ts"],"names":[],"m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,CAAC,QAAQ,GAAG,IAAI,CAAC;gBAClD,YAAY,CAAC,2CAA2C,CAAC,QAAQ,CAAC,CAAC;gBACnE,YAAY,CAAC,4CAA4C,CAAC,QAAQ,CAAC,CAAC;gBACpE,YAAY,CAAC,6BAA6B,CAAC;oBACzC,MAAM,EAAE,cAAc,CAAC,cAAc,CAAC,OAAO;oBAC7C,IAAI,EAAE,cAAc,CAAC,cAAc,CAAC,OAAO;oBAC3C,IAAI,EAAE,cAAc,CAAC,cAAc,CAAC,OAAO;iBAC5C,CAAC,CAAC;gBACH,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,oCAAoC,QAAQ,EAAE,CAAC,CAAC;YAChE,CAAC;QACH,CAAC,EACD,EAAE,GAAG,IAAI,GAAG,GAAG,CAChB,CAAC;QAEF,WAAW,CACT,GAAG,EAAE;YACH,IAAI,CAAC,IAAI,CAAC,KAAK;gBAAE,OAAO;YACxB,MAAM,YAAY,GAAG,IAAI,CAAC,KAAK,CAAC,gBAAgB,CAAC,YAAY,CAAC,CAAC;YAC/D,IAAI,YAAY,EAAE,CAAC;gBACjB,MAAM,MAAM,GAAG,YAAY,CAAC,iBAAiB,EAAE,CAAC;gBAChD,YAAY,CAAC,iBAAiB,CAAC,CAAC,MAAM,CAAC,CAAC;gBACxC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,gBAAgB,CAAC,MAAM,EAAE,CAAC,CAAC;YAC3C,CAAC;QACH,CAAC,EACD,EAAE,GAAG,IAAI,GAAG,GAAG,CAChB,CAAC;IACJ,CAAC;IAEQ,KAAK,CAAC,UAAU,CAAC,MAAe;QACvC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,gCAAgC,EAAE,MAAM,IAAI,MAAM,CAAC,CAAC;IACpE,CAAC;CACF"}
@@ -0,0 +1,15 @@
1
+ // link-script.js
2
+ import { exec } from 'child_process';
3
+
4
+ const command = process.platform === 'win32' ? 'npm link matterbridge' : 'sudo npm link matterbridge';
5
+
6
+ exec(command, (error, stdout, stderr) => {
7
+ if (error) {
8
+ console.error(`exec error: ${error}`);
9
+ return;
10
+ }
11
+ console.log(`stdout: ${stdout}`);
12
+ if (stderr) {
13
+ console.error(`stderr: ${stderr}`);
14
+ }
15
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "matterbridge-example-dynamic-platform",
3
- "version": "1.0.0",
3
+ "version": "1.0.2",
4
4
  "description": "Matterbridge dynamic platform plugin example",
5
5
  "author": "https://github.com/Luligu",
6
6
  "license": "MIT",
@@ -26,7 +26,8 @@
26
26
  "scripts": {
27
27
  "build": "tsc",
28
28
  "watch": "tsc --watch",
29
- "start": "node ./dist/index.js",
29
+ "start:bridge": "matterbridge -bridge",
30
+ "start:childbridge": "matterbridge -childbridge",
30
31
  "test": "jest",
31
32
  "test:verbose": "jest --verbose",
32
33
  "test:watch": "jest --watch",
@@ -40,22 +41,29 @@
40
41
  "prepublishOnly": "npm run lint && npm run cleanBuild",
41
42
  "checkDependencies": "npx npm-check-updates",
42
43
  "updateDependencies": "npx npm-check-updates -u",
43
- "updateMatter": "npm install @project-chip/matter.js@dev && npm install @project-chip/matter-node.js@dev && npm install @project-chip/matter.js-tools@dev && npm install @project-chip/matter-node-ble.js@dev"
44
+ "matterbridge:add": "matterbridge -add .\\",
45
+ "matterbridge:remove": "matterbridge -remove .\\",
46
+ "matterbridge:enable": "matterbridge -enable .\\",
47
+ "matterbridge:disable": "matterbridge -disable .\\",
48
+ "matterbridge:list": "matterbridge -list",
49
+ "dev:link": "npm link --save-dev matterbridge",
50
+ "dev:install": "npm install --save-dev matterbridge",
51
+ "dev:unlink": "npm uninstall matterbridge && npm unlink matterbridge",
52
+ "install": "node link-matterbridge-script.js && npm run build"
44
53
  },
45
54
  "devDependencies": {
46
- "@stylistic/eslint-plugin": "^1.6.2",
55
+ "@stylistic/eslint-plugin": "^1.6.3",
47
56
  "@tsconfig/node-lts": "^20.1.1",
48
- "@types/node": "^20.11.20",
49
- "@typescript-eslint/eslint-plugin": "^7.0.2",
50
- "@typescript-eslint/parser": "^7.0.2",
57
+ "@types/node": "^20.11.27",
58
+ "@typescript-eslint/eslint-plugin": "^7.2.0",
59
+ "@typescript-eslint/parser": "^7.2.0",
51
60
  "eslint-config-prettier": "^9.1.0",
52
61
  "eslint-plugin-prettier": "^5.1.3",
62
+ "matterbridge": "file:../matterbridge",
53
63
  "prettier": "^3.2.5",
54
- "typescript": "^5.3.3"
64
+ "typescript": "^5.4.2"
55
65
  },
56
66
  "dependencies": {
57
- "@project-chip/matter-node.js": "^0.7.5",
58
- "node-ansi-logger": "^1.9.1",
59
- "node-persist-manager": "^1.0.3"
67
+ "node-ansi-logger": "^1.9.2"
60
68
  }
61
69
  }