matterbridge-eve-door 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/README.md ADDED
@@ -0,0 +1,15 @@
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 eve door with history
2
+
3
+ [![npm version](https://img.shields.io/npm/v/matterbridge-eve-door.svg)](https://www.npmjs.com/package/matterbridge-eve-door)
4
+ [![npm downloads](https://img.shields.io/npm/dt/matterbridge-eve-door.svg)](https://www.npmjs.com/package/matterbridge-eve-door)
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
+ This plugin shows how to use the Matter history and how to create passive device in matter.js.
14
+
15
+ It create a contact sensor device that continuously changes state.
@@ -0,0 +1,11 @@
1
+ import { Matterbridge, PlatformConfig } from 'matterbridge';
2
+ import { AnsiLogger } from 'node-ansi-logger';
3
+ import { EveDoorPlatform } 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, config: PlatformConfig): EveDoorPlatform;
11
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC5D,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAEhD;;;;;GAKG;AACH,MAAM,CAAC,OAAO,UAAU,gBAAgB,CAAC,YAAY,EAAE,YAAY,EAAE,GAAG,EAAE,UAAU,EAAE,MAAM,EAAE,cAAc,mBAE3G"}
package/dist/index.js ADDED
@@ -0,0 +1,11 @@
1
+ import { EveDoorPlatform } from './platform.js';
2
+ /**
3
+ * This is the standard interface for MatterBridge plugins.
4
+ * Each plugin should export a default function that follows this signature.
5
+ *
6
+ * @param matterbridge - An instance of MatterBridge
7
+ */
8
+ export default function initializePlugin(matterbridge, log, config) {
9
+ return new EveDoorPlatform(matterbridge, log, config);
10
+ }
11
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAEhD;;;;;GAKG;AACH,MAAM,CAAC,OAAO,UAAU,gBAAgB,CAAC,YAA0B,EAAE,GAAe,EAAE,MAAsB;IAC1G,OAAO,IAAI,eAAe,CAAC,YAAY,EAAE,GAAG,EAAE,MAAM,CAAC,CAAC;AACxD,CAAC"}
@@ -0,0 +1,14 @@
1
+ /// <reference types="node" resolution-mode="require"/>
2
+ import { PlatformConfig } from 'matterbridge';
3
+ import { Matterbridge, MatterbridgeDevice, MatterbridgeAccessoryPlatform, MatterHistory } from 'matterbridge';
4
+ import { AnsiLogger } from 'node-ansi-logger';
5
+ export declare class EveDoorPlatform extends MatterbridgeAccessoryPlatform {
6
+ door: MatterbridgeDevice | undefined;
7
+ history: MatterHistory | undefined;
8
+ interval: NodeJS.Timeout | undefined;
9
+ constructor(matterbridge: Matterbridge, log: AnsiLogger, config: PlatformConfig);
10
+ onStart(reason?: string): Promise<void>;
11
+ onConfigure(): Promise<void>;
12
+ onShutdown(reason?: string): Promise<void>;
13
+ }
14
+ //# sourceMappingURL=platform.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"platform.d.ts","sourceRoot":"","sources":["../src/platform.ts"],"names":[],"mappings":";AAAA,OAAO,EAA6B,cAAc,EAAE,MAAM,cAAc,CAAC;AAEzE,OAAO,EAAE,YAAY,EAAE,kBAAkB,EAAE,6BAA6B,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC9G,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE9C,qBAAa,eAAgB,SAAQ,6BAA6B;IAChE,IAAI,EAAE,kBAAkB,GAAG,SAAS,CAAC;IACrC,OAAO,EAAE,aAAa,GAAG,SAAS,CAAC;IACnC,QAAQ,EAAE,MAAM,CAAC,OAAO,GAAG,SAAS,CAAC;gBAEzB,YAAY,EAAE,YAAY,EAAE,GAAG,EAAE,UAAU,EAAE,MAAM,EAAE,cAAc;IAIhE,OAAO,CAAC,MAAM,CAAC,EAAE,MAAM;IAyBvB,WAAW;IAmBX,UAAU,CAAC,MAAM,CAAC,EAAE,MAAM;CAK1C"}
@@ -0,0 +1,50 @@
1
+ import { DeviceTypes, BooleanState } from 'matterbridge';
2
+ import { MatterbridgeDevice, MatterbridgeAccessoryPlatform, MatterHistory } from 'matterbridge';
3
+ export class EveDoorPlatform extends MatterbridgeAccessoryPlatform {
4
+ door;
5
+ history;
6
+ interval;
7
+ constructor(matterbridge, log, config) {
8
+ super(matterbridge, log, config);
9
+ }
10
+ async onStart(reason) {
11
+ this.log.info('onStart called with reason:', reason ?? 'none');
12
+ this.history = new MatterHistory(this.log, 'Eve door', { filePath: this.matterbridge.matterbridgeDirectory });
13
+ this.door = new MatterbridgeDevice(DeviceTypes.CONTACT_SENSOR);
14
+ this.door.createDefaultIdentifyClusterServer();
15
+ this.door.createDefaultBasicInformationClusterServer('Eve door', '0x88030475', 4874, 'Eve Systems', 77, 'Eve Door 20EBN9901', 1144, '1.2.8');
16
+ this.door.createDefaultBooleanStateClusterServer(true);
17
+ this.door.createDefaultPowerSourceReplaceableBatteryClusterServer(75);
18
+ this.door.createDefaultPowerSourceConfigurationClusterServer(1);
19
+ // Add the EveHistory cluster to the device as last cluster!
20
+ this.door.createDoorEveHistoryClusterServer(this.history, this.log);
21
+ this.history.autoPilot(this.door);
22
+ await this.registerDevice(this.door);
23
+ this.door.addCommandHandler('identify', async ({ request: { identifyTime } }) => {
24
+ this.log.warn(`Command identify called identifyTime:${identifyTime}`);
25
+ this.history?.logHistory(false);
26
+ });
27
+ }
28
+ async onConfigure() {
29
+ this.log.info('onConfigure called');
30
+ this.interval = setInterval(() => {
31
+ if (!this.door || !this.history)
32
+ return;
33
+ let contact = this.door.getClusterServerById(BooleanState.Cluster.id)?.getStateValueAttribute();
34
+ contact = !contact;
35
+ this.door.getClusterServerById(BooleanState.Cluster.id)?.setStateValueAttribute(contact);
36
+ this.door.getClusterServerById(BooleanState.Cluster.id)?.triggerStateChangeEvent({ stateValue: contact });
37
+ if (contact === false)
38
+ this.history.addToTimesOpened();
39
+ this.history.setLastEvent();
40
+ this.history.addEntry({ time: this.history.now(), contact: contact === true ? 0 : 1 });
41
+ this.log.info(`Set contact to ${contact}`);
42
+ }, 60 * 1000 + 100);
43
+ }
44
+ async onShutdown(reason) {
45
+ this.log.info('onShutdown called with reason:', reason ?? 'none');
46
+ await this.history?.close();
47
+ clearInterval(this.interval);
48
+ }
49
+ }
50
+ //# 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,YAAY,EAAkB,MAAM,cAAc,CAAC;AAEzE,OAAO,EAAgB,kBAAkB,EAAE,6BAA6B,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAG9G,MAAM,OAAO,eAAgB,SAAQ,6BAA6B;IAChE,IAAI,CAAiC;IACrC,O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,CAAC,kBAAkB,OAAO,EAAE,CAAC,CAAC;QAC7C,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;QAClE,MAAM,IAAI,CAAC,OAAO,EAAE,KAAK,EAAE,CAAC;QAC5B,aAAa,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IAC/B,CAAC;CACF"}
@@ -0,0 +1,14 @@
1
+ import { exec } from 'child_process';
2
+
3
+ const command = process.platform === 'win32' ? 'npm link matterbridge' : 'sudo npm link matterbridge';
4
+
5
+ exec(command, (error, stdout, stderr) => {
6
+ if (error) {
7
+ console.error(`exec error: ${error}`);
8
+ return;
9
+ }
10
+ console.log(`stdout: ${stdout}`);
11
+ if (stderr) {
12
+ console.error(`stderr: ${stderr}`);
13
+ }
14
+ });
package/package.json ADDED
@@ -0,0 +1,72 @@
1
+ {
2
+ "name": "matterbridge-eve-door",
3
+ "version": "1.0.2",
4
+ "description": "Matterbridge eve door with history",
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-eve-door"
13
+ },
14
+ "bugs": {
15
+ "url": "https://github.com/Luligu/matterbridge-eve-door/issues"
16
+ },
17
+ "keywords": [
18
+ "matterbridge",
19
+ "homebridge",
20
+ "matter",
21
+ "matter.js",
22
+ "plugin",
23
+ "eve",
24
+ "door",
25
+ "history"
26
+ ],
27
+ "engines": {
28
+ "node": "^18.19.0 || ^20.11.0"
29
+ },
30
+ "scripts": {
31
+ "build": "tsc",
32
+ "watch": "tsc --watch",
33
+ "start:bridge": "matterbridge -bridge",
34
+ "start:childbridge": "matterbridge -childbridge",
35
+ "test": "jest",
36
+ "test:verbose": "jest --verbose",
37
+ "test:watch": "jest --watch",
38
+ "lint": "eslint src/**.ts",
39
+ "lint:fix": "eslint src/**.ts --fix",
40
+ "format": "prettier --write \"src/**/*.{js,jsx,ts,tsx,json,css,md}\"",
41
+ "format:check": "prettier --check \"src/**/*.{js,jsx,ts,tsx,json,css,md}\"",
42
+ "clean": "rimraf tsconfig.tsbuildinfo ./dist",
43
+ "cleanBuild": "npm run clean && tsc",
44
+ "deepClean": "rimraf tsconfig.tsbuildinfo package-lock.json ./dist ./node_modules",
45
+ "prepublishOnly": "npm run lint && npm run cleanBuild",
46
+ "checkDependencies": "npx npm-check-updates",
47
+ "updateDependencies": "npx npm-check-updates -u",
48
+ "matterbridge:add": "matterbridge -add .\\",
49
+ "matterbridge:remove": "matterbridge -remove .\\",
50
+ "matterbridge:enable": "matterbridge -enable .\\",
51
+ "matterbridge:disable": "matterbridge -disable .\\",
52
+ "matterbridge:list": "matterbridge -list",
53
+ "dev:link": "npm link --save-dev matterbridge",
54
+ "dev:install": "npm install --save-dev matterbridge",
55
+ "dev:uninstall": "npm uninstall matterbridge && npm unlink matterbridge",
56
+ "install": "node link-matterbridge-script.js"
57
+ },
58
+ "devDependencies": {
59
+ "@stylistic/eslint-plugin": "^1.7.0",
60
+ "@tsconfig/node-lts": "^20.1.2",
61
+ "@types/node": "^20.11.30",
62
+ "@typescript-eslint/eslint-plugin": "^7.3.1",
63
+ "@typescript-eslint/parser": "^7.3.1",
64
+ "eslint-config-prettier": "^9.1.0",
65
+ "eslint-plugin-prettier": "^5.1.3",
66
+ "prettier": "^3.2.5",
67
+ "typescript": "^5.4.3"
68
+ },
69
+ "dependencies": {
70
+ "node-ansi-logger": "^1.9.2"
71
+ }
72
+ }