matterbridge-example-dynamic-platform 1.0.18 → 1.0.19

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/CHANGELOG.md CHANGED
@@ -2,7 +2,24 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file.
4
4
 
5
- If you like this project and find it useful, please consider giving it a star on GitHub at https://github.com/Luligu/matterbridge-shelly and sponsoring it.
5
+ If you like this project and find it useful, please consider giving it a star on GitHub at https://github.com/Luligu/matterbridge-example-dynamic-platform and sponsoring it.
6
+
7
+ ## [1.0.19] - 2024-09-04
8
+
9
+ ### Added
10
+
11
+ - [plugin] Added:
12
+ - a light with onOff
13
+ - a light with onOff, levelControl
14
+ - an air quality device
15
+
16
+ ### Changed
17
+
18
+ - [package]: Updated dependencies.
19
+
20
+ <a href="https://www.buymeacoffee.com/luligugithub">
21
+ <img src="./yellow-button.png" alt="Buy me a coffee" width="120">
22
+ </a>
6
23
 
7
24
  ## [1.0.18] - 2024-09-03
8
25
 
package/README.md CHANGED
@@ -18,15 +18,17 @@ Matterbridge dynamic platform example plugin is a template to develop your own p
18
18
  It exposes:
19
19
 
20
20
  - a switch with onOff cluster
21
+ - a light with onOff
22
+ - a light with onOff and levelControl (dimmer)
21
23
  - a light with onOff, levelControl and colorControl (with XY, HS and CT) clusters
22
24
  - a light with onOff, levelControl and colorControl (with HS only) clusters
23
25
  - a light with onOff, levelControl and colorControl (with XY only) clusters
24
26
  - a light with onOff, levelControl and colorControl (with CT only) clusters
25
- - an outlet with onOff cluster
27
+ - an outlet (plug) with onOff cluster
26
28
  - a cover with windowCovering cluster
27
29
  - a lock with doorLock cluster
28
30
  - a thermo with thermostat cluster and 3 sub endpoints with flowMeasurement cluster, temperatureMeasurement cluster
29
- and relativeHumidityMeasurement cluster (to show how to create a composed device with sub enpoints)
31
+ and relativeHumidityMeasurement cluster (to show how to create a composed device with sub endpoints)
30
32
  - a fan with FanControl cluster
31
33
  - a rainSensor device
32
34
  - a waterFreezeDetector device
@@ -0,0 +1,81 @@
1
+ /* eslint-disable no-console */
2
+
3
+ /*
4
+ Add the following scripts to package.json file:
5
+ "prepublishOnly": "npm run lint && npm run test && npm run cleanBuild",
6
+ "npmPublish": "npm publish",
7
+ "gitPublish": "npm run lint && npm run test && npm run cleanBuild && node create-release.js",
8
+ "preversion": "npm run lint && npm run test && npm run cleanBuild",
9
+ "postversion": "git push && git push --tags && node create-release.js",
10
+ "version:patch": "npm version patch",
11
+ "version:minor": "npm version minor",
12
+ "version:major": "npm version major",
13
+ */
14
+
15
+ import { execSync } from 'child_process';
16
+ import { readFileSync, writeFileSync, unlinkSync } from 'fs';
17
+ import path from 'path';
18
+ import readline from 'readline';
19
+
20
+ // Get the latest tag
21
+ let tag = execSync('git describe --tags --abbrev=0').toString().trim();
22
+ if (tag.startsWith('v')) {
23
+ tag = tag.substring(1);
24
+ }
25
+
26
+ // Read the changelog file
27
+ const changelogPath = path.join(process.cwd(), 'CHANGELOG.md');
28
+ const changelog = readFileSync(changelogPath, 'utf8');
29
+
30
+ // Extract the relevant section from the changelog
31
+ const changelogSection = extractChangelogSection(changelog, tag);
32
+
33
+ const title = `Release ${tag}`;
34
+ const notes = `Release notes for version ${tag}\n\n## [${tag}] ${changelogSection}`;
35
+
36
+ // Log the release details
37
+ console.log(`Creating release ${tag} with the following details:\nTitle:\n${title}\nNotes:\n${notes}`);
38
+
39
+ // Write the release notes to a temporary file
40
+ const notesFilePath = path.join(process.cwd(), 'release-notes.md');
41
+ writeFileSync(notesFilePath, notes);
42
+
43
+ // Wait for user input before proceeding
44
+ await pressAnyKey();
45
+
46
+ // Create the release using the temporary file
47
+ execSync(`gh release create ${tag} -t "${title}" -F "${notesFilePath}"`, { stdio: 'inherit' });
48
+
49
+ // Clean up the temporary file
50
+ unlinkSync(notesFilePath);
51
+
52
+ /**
53
+ * Extracts the relevant section from the changelog for the given tag.
54
+ * Assumes that each version section in the changelog starts with a heading like "## [tag]".
55
+ * @param {string} changelog - The content of the changelog file.
56
+ * @param {string} tag - The tag for which to extract the changelog section.
57
+ * @returns {string} - The extracted changelog section.
58
+ */
59
+ function extractChangelogSection(changelog, tag) {
60
+ const regex = new RegExp(`## \\[${tag}\\](.*?)(## \\[|$)`, 's');
61
+ const match = changelog.match(regex);
62
+ return match ? match[1].trim() : 'No changelog entry found for this version.';
63
+ }
64
+
65
+ /**
66
+ * Waits for the user to press any key.
67
+ * @returns {Promise<void>}
68
+ */
69
+ function pressAnyKey() {
70
+ return new Promise((resolve) => {
71
+ const rl = readline.createInterface({
72
+ input: process.stdin,
73
+ output: process.stdout,
74
+ });
75
+
76
+ rl.question('Press any key to continue...', () => {
77
+ rl.close();
78
+ resolve();
79
+ });
80
+ });
81
+ }
@@ -3,6 +3,8 @@ import { Matterbridge, MatterbridgeDevice, MatterbridgeDynamicPlatform } from 'm
3
3
  import { AnsiLogger } from 'matterbridge/logger';
4
4
  export declare class ExampleMatterbridgeDynamicPlatform extends MatterbridgeDynamicPlatform {
5
5
  switch: MatterbridgeDevice | undefined;
6
+ lightOnOff: MatterbridgeDevice | undefined;
7
+ dimmer: MatterbridgeDevice | undefined;
6
8
  light: MatterbridgeDevice | undefined;
7
9
  lightXY: MatterbridgeDevice | undefined;
8
10
  lightHS: MatterbridgeDevice | undefined;
@@ -16,6 +18,7 @@ export declare class ExampleMatterbridgeDynamicPlatform extends MatterbridgeDyna
16
18
  waterFreeze: MatterbridgeDevice | undefined;
17
19
  rain: MatterbridgeDevice | undefined;
18
20
  smoke: MatterbridgeDevice | undefined;
21
+ airQuality: MatterbridgeDevice | undefined;
19
22
  switchInterval: NodeJS.Timeout | undefined;
20
23
  lightInterval: NodeJS.Timeout | undefined;
21
24
  outletInterval: NodeJS.Timeout | undefined;
@@ -27,6 +30,7 @@ export declare class ExampleMatterbridgeDynamicPlatform extends MatterbridgeDyna
27
30
  waterFreezeInterval: NodeJS.Timeout | undefined;
28
31
  rainInterval: NodeJS.Timeout | undefined;
29
32
  smokeInterval: NodeJS.Timeout | undefined;
33
+ airQualityInterval: NodeJS.Timeout | undefined;
30
34
  constructor(matterbridge: Matterbridge, log: AnsiLogger, config: PlatformConfig);
31
35
  onStart(reason?: string): Promise<void>;
32
36
  onConfigure(): Promise<void>;
@@ -1 +1 @@
1
- {"version":3,"file":"platform.d.ts","sourceRoot":"","sources":["../src/platform.ts"],"names":[],"mappings":"AAAA,OAAO,EAgBL,cAAc,EAgBf,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,YAAY,EAAE,kBAAkB,EAAE,2BAA2B,EAAE,MAAM,cAAc,CAAC;AAE7F,OAAO,EAAE,UAAU,EAAc,MAAM,qBAAqB,CAAC;AAE7D,qBAAa,kCAAmC,SAAQ,2BAA2B;IACjF,MAAM,EAAE,kBAAkB,GAAG,SAAS,CAAC;IACvC,KAAK,EAAE,kBAAkB,GAAG,SAAS,CAAC;IACtC,OAAO,EAAE,kBAAkB,GAAG,SAAS,CAAC;IACxC,OAAO,EAAE,kBAAkB,GAAG,SAAS,CAAC;IACxC,OAAO,EAAE,kBAAkB,GAAG,SAAS,CAAC;IACxC,MAAM,EAAE,kBAAkB,GAAG,SAAS,CAAC;IACvC,KAAK,EAAE,kBAAkB,GAAG,SAAS,CAAC;IACtC,IAAI,EAAE,kBAAkB,GAAG,SAAS,CAAC;IACrC,MAAM,EAAE,kBAAkB,GAAG,SAAS,CAAC;IACvC,GAAG,EAAE,kBAAkB,GAAG,SAAS,CAAC;IACpC,SAAS,EAAE,kBAAkB,GAAG,SAAS,CAAC;IAC1C,WAAW,EAAE,kBAAkB,GAAG,SAAS,CAAC;IAC5C,IAAI,EAAE,kBAAkB,GAAG,SAAS,CAAC;IACrC,KAAK,EAAE,kBAAkB,GAAG,SAAS,CAAC;IAEtC,cAAc,EAAE,MAAM,CAAC,OAAO,GAAG,SAAS,CAAC;IAC3C,aAAa,EAAE,MAAM,CAAC,OAAO,GAAG,SAAS,CAAC;IAC1C,cAAc,EAAE,MAAM,CAAC,OAAO,GAA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