matterbridge-webhooks 0.0.3 → 0.0.4

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
@@ -8,6 +8,21 @@ If you like this project and find it useful, please consider giving it a star on
8
8
  <img src="bmc-button.svg" alt="Buy me a coffee" width="120">
9
9
  </a>
10
10
 
11
+ ## [0.0.4] - 2025-05-05
12
+
13
+ ### Changed
14
+
15
+ - [package]: Updated package.
16
+ - [package]: Updated dependencies.
17
+
18
+ ### Fixed
19
+
20
+ - [platform]: Fixed bug on unselected webhooks.
21
+
22
+ <a href="https://www.buymeacoffee.com/luligugithub">
23
+ <img src="bmc-button.svg" alt="Buy me a coffee" width="80">
24
+ </a>
25
+
11
26
  ## [0.0.3] - 2025-05-01
12
27
 
13
28
  ### Added
package/dist/platform.js CHANGED
@@ -17,30 +17,29 @@ export class Platform extends MatterbridgeDynamicPlatform {
17
17
  this.log.info('onStart called with reason:', reason ?? 'none');
18
18
  await this.ready;
19
19
  await this.clearSelect();
20
- let i = 1;
20
+ let i = 0;
21
21
  for (const webhookName in this.webhooks) {
22
- if (Object.prototype.hasOwnProperty.call(this.webhooks, webhookName)) {
23
- const webhook = this.webhooks[webhookName];
24
- this.setSelectDevice('webhook' + i, webhookName, webhook.httpUrl, 'webhook');
25
- if (!this.validateDevice(['webhook' + i, webhookName]))
26
- return;
27
- this.log.info(`Registering device: ${webhookName}`, webhook.method, webhook.httpUrl);
28
- const device = new MatterbridgeEndpoint([this.config.deviceType === 'Outlet' ? onOffOutlet : this.config.deviceType === 'Light' ? onOffLight : onOffSwitch, bridgedNode], { uniqueStorageKey: webhookName }, this.config.debug)
29
- .createDefaultBridgedDeviceBasicInformationClusterServer(webhookName, 'webhook' + i++, this.matterbridge.aggregatorVendorId, 'Matterbridge', 'Matterbridge Webhook', 0, this.config.version)
30
- .createOnOffClusterServer(false)
31
- .addRequiredClusterServers()
32
- .addCommandHandler('on', async () => {
33
- this.log.info(`Webhook ${webhookName} triggered.`);
34
- await device.setAttribute('onOff', 'onOff', false, device.log);
35
- fetch(webhook.httpUrl, webhook.method)
36
- .then(() => this.log.notice(`Webhook ${webhookName} successful!`))
37
- .catch((err) => {
38
- this.log.error(`Webhook ${webhookName} failed: ${err instanceof Error ? err.message : err}`);
39
- });
22
+ this.log.debug(`Loading webhook ${++i} ${webhookName} with method ${this.webhooks[webhookName].method} and url ${this.webhooks[webhookName].httpUrl}`);
23
+ const webhook = this.webhooks[webhookName];
24
+ this.setSelectDevice('webhook' + i, webhookName, undefined, 'hub');
25
+ if (!this.validateDevice(['webhook' + i, webhookName], true))
26
+ continue;
27
+ this.log.info(`Registering device: ${webhookName} with method ${webhook.method} and url ${webhook.httpUrl}`);
28
+ const device = new MatterbridgeEndpoint([this.config.deviceType === 'Outlet' ? onOffOutlet : this.config.deviceType === 'Light' ? onOffLight : onOffSwitch, bridgedNode], { uniqueStorageKey: webhookName }, this.config.debug)
29
+ .createDefaultBridgedDeviceBasicInformationClusterServer(webhookName, 'webhook' + i++, this.matterbridge.aggregatorVendorId, 'Matterbridge', 'Matterbridge Webhook', 0, this.config.version)
30
+ .createOnOffClusterServer(false)
31
+ .addRequiredClusterServers()
32
+ .addCommandHandler('on', async () => {
33
+ this.log.info(`Webhook ${webhookName} triggered.`);
34
+ await device.setAttribute('onOff', 'onOff', false, device.log);
35
+ fetch(webhook.httpUrl, webhook.method)
36
+ .then(() => this.log.notice(`Webhook ${webhookName} successful!`))
37
+ .catch((err) => {
38
+ this.log.error(`Webhook ${webhookName} failed: ${err instanceof Error ? err.message : err}`);
40
39
  });
41
- await this.registerDevice(device);
42
- this.bridgedDevices.set(webhookName, device);
43
- }
40
+ });
41
+ await this.registerDevice(device);
42
+ this.bridgedDevices.set(webhookName, device);
44
43
  }
45
44
  }
46
45
  async onConfigure() {
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "matterbridge-webhooks",
3
- "version": "0.0.3",
3
+ "version": "0.0.4",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "matterbridge-webhooks",
9
- "version": "0.0.3",
9
+ "version": "0.0.4",
10
10
  "license": "Apache-2.0",
11
11
  "dependencies": {
12
12
  "node-ansi-logger": "^3.0.1",
package/package.json CHANGED
@@ -1,9 +1,10 @@
1
1
  {
2
2
  "name": "matterbridge-webhooks",
3
- "version": "0.0.3",
3
+ "version": "0.0.4",
4
4
  "description": "Matterbridge webhooks plugin",
5
5
  "author": "https://github.com/Luligu",
6
6
  "license": "Apache-2.0",
7
+ "homepage": "https://www.npmjs.com/package/matterbridge-webhooks",
7
8
  "type": "module",
8
9
  "main": "dist/index.js",
9
10
  "repository": {