matterbridge-example-accessory-platform 1.0.0
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 +46 -0
- package/.gitattributes +2 -0
- package/.prettierignore +2 -0
- package/.prettierrc.json +12 -0
- package/README.md +2 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +24 -0
- package/dist/index.js.map +1 -0
- package/dist/platform.d.ts +8 -0
- package/dist/platform.d.ts.map +1 -0
- package/dist/platform.js +41 -0
- package/dist/platform.js.map +1 -0
- package/package.json +61 -0
package/.eslintrc.json
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
{
|
|
2
|
+
"ignorePatterns":["dist/", "node_modules/"],
|
|
3
|
+
"plugins": [
|
|
4
|
+
"@typescript-eslint",
|
|
5
|
+
"@stylistic",
|
|
6
|
+
"prettier"
|
|
7
|
+
],
|
|
8
|
+
"parser": "@typescript-eslint/parser",
|
|
9
|
+
"parserOptions": {
|
|
10
|
+
"ecmaVersion": "latest",
|
|
11
|
+
"sourceType": "module"
|
|
12
|
+
},
|
|
13
|
+
"env": {
|
|
14
|
+
"browser": true,
|
|
15
|
+
"es2021": true,
|
|
16
|
+
"node": true
|
|
17
|
+
},
|
|
18
|
+
"extends": [
|
|
19
|
+
"eslint:recommended",
|
|
20
|
+
"plugin:@typescript-eslint/eslint-recommended",
|
|
21
|
+
"plugin:@typescript-eslint/recommended",
|
|
22
|
+
"prettier"
|
|
23
|
+
],
|
|
24
|
+
"rules": {
|
|
25
|
+
"prettier/prettier": ["error"],
|
|
26
|
+
"indent": ["error", 2],
|
|
27
|
+
"max-len": ["warn", 180],
|
|
28
|
+
"no-console": ["warn"],
|
|
29
|
+
"quotes": ["error", "single", { "avoidEscape": true, "allowTemplateLiterals": false }],
|
|
30
|
+
"comma-spacing": ["error", { "before": false, "after": true }],
|
|
31
|
+
"space-before-function-paren": ["error", { "anonymous": "never", "named": "never", "asyncArrow": "always" }],
|
|
32
|
+
"keyword-spacing": ["error", { "before": true, "after": true }],
|
|
33
|
+
"no-multi-spaces": "error",
|
|
34
|
+
"object-curly-spacing": ["error", "always"],
|
|
35
|
+
"@typescript-eslint/type-annotation-spacing": ["error", {
|
|
36
|
+
"before": false,
|
|
37
|
+
"after": true,
|
|
38
|
+
"overrides": {
|
|
39
|
+
"arrow": {
|
|
40
|
+
"before": true,
|
|
41
|
+
"after": true
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}]
|
|
45
|
+
}
|
|
46
|
+
}
|
package/.gitattributes
ADDED
package/.prettierignore
ADDED
package/.prettierrc.json
ADDED
package/README.md
ADDED
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Matterbridge } from '../../matterbridge/dist/index.js';
|
|
2
|
+
import { AnsiLogger } from 'node-ansi-logger';
|
|
3
|
+
import { ExampleMatterbridgeAccessoryPlatform } from './platform.js';
|
|
4
|
+
/**
|
|
5
|
+
* This is the standard interface for MatterBridge plugins.
|
|
6
|
+
* Each plugin should export a default function that follows this signature.
|
|
7
|
+
*
|
|
8
|
+
* @param matterbridge - An instance of MatterBridge
|
|
9
|
+
*/
|
|
10
|
+
export default function initializePlugin(matterbridge: Matterbridge, log: AnsiLogger): ExampleMatterbridgeAccessoryPlatform;
|
|
11
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +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,oCAAoC,EAAE,MAAM,eAAe,CAAC;AAErE;;;;;GAKG;AACH,MAAM,CAAC,OAAO,UAAU,gBAAgB,CAAC,YAAY,EAAE,YAAY,EAAE,GAAG,EAAE,UAAU,wCAgBnF"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
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
|
+
import { ExampleMatterbridgeAccessoryPlatform } from './platform.js';
|
|
5
|
+
/**
|
|
6
|
+
* This is the standard interface for MatterBridge plugins.
|
|
7
|
+
* Each plugin should export a default function that follows this signature.
|
|
8
|
+
*
|
|
9
|
+
* @param matterbridge - An instance of MatterBridge
|
|
10
|
+
*/
|
|
11
|
+
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 accessory platform example plugin is loading...');
|
|
20
|
+
const platform = new ExampleMatterbridgeAccessoryPlatform(matterbridge, log);
|
|
21
|
+
log.info('Matterbridge accessory platform example plugin initialized successfully!');
|
|
22
|
+
return platform;
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +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,oCAAoC,EAAE,MAAM,eAAe,CAAC;AAErE;;;;;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,8DAA8D,CAAC,CAAC;IAEzE,MAAM,QAAQ,GAAG,IAAI,oCAAoC,CAAC,YAAY,EAAE,GAAG,CAAC,CAAC;IAE7E,GAAG,CAAC,IAAI,CAAC,0EAA0E,CAAC,CAAC;IACrF,OAAO,QAAQ,CAAC;AAClB,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Matterbridge, MatterbridgeAccessoryPlatform } from '../../matterbridge/dist/index.js';
|
|
2
|
+
import { AnsiLogger } from 'node-ansi-logger';
|
|
3
|
+
export declare class ExampleMatterbridgeAccessoryPlatform extends MatterbridgeAccessoryPlatform {
|
|
4
|
+
constructor(matterbridge: Matterbridge, log: AnsiLogger);
|
|
5
|
+
onStartAccessoryPlatform(): void;
|
|
6
|
+
onShutdown(): void;
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=platform.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"platform.d.ts","sourceRoot":"","sources":["../src/platform.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAsB,6BAA6B,EAAE,MAAM,kCAAkC,CAAC;AACnH,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAG9C,qBAAa,oCAAqC,SAAQ,6BAA6B;gBACzE,YAAY,EAAE,YAAY,EAAE,GAAG,EAAE,UAAU;IAI9C,wBAAwB,IAAI,IAAI;IAkChC,UAAU,IAAI,IAAI;CAG5B"}
|
package/dist/platform.js
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { DeviceTypes } from '@project-chip/matter-node.js/device';
|
|
2
|
+
import { MatterbridgeDevice, MatterbridgeAccessoryPlatform } from '../../matterbridge/dist/index.js';
|
|
3
|
+
import { WindowCovering, WindowCoveringCluster } from '@project-chip/matter-node.js/cluster';
|
|
4
|
+
export class ExampleMatterbridgeAccessoryPlatform extends MatterbridgeAccessoryPlatform {
|
|
5
|
+
constructor(matterbridge, log) {
|
|
6
|
+
super(matterbridge, log);
|
|
7
|
+
}
|
|
8
|
+
onStartAccessoryPlatform() {
|
|
9
|
+
this.log.info('onStartAccessoryPlatform called');
|
|
10
|
+
const cover = new MatterbridgeDevice(DeviceTypes.WINDOW_COVERING);
|
|
11
|
+
cover.createDefaultIdentifyClusterServer();
|
|
12
|
+
cover.createDefaultBasicInformationClusterServer('Device1', 'Device1 0x9010880304', 0xfff1, 'Luligu', 0x0001, 'Device1');
|
|
13
|
+
cover.createDefaultWindowCoveringClusterServer(10000);
|
|
14
|
+
this.registerDevice(cover);
|
|
15
|
+
cover.addCommandHandler('identify', async ({ request: { identifyTime } }) => {
|
|
16
|
+
this.log.warn(`Command identify called identifyTime:${identifyTime}`);
|
|
17
|
+
});
|
|
18
|
+
cover.addCommandHandler('goToLiftPercentage', async ({ request: { liftPercent100thsValue } }) => {
|
|
19
|
+
this.log.warn(`Command goToLiftPercentage called liftPercent100thsValue:${liftPercent100thsValue}`);
|
|
20
|
+
});
|
|
21
|
+
setInterval(() => {
|
|
22
|
+
const coverCluster = cover.getClusterServer(WindowCoveringCluster.with(WindowCovering.Feature.Lift, WindowCovering.Feature.PositionAwareLift));
|
|
23
|
+
if (coverCluster && coverCluster.getCurrentPositionLiftPercent100thsAttribute) {
|
|
24
|
+
let position = coverCluster.getCurrentPositionLiftPercent100thsAttribute() + 1000;
|
|
25
|
+
position = position > 10000 ? 0 : position;
|
|
26
|
+
coverCluster.setTargetPositionLiftPercent100thsAttribute(position);
|
|
27
|
+
coverCluster.setCurrentPositionLiftPercent100thsAttribute(position);
|
|
28
|
+
coverCluster.setOperationalStatusAttribute({
|
|
29
|
+
global: WindowCovering.MovementStatus.Stopped,
|
|
30
|
+
lift: WindowCovering.MovementStatus.Stopped,
|
|
31
|
+
tilt: WindowCovering.MovementStatus.Stopped,
|
|
32
|
+
});
|
|
33
|
+
this.log.warn(`Set liftPercent100thsValue to ${position}`);
|
|
34
|
+
}
|
|
35
|
+
}, 10 * 1000);
|
|
36
|
+
}
|
|
37
|
+
onShutdown() {
|
|
38
|
+
this.log.info('onShutdown called');
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=platform.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"platform.js","sourceRoot":"","sources":["../src/platform.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,qCAAqC,CAAC;AAElE,OAAO,EAAgB,kBAAkB,EAAE,6BAA6B,EAAE,MAAM,kCAAkC,CAAC;AAEnH,OAAO,EAAE,cAAc,EAAE,qBAAqB,EAAE,MAAM,sCAAsC,CAAC;AAE7F,MAAM,OAAO,oCAAqC,SAAQ,6BAA6B;IACrF,YAAY,YAA0B,EAAE,GAAe;QACrD,KAAK,CAAC,YAAY,EAAE,GAAG,CAAC,CAAC;IAC3B,CAAC;IAEQ,wBAAwB;QAC/B,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,iCAAiC,CAAC,CAAC;QAEjD,MAAM,KAAK,GAAG,IAAI,kBAAkB,CAAC,WAAW,CAAC,eAAe,CAAC,CAAC;QAClE,KAAK,CAAC,kCAAkC,EAAE,CAAC;QAC3C,KAAK,CAAC,0CAA0C,CAAC,SAAS,EAAE,sBAAsB,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EA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c,CAAC,cAAc,CAAC,OAAO;iBAC5C,CAAC,CAAC;gBACH,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,iCAAiC,QAAQ,EAAE,CAAC,CAAC;YAC7D,CAAC;QACH,CAAC,EAAE,EAAE,GAAG,IAAI,CAAC,CAAC;IAChB,CAAC;IAEQ,UAAU;QACjB,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,mBAAmB,CAAC,CAAC;IACrC,CAAC;CACF"}
|
package/package.json
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "matterbridge-example-accessory-platform",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Matterbridge accessory platform plugin example",
|
|
5
|
+
"author": "https://github.com/Luligu",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"type": "module",
|
|
8
|
+
"main": "dist/index.js",
|
|
9
|
+
"types": "dist/index.d.js",
|
|
10
|
+
"repository": {
|
|
11
|
+
"type": "git",
|
|
12
|
+
"url": "https://github.com/Luligu/matterbridge-example-accessory-platform"
|
|
13
|
+
},
|
|
14
|
+
"bugs": {
|
|
15
|
+
"url": "https://github.com/Luligu/matterbridge-example-accessory-platform/issues"
|
|
16
|
+
},
|
|
17
|
+
"keywords": [
|
|
18
|
+
"matterbridge",
|
|
19
|
+
"homebridge",
|
|
20
|
+
"matter",
|
|
21
|
+
"matter.js"
|
|
22
|
+
],
|
|
23
|
+
"engines": {
|
|
24
|
+
"node": "^18.19.0 || ^20.11.0"
|
|
25
|
+
},
|
|
26
|
+
"scripts": {
|
|
27
|
+
"build": "tsc",
|
|
28
|
+
"watch": "tsc --watch",
|
|
29
|
+
"start": "node ./dist/index.js",
|
|
30
|
+
"test": "jest",
|
|
31
|
+
"test:verbose": "jest --verbose",
|
|
32
|
+
"test:watch": "jest --watch",
|
|
33
|
+
"lint": "eslint src/**.ts",
|
|
34
|
+
"lint:fix": "eslint src/**.ts --fix",
|
|
35
|
+
"format": "prettier --write \"src/**/*.{js,jsx,ts,tsx,json,css,md}\"",
|
|
36
|
+
"format:check": "prettier --check \"src/**/*.{js,jsx,ts,tsx,json,css,md}\"",
|
|
37
|
+
"clean": "rimraf tsconfig.tsbuildinfo ./dist",
|
|
38
|
+
"cleanBuild": "npm run clean && tsc",
|
|
39
|
+
"deepClean": "rimraf tsconfig.tsbuildinfo package-lock.json ./dist ./node_modules",
|
|
40
|
+
"prepublishOnly": "npm run lint && npm run cleanBuild",
|
|
41
|
+
"checkDependencies": "npx npm-check-updates",
|
|
42
|
+
"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
|
+
},
|
|
45
|
+
"devDependencies": {
|
|
46
|
+
"@stylistic/eslint-plugin": "^1.6.2",
|
|
47
|
+
"@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",
|
|
51
|
+
"eslint-config-prettier": "^9.1.0",
|
|
52
|
+
"eslint-plugin-prettier": "^5.1.3",
|
|
53
|
+
"prettier": "^3.2.5",
|
|
54
|
+
"typescript": "^5.3.3"
|
|
55
|
+
},
|
|
56
|
+
"dependencies": {
|
|
57
|
+
"@project-chip/matter-node.js": "^0.7.5",
|
|
58
|
+
"node-ansi-logger": "^1.9.1",
|
|
59
|
+
"node-persist-manager": "^1.0.3"
|
|
60
|
+
}
|
|
61
|
+
}
|