matterbridge-test 1.0.4 → 1.0.7-dev.1
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 +37 -0
- package/dist/platform.js +41 -34
- package/npm-shrinkwrap.json +35 -5
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,39 @@ All notable changes to this project will be documented in this file.
|
|
|
4
4
|
|
|
5
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
6
|
|
|
7
|
+
## [1.0.7] - 2025-02-01
|
|
8
|
+
|
|
9
|
+
### Changed
|
|
10
|
+
|
|
11
|
+
- [package]: Updated dependencies.
|
|
12
|
+
- [package]: Require matterbridge 2.1.0.
|
|
13
|
+
|
|
14
|
+
<a href="https://www.buymeacoffee.com/luligugithub">
|
|
15
|
+
<img src="./yellow-button.png" alt="Buy me a coffee" width="120">
|
|
16
|
+
</a>
|
|
17
|
+
|
|
18
|
+
## [1.0.6] - 2025-01-21
|
|
19
|
+
|
|
20
|
+
### Changed
|
|
21
|
+
|
|
22
|
+
- [package]: Updated dependencies.
|
|
23
|
+
- [package]: Require matterbridge 2.0.0.
|
|
24
|
+
|
|
25
|
+
<a href="https://www.buymeacoffee.com/luligugithub">
|
|
26
|
+
<img src="./yellow-button.png" alt="Buy me a coffee" width="120">
|
|
27
|
+
</a>
|
|
28
|
+
|
|
29
|
+
## [1.0.5] - 2025-01-21
|
|
30
|
+
|
|
31
|
+
### Changed
|
|
32
|
+
|
|
33
|
+
- [package]: Updated dependencies.
|
|
34
|
+
- [package]: Require matterbridge 2.0.0.
|
|
35
|
+
|
|
36
|
+
<a href="https://www.buymeacoffee.com/luligugithub">
|
|
37
|
+
<img src="./yellow-button.png" alt="Buy me a coffee" width="120">
|
|
38
|
+
</a>
|
|
39
|
+
|
|
7
40
|
## [1.0.4] - 2025-01-20
|
|
8
41
|
|
|
9
42
|
### Changed
|
|
@@ -11,6 +44,10 @@ If you like this project and find it useful, please consider giving it a star on
|
|
|
11
44
|
- [package]: Updated dependencies.
|
|
12
45
|
- [package]: Updated package for production build.
|
|
13
46
|
|
|
47
|
+
<a href="https://www.buymeacoffee.com/luligugithub">
|
|
48
|
+
<img src="./yellow-button.png" alt="Buy me a coffee" width="120">
|
|
49
|
+
</a>
|
|
50
|
+
|
|
14
51
|
## [1.0.3] - 2024-12-21
|
|
15
52
|
|
|
16
53
|
### Added
|
package/dist/platform.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { MatterbridgeDynamicPlatform, bridgedNode, electricalSensor, onOffSwitch, onOffOutlet, colorTemperatureLight, OnOffCluster, powerSource, ElectricalPowerMeasurementCluster, ElectricalEnergyMeasurementCluster, ModeSelectCluster, PowerSourceCluster, modeSelect, MatterbridgeEndpoint, } from 'matterbridge';
|
|
2
2
|
import { waiter } from 'matterbridge/utils';
|
|
3
3
|
export class TestPlatform extends MatterbridgeDynamicPlatform {
|
|
4
4
|
noDevices = false;
|
|
@@ -16,18 +16,10 @@ export class TestPlatform extends MatterbridgeDynamicPlatform {
|
|
|
16
16
|
enablePowerSource = false;
|
|
17
17
|
interval;
|
|
18
18
|
bridgedDevices = new Map();
|
|
19
|
-
async createMutableDevice(definition, options = {}, debug = false) {
|
|
20
|
-
let device;
|
|
21
|
-
if (this.matterbridge.edge === true)
|
|
22
|
-
device = new MatterbridgeEndpoint(definition, options, debug);
|
|
23
|
-
else
|
|
24
|
-
device = new MatterbridgeDevice(definition, options, debug);
|
|
25
|
-
return device;
|
|
26
|
-
}
|
|
27
19
|
constructor(matterbridge, log, config) {
|
|
28
20
|
super(matterbridge, log, config);
|
|
29
|
-
if (this.verifyMatterbridgeVersion === undefined || typeof this.verifyMatterbridgeVersion !== 'function' || !this.verifyMatterbridgeVersion('1.
|
|
30
|
-
throw new Error(`The test plugin requires Matterbridge version >= "1.
|
|
21
|
+
if (this.verifyMatterbridgeVersion === undefined || typeof this.verifyMatterbridgeVersion !== 'function' || !this.verifyMatterbridgeVersion('2.1.0')) {
|
|
22
|
+
throw new Error(`The test plugin requires Matterbridge version >= "2.1.0". Please update Matterbridge to the latest version in the frontend.`);
|
|
31
23
|
}
|
|
32
24
|
this.log.info('Initializing platform:', this.config.name);
|
|
33
25
|
this.log.debug('- with matterbridge version ', matterbridge.matterbridgeVersion);
|
|
@@ -84,10 +76,15 @@ export class TestPlatform extends MatterbridgeDynamicPlatform {
|
|
|
84
76
|
if (this.config.longDelayStart)
|
|
85
77
|
await waiter('Delay start', () => false, false, 60000, 1000);
|
|
86
78
|
for (let i = 0; i < this.loadSwitches; i++) {
|
|
87
|
-
const switchDevice =
|
|
79
|
+
const switchDevice = new MatterbridgeEndpoint([
|
|
80
|
+
onOffSwitch,
|
|
81
|
+
bridgedNode,
|
|
82
|
+
...(this.enableElectrical ? [electricalSensor] : []),
|
|
83
|
+
...(this.enablePowerSource ? [powerSource] : []),
|
|
84
|
+
...(this.enableModeSelect ? [modeSelect] : []),
|
|
85
|
+
], { uniqueStorageKey: 'Switch' + i }, this.config.debug);
|
|
88
86
|
switchDevice.log.logName = 'Switch' + i;
|
|
89
87
|
switchDevice.createDefaultBridgedDeviceBasicInformationClusterServer('Switch ' + i, 'serial_switch_' + i, 0xfff1, 'Matterbridge', 'Matterbridge test plugin', parseInt(this.version.replace(/\D/g, '')), this.version, parseInt(this.matterbridge.matterbridgeVersion.replace(/\D/g, '')), this.matterbridge.matterbridgeVersion);
|
|
90
|
-
switchDevice.addDeviceTypeWithClusterServer([onOffSwitch], []);
|
|
91
88
|
switchDevice.addCommandHandler('identify', async (data) => {
|
|
92
89
|
this.log.info(`Received identify command request ${data.request.identifyTime} for endpoint ${data.endpoint?.number}`);
|
|
93
90
|
});
|
|
@@ -104,18 +101,24 @@ export class TestPlatform extends MatterbridgeDynamicPlatform {
|
|
|
104
101
|
if (this.enableModeSelect) {
|
|
105
102
|
this.addModeSelect(switchDevice, 'Switch ' + i);
|
|
106
103
|
switchDevice.addCommandHandler('changeToMode', async (data) => {
|
|
107
|
-
this.log.info(`Received command
|
|
104
|
+
this.log.info(`Received changeToMode command with request ${data.request.newMode} for endpoint ${data.endpoint?.number}`);
|
|
108
105
|
});
|
|
109
106
|
}
|
|
107
|
+
switchDevice.addRequiredClusterServers();
|
|
110
108
|
if (this.noDevices === false)
|
|
111
109
|
await this.registerDevice(switchDevice);
|
|
112
110
|
this.bridgedDevices.set('Switch' + i, switchDevice);
|
|
113
111
|
}
|
|
114
112
|
for (let i = 0; i < this.loadOutlets; i++) {
|
|
115
|
-
const outletDevice =
|
|
113
|
+
const outletDevice = new MatterbridgeEndpoint([
|
|
114
|
+
onOffOutlet,
|
|
115
|
+
bridgedNode,
|
|
116
|
+
...(this.enableElectrical ? [electricalSensor] : []),
|
|
117
|
+
...(this.enablePowerSource ? [powerSource] : []),
|
|
118
|
+
...(this.enableModeSelect ? [modeSelect] : []),
|
|
119
|
+
], { uniqueStorageKey: 'Outlet' + i }, this.config.debug);
|
|
116
120
|
outletDevice.log.logName = 'Outlet' + i;
|
|
117
121
|
outletDevice.createDefaultBridgedDeviceBasicInformationClusterServer('Outlet ' + i, 'serial_outlet_' + i, 0xfff1, 'Matterbridge', 'Matterbridge test plugin', parseInt(this.version.replace(/\D/g, '')), this.version, parseInt(this.matterbridge.matterbridgeVersion.replace(/\D/g, '')), this.matterbridge.matterbridgeVersion);
|
|
118
|
-
outletDevice.addDeviceTypeWithClusterServer([onOffOutlet], []);
|
|
119
122
|
outletDevice.addCommandHandler('identify', async (data) => {
|
|
120
123
|
this.log.info(`Received identify command request ${data.request.identifyTime} for endpoint ${data.endpoint?.number}`);
|
|
121
124
|
});
|
|
@@ -135,15 +138,21 @@ export class TestPlatform extends MatterbridgeDynamicPlatform {
|
|
|
135
138
|
this.log.info(`Received command changeToMode with request ${data.request.newMode} for endpoint ${data.endpoint?.number}`);
|
|
136
139
|
});
|
|
137
140
|
}
|
|
141
|
+
outletDevice.addRequiredClusterServers();
|
|
138
142
|
if (this.noDevices === false)
|
|
139
143
|
await this.registerDevice(outletDevice);
|
|
140
144
|
this.bridgedDevices.set('Outlet' + i, outletDevice);
|
|
141
145
|
}
|
|
142
146
|
for (let i = 0; i < this.loadLights; i++) {
|
|
143
|
-
const lightDevice =
|
|
147
|
+
const lightDevice = new MatterbridgeEndpoint([
|
|
148
|
+
colorTemperatureLight,
|
|
149
|
+
bridgedNode,
|
|
150
|
+
...(this.enableElectrical ? [electricalSensor] : []),
|
|
151
|
+
...(this.enablePowerSource ? [powerSource] : []),
|
|
152
|
+
...(this.enableModeSelect ? [modeSelect] : []),
|
|
153
|
+
], { uniqueStorageKey: 'Light' + i }, this.config.debug);
|
|
144
154
|
lightDevice.log.logName = 'Light' + i;
|
|
145
155
|
lightDevice.createDefaultBridgedDeviceBasicInformationClusterServer('Light ' + i, 'serial_light_' + i, 0xfff1, 'Matterbridge', 'Matterbridge test plugin', parseInt(this.version.replace(/\D/g, '')), this.version, parseInt(this.matterbridge.matterbridgeVersion.replace(/\D/g, '')), this.matterbridge.matterbridgeVersion);
|
|
146
|
-
lightDevice.addDeviceTypeWithClusterServer([colorTemperatureLight], []);
|
|
147
156
|
lightDevice.addCommandHandler('identify', async (data) => {
|
|
148
157
|
this.log.info(`Received identify command request ${data.request.identifyTime} for endpoint ${data.endpoint?.number}`);
|
|
149
158
|
});
|
|
@@ -154,25 +163,25 @@ export class TestPlatform extends MatterbridgeDynamicPlatform {
|
|
|
154
163
|
this.log.info(`Received off command for endpoint ${data.endpoint?.number}`);
|
|
155
164
|
});
|
|
156
165
|
lightDevice.addCommandHandler('moveToLevel', async (data) => {
|
|
157
|
-
this.log.info(`Received
|
|
166
|
+
this.log.info(`Received moveToLevel command request ${data.request.level} for endpoint ${data.endpoint?.number}`);
|
|
158
167
|
});
|
|
159
168
|
lightDevice.addCommandHandler('moveToLevelWithOnOff', async (data) => {
|
|
160
|
-
this.log.info(`Received
|
|
169
|
+
this.log.info(`Received moveToLevelWithOnOff command request ${data.request.level} for endpoint ${data.endpoint?.number}`);
|
|
161
170
|
});
|
|
162
171
|
lightDevice.addCommandHandler('moveToColor', async ({ request: { colorX, colorY } }) => {
|
|
163
|
-
this.log.info(`
|
|
172
|
+
this.log.info(`Received moveToColor command request X ${colorX / 65536} Y ${colorY / 65536}`);
|
|
164
173
|
});
|
|
165
174
|
lightDevice.addCommandHandler('moveToHueAndSaturation', async ({ request: { hue, saturation } }) => {
|
|
166
|
-
this.log.info(`
|
|
175
|
+
this.log.info(`Received moveToHueAndSaturation command request hue ${hue} saturation ${saturation}`);
|
|
167
176
|
});
|
|
168
177
|
lightDevice.addCommandHandler('moveToHue', async ({ request: { hue } }) => {
|
|
169
|
-
this.log.info(`
|
|
178
|
+
this.log.info(`Received moveToHue command request ${hue}`);
|
|
170
179
|
});
|
|
171
180
|
lightDevice.addCommandHandler('moveToSaturation', async ({ request: { saturation } }) => {
|
|
172
|
-
this.log.info(`
|
|
181
|
+
this.log.info(`Received moveToSaturation command request ${saturation}`);
|
|
173
182
|
});
|
|
174
183
|
lightDevice.addCommandHandler('moveToColorTemperature', async ({ request }) => {
|
|
175
|
-
this.log.info(`
|
|
184
|
+
this.log.info(`Received moveToColorTemperature command request ${request.colorTemperatureMireds}`);
|
|
176
185
|
});
|
|
177
186
|
if (this.enableElectrical)
|
|
178
187
|
this.addElectricalMeasurements(lightDevice);
|
|
@@ -184,27 +193,25 @@ export class TestPlatform extends MatterbridgeDynamicPlatform {
|
|
|
184
193
|
this.log.info(`Received command changeToMode with request ${data.request.newMode} for endpoint ${data.endpoint?.number}`);
|
|
185
194
|
});
|
|
186
195
|
}
|
|
196
|
+
lightDevice.addRequiredClusterServers();
|
|
187
197
|
if (this.noDevices === false)
|
|
188
198
|
await this.registerDevice(lightDevice);
|
|
189
199
|
this.bridgedDevices.set('Light' + i, lightDevice);
|
|
190
200
|
}
|
|
191
201
|
}
|
|
192
202
|
addElectricalMeasurements(device) {
|
|
193
|
-
device.
|
|
194
|
-
device.
|
|
195
|
-
device.
|
|
196
|
-
device.addClusterServer(device.getDefaultElectricalEnergyMeasurementClusterServer(1500 * 1000));
|
|
203
|
+
device.createDefaultPowerTopologyClusterServer();
|
|
204
|
+
device.createDefaultElectricalPowerMeasurementClusterServer(220 * 1000, 2.5 * 1000, 220 * 2.5 * 1000, 50 * 1000);
|
|
205
|
+
device.createDefaultElectricalEnergyMeasurementClusterServer(1500 * 1000);
|
|
197
206
|
}
|
|
198
207
|
addModeSelect(device, description) {
|
|
199
|
-
device.
|
|
200
|
-
device.addClusterServer(device.getDefaultModeSelectClusterServer(description + ' Led Mode Select', [
|
|
208
|
+
device.createDefaultModeSelectClusterServer(description + ' Led Mode Select', [
|
|
201
209
|
{ label: 'Led ON', mode: 1, semanticTags: [] },
|
|
202
210
|
{ label: 'Led OFF', mode: 2, semanticTags: [] },
|
|
203
|
-
], 1, 1)
|
|
211
|
+
], 1, 1);
|
|
204
212
|
}
|
|
205
213
|
addPowerSource(device) {
|
|
206
|
-
device.
|
|
207
|
-
device.addClusterServer(device.getDefaultPowerSourceReplaceableBatteryClusterServer(100));
|
|
214
|
+
device.createDefaultPowerSourceReplaceableBatteryClusterServer(100);
|
|
208
215
|
}
|
|
209
216
|
async onConfigure() {
|
|
210
217
|
await super.onConfigure();
|
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "matterbridge-test",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.7-dev.1",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "matterbridge-test",
|
|
9
|
-
"version": "1.0.
|
|
9
|
+
"version": "1.0.7-dev.1",
|
|
10
10
|
"license": "Apache-2.0",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"node-ansi-logger": "3.0.0",
|
|
@@ -34,10 +34,13 @@
|
|
|
34
34
|
}
|
|
35
35
|
},
|
|
36
36
|
"node_modules/node-persist": {
|
|
37
|
-
"version": "4.0.
|
|
38
|
-
"resolved": "https://registry.npmjs.org/node-persist/-/node-persist-4.0.
|
|
39
|
-
"integrity": "sha512-
|
|
37
|
+
"version": "4.0.4",
|
|
38
|
+
"resolved": "https://registry.npmjs.org/node-persist/-/node-persist-4.0.4.tgz",
|
|
39
|
+
"integrity": "sha512-8sPAz/7tw1mCCc8xBG4f0wi+flHkSSgQeX998iQ75Pu27evA6UUWCjSE7xnrYTg2q33oU5leJ061EKPDv6BocQ==",
|
|
40
40
|
"license": "MIT",
|
|
41
|
+
"dependencies": {
|
|
42
|
+
"p-limit": "^3.1.0"
|
|
43
|
+
},
|
|
41
44
|
"engines": {
|
|
42
45
|
"node": ">=10.12.0"
|
|
43
46
|
}
|
|
@@ -57,6 +60,33 @@
|
|
|
57
60
|
"type": "buymeacoffee",
|
|
58
61
|
"url": "https://www.buymeacoffee.com/luligugithub"
|
|
59
62
|
}
|
|
63
|
+
},
|
|
64
|
+
"node_modules/p-limit": {
|
|
65
|
+
"version": "3.1.0",
|
|
66
|
+
"resolved": "https://registry.npmjs.org/p-limit/-/p-limit-3.1.0.tgz",
|
|
67
|
+
"integrity": "sha512-TYOanM3wGwNGsZN2cVTYPArw454xnXj5qmWF1bEoAc4+cU/ol7GVh7odevjp1FNHduHc3KZMcFduxU5Xc6uJRQ==",
|
|
68
|
+
"license": "MIT",
|
|
69
|
+
"dependencies": {
|
|
70
|
+
"yocto-queue": "^0.1.0"
|
|
71
|
+
},
|
|
72
|
+
"engines": {
|
|
73
|
+
"node": ">=10"
|
|
74
|
+
},
|
|
75
|
+
"funding": {
|
|
76
|
+
"url": "https://github.com/sponsors/sindresorhus"
|
|
77
|
+
}
|
|
78
|
+
},
|
|
79
|
+
"node_modules/yocto-queue": {
|
|
80
|
+
"version": "0.1.0",
|
|
81
|
+
"resolved": "https://registry.npmjs.org/yocto-queue/-/yocto-queue-0.1.0.tgz",
|
|
82
|
+
"integrity": "sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q==",
|
|
83
|
+
"license": "MIT",
|
|
84
|
+
"engines": {
|
|
85
|
+
"node": ">=10"
|
|
86
|
+
},
|
|
87
|
+
"funding": {
|
|
88
|
+
"url": "https://github.com/sponsors/sindresorhus"
|
|
89
|
+
}
|
|
60
90
|
}
|
|
61
91
|
}
|
|
62
92
|
}
|