matterbridge 3.0.2 → 3.0.3-dev-20250517-720018f

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.
Files changed (164) hide show
  1. package/CHANGELOG.md +22 -3
  2. package/dist/cli.js +2 -37
  3. package/dist/cluster/export.js +0 -2
  4. package/dist/defaultConfigSchema.js +0 -23
  5. package/dist/deviceManager.js +1 -94
  6. package/dist/frontend.js +71 -369
  7. package/dist/helpers.js +25 -56
  8. package/dist/index.js +2 -31
  9. package/dist/logger/export.js +0 -1
  10. package/dist/matter/behaviors.js +0 -2
  11. package/dist/matter/clusters.js +0 -2
  12. package/dist/matter/devices.js +0 -2
  13. package/dist/matter/endpoints.js +0 -2
  14. package/dist/matter/export.js +0 -2
  15. package/dist/matter/types.js +0 -2
  16. package/dist/matterbridge.js +143 -873
  17. package/dist/matterbridgeAccessoryPlatform.js +0 -34
  18. package/dist/matterbridgeBehaviors.js +4 -53
  19. package/dist/matterbridgeDeviceTypes.js +34 -431
  20. package/dist/matterbridgeDynamicPlatform.js +0 -34
  21. package/dist/matterbridgeEndpoint.js +11 -807
  22. package/dist/matterbridgeEndpointHelpers.js +9 -147
  23. package/dist/matterbridgePlatform.js +7 -225
  24. package/dist/matterbridgeTypes.js +0 -24
  25. package/dist/pluginManager.js +3 -264
  26. package/dist/roboticVacuumCleaner.js +3 -39
  27. package/dist/shelly.js +7 -155
  28. package/dist/storage/export.js +0 -1
  29. package/dist/update.js +0 -53
  30. package/dist/utils/colorUtils.js +2 -205
  31. package/dist/utils/commandLine.js +0 -53
  32. package/dist/utils/copyDirectory.js +1 -37
  33. package/dist/utils/createZip.js +2 -42
  34. package/dist/utils/deepCopy.js +0 -38
  35. package/dist/utils/deepEqual.js +1 -71
  36. package/dist/utils/export.js +0 -1
  37. package/dist/utils/hex.js +0 -57
  38. package/dist/utils/isvalid.js +0 -100
  39. package/dist/utils/network.js +5 -76
  40. package/dist/utils/wait.js +20 -56
  41. package/frontend/build/asset-manifest.json +3 -3
  42. package/frontend/build/index.html +1 -1
  43. package/frontend/build/static/js/{main.f6e0f736.js → main.2486c3e3.js} +3 -3
  44. package/frontend/build/static/js/{main.f6e0f736.js.map → main.2486c3e3.js.map} +1 -1
  45. package/npm-shrinkwrap.json +2 -2
  46. package/package.json +1 -2
  47. package/dist/cli.d.ts +0 -29
  48. package/dist/cli.d.ts.map +0 -1
  49. package/dist/cli.js.map +0 -1
  50. package/dist/cluster/export.d.ts +0 -2
  51. package/dist/cluster/export.d.ts.map +0 -1
  52. package/dist/cluster/export.js.map +0 -1
  53. package/dist/defaultConfigSchema.d.ts +0 -27
  54. package/dist/defaultConfigSchema.d.ts.map +0 -1
  55. package/dist/defaultConfigSchema.js.map +0 -1
  56. package/dist/deviceManager.d.ts +0 -114
  57. package/dist/deviceManager.d.ts.map +0 -1
  58. package/dist/deviceManager.js.map +0 -1
  59. package/dist/frontend.d.ts +0 -241
  60. package/dist/frontend.d.ts.map +0 -1
  61. package/dist/frontend.js.map +0 -1
  62. package/dist/helpers.d.ts +0 -46
  63. package/dist/helpers.d.ts.map +0 -1
  64. package/dist/helpers.js.map +0 -1
  65. package/dist/index.d.ts +0 -36
  66. package/dist/index.d.ts.map +0 -1
  67. package/dist/index.js.map +0 -1
  68. package/dist/logger/export.d.ts +0 -2
  69. package/dist/logger/export.d.ts.map +0 -1
  70. package/dist/logger/export.js.map +0 -1
  71. package/dist/matter/behaviors.d.ts +0 -2
  72. package/dist/matter/behaviors.d.ts.map +0 -1
  73. package/dist/matter/behaviors.js.map +0 -1
  74. package/dist/matter/clusters.d.ts +0 -2
  75. package/dist/matter/clusters.d.ts.map +0 -1
  76. package/dist/matter/clusters.js.map +0 -1
  77. package/dist/matter/devices.d.ts +0 -2
  78. package/dist/matter/devices.d.ts.map +0 -1
  79. package/dist/matter/devices.js.map +0 -1
  80. package/dist/matter/endpoints.d.ts +0 -2
  81. package/dist/matter/endpoints.d.ts.map +0 -1
  82. package/dist/matter/endpoints.js.map +0 -1
  83. package/dist/matter/export.d.ts +0 -5
  84. package/dist/matter/export.d.ts.map +0 -1
  85. package/dist/matter/export.js.map +0 -1
  86. package/dist/matter/types.d.ts +0 -3
  87. package/dist/matter/types.d.ts.map +0 -1
  88. package/dist/matter/types.js.map +0 -1
  89. package/dist/matterbridge.d.ts +0 -435
  90. package/dist/matterbridge.d.ts.map +0 -1
  91. package/dist/matterbridge.js.map +0 -1
  92. package/dist/matterbridgeAccessoryPlatform.d.ts +0 -40
  93. package/dist/matterbridgeAccessoryPlatform.d.ts.map +0 -1
  94. package/dist/matterbridgeAccessoryPlatform.js.map +0 -1
  95. package/dist/matterbridgeBehaviors.d.ts +0 -1188
  96. package/dist/matterbridgeBehaviors.d.ts.map +0 -1
  97. package/dist/matterbridgeBehaviors.js.map +0 -1
  98. package/dist/matterbridgeDeviceTypes.d.ts +0 -494
  99. package/dist/matterbridgeDeviceTypes.d.ts.map +0 -1
  100. package/dist/matterbridgeDeviceTypes.js.map +0 -1
  101. package/dist/matterbridgeDynamicPlatform.d.ts +0 -40
  102. package/dist/matterbridgeDynamicPlatform.d.ts.map +0 -1
  103. package/dist/matterbridgeDynamicPlatform.js.map +0 -1
  104. package/dist/matterbridgeEndpoint.d.ts +0 -965
  105. package/dist/matterbridgeEndpoint.d.ts.map +0 -1
  106. package/dist/matterbridgeEndpoint.js.map +0 -1
  107. package/dist/matterbridgeEndpointHelpers.d.ts +0 -2728
  108. package/dist/matterbridgeEndpointHelpers.d.ts.map +0 -1
  109. package/dist/matterbridgeEndpointHelpers.js.map +0 -1
  110. package/dist/matterbridgePlatform.d.ts +0 -294
  111. package/dist/matterbridgePlatform.d.ts.map +0 -1
  112. package/dist/matterbridgePlatform.js.map +0 -1
  113. package/dist/matterbridgeTypes.d.ts +0 -187
  114. package/dist/matterbridgeTypes.d.ts.map +0 -1
  115. package/dist/matterbridgeTypes.js.map +0 -1
  116. package/dist/pluginManager.d.ts +0 -273
  117. package/dist/pluginManager.d.ts.map +0 -1
  118. package/dist/pluginManager.js.map +0 -1
  119. package/dist/roboticVacuumCleaner.d.ts +0 -43
  120. package/dist/roboticVacuumCleaner.d.ts.map +0 -1
  121. package/dist/roboticVacuumCleaner.js.map +0 -1
  122. package/dist/shelly.d.ts +0 -153
  123. package/dist/shelly.d.ts.map +0 -1
  124. package/dist/shelly.js.map +0 -1
  125. package/dist/storage/export.d.ts +0 -2
  126. package/dist/storage/export.d.ts.map +0 -1
  127. package/dist/storage/export.js.map +0 -1
  128. package/dist/update.d.ts +0 -58
  129. package/dist/update.d.ts.map +0 -1
  130. package/dist/update.js.map +0 -1
  131. package/dist/utils/colorUtils.d.ts +0 -61
  132. package/dist/utils/colorUtils.d.ts.map +0 -1
  133. package/dist/utils/colorUtils.js.map +0 -1
  134. package/dist/utils/commandLine.d.ts +0 -58
  135. package/dist/utils/commandLine.d.ts.map +0 -1
  136. package/dist/utils/commandLine.js.map +0 -1
  137. package/dist/utils/copyDirectory.d.ts +0 -32
  138. package/dist/utils/copyDirectory.d.ts.map +0 -1
  139. package/dist/utils/copyDirectory.js.map +0 -1
  140. package/dist/utils/createZip.d.ts +0 -38
  141. package/dist/utils/createZip.d.ts.map +0 -1
  142. package/dist/utils/createZip.js.map +0 -1
  143. package/dist/utils/deepCopy.d.ts +0 -31
  144. package/dist/utils/deepCopy.d.ts.map +0 -1
  145. package/dist/utils/deepCopy.js.map +0 -1
  146. package/dist/utils/deepEqual.d.ts +0 -53
  147. package/dist/utils/deepEqual.d.ts.map +0 -1
  148. package/dist/utils/deepEqual.js.map +0 -1
  149. package/dist/utils/export.d.ts +0 -11
  150. package/dist/utils/export.d.ts.map +0 -1
  151. package/dist/utils/export.js.map +0 -1
  152. package/dist/utils/hex.d.ts +0 -48
  153. package/dist/utils/hex.d.ts.map +0 -1
  154. package/dist/utils/hex.js.map +0 -1
  155. package/dist/utils/isvalid.d.ts +0 -102
  156. package/dist/utils/isvalid.d.ts.map +0 -1
  157. package/dist/utils/isvalid.js.map +0 -1
  158. package/dist/utils/network.d.ts +0 -69
  159. package/dist/utils/network.d.ts.map +0 -1
  160. package/dist/utils/network.js.map +0 -1
  161. package/dist/utils/wait.d.ts +0 -51
  162. package/dist/utils/wait.d.ts.map +0 -1
  163. package/dist/utils/wait.js.map +0 -1
  164. /package/frontend/build/static/js/{main.f6e0f736.js.LICENSE.txt → main.2486c3e3.js.LICENSE.txt} +0 -0
package/dist/helpers.js CHANGED
@@ -1,83 +1,53 @@
1
- /**
2
- * This file contains the helpers functions of Matterbridge.
3
- *
4
- * @file helpers.ts
5
- * @author Luca Liguori
6
- * @date 2025-05-12
7
- * @version 1.0.0
8
- *
9
- * Copyright 2025, 2026, 2027 Luca Liguori.
10
- *
11
- * Licensed under the Apache License, Version 2.0 (the "License");
12
- * you may not use this file except in compliance with the License.
13
- * You may obtain a copy of the License at
14
- *
15
- * http://www.apache.org/licenses/LICENSE-2.0
16
- *
17
- * Unless required by applicable law or agreed to in writing, software
18
- * distributed under the License is distributed on an "AS IS" BASIS,
19
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20
- * See the License for the specific language governing permissions and
21
- * limitations under the License. *
22
- */
23
- // @matter module
24
1
  import { OnOff } from '@matter/main/clusters/on-off';
25
2
  import { Endpoint } from '@matter/node';
26
3
  import { BridgedDeviceBasicInformationServer } from '@matter/node/behaviors/bridged-device-basic-information';
27
4
  import { OnOffBaseServer } from '@matter/node/behaviors/on-off';
28
5
  import { OnOffPlugInUnitDevice } from '@matter/node/devices/on-off-plug-in-unit';
29
6
  import { hasParameter } from './utils/commandLine.js';
30
- /**
31
- * Adds a virtual device to the provided endpoint, sets up an event listener for device state changes,
32
- * and ensures the device is initialized in the off state.
33
- *
34
- * @param {Endpoint<AggregatorEndpoint>} aggregatorEndpoint - The aggragator endpoint to which the virtual device will be added.
35
- * @param {string} name - The name of the virtual device. Spaces in the name are removed to form the device ID.
36
- * @param {() => Promise<void>} callback - A callback function that gets executed when the device's on/off state changes to true.
37
- * @returns {Promise<Endpoint>} A promise that resolves with the created virtual device.
38
- * @remark The virtual device is created as an instance of `Endpoint` with the `OnOffPlugInUnitDevice` device type.
39
- * The onOff state always reverts to false when the device is turned on.
40
- */
41
- export async function addVirtualDevice(aggregatorEndpoint, name, callback) {
42
- // Create a new virtual device by instantiating `Endpoint` with device information.
43
- // The device ID is created by replacing all spaces in the name with an empty string.
44
- // The node label of the bridged device basic information is set to the given name.
45
- const device = new Endpoint(OnOffPlugInUnitDevice.with(BridgedDeviceBasicInformationServer), {
46
- id: name.replaceAll(' ', ''),
7
+ import { MountedOnOffControlDevice } from '@matter/node/devices/mounted-on-off-control';
8
+ import { OnOffLightDevice } from '@matter/node/devices/on-off-light';
9
+ import { OnOffLightSwitchDevice } from '@matter/node/devices/on-off-light-switch';
10
+ export async function addVirtualDevice(aggregatorEndpoint, name, type, callback) {
11
+ let deviceType;
12
+ switch (type) {
13
+ case 'light':
14
+ deviceType = OnOffLightDevice.with(BridgedDeviceBasicInformationServer);
15
+ break;
16
+ case 'outlet':
17
+ deviceType = OnOffPlugInUnitDevice.with(BridgedDeviceBasicInformationServer);
18
+ break;
19
+ case 'switch':
20
+ deviceType = OnOffLightSwitchDevice.with(BridgedDeviceBasicInformationServer, OnOffBaseServer);
21
+ break;
22
+ case 'mounted_switch':
23
+ deviceType = MountedOnOffControlDevice.with(BridgedDeviceBasicInformationServer);
24
+ break;
25
+ }
26
+ const device = new Endpoint(deviceType, {
27
+ id: name.replaceAll(' ', '') + ':' + type,
47
28
  bridgedDeviceBasicInformation: { nodeLabel: name },
48
29
  onOff: { onOff: false, startUpOnOff: OnOff.StartUpOnOff.Off },
49
30
  });
50
- // Set up an event listener for when the `onOff` state changes.
51
31
  device.events.onOff.onOff$Changed.on(async (value) => {
52
- // If the `onOff` state becomes true, turn off the virtual device and execute the callback.
53
32
  if (value) {
54
33
  await device.setStateOf(OnOffBaseServer, { onOff: false });
55
34
  callback();
56
35
  }
57
36
  });
58
- // Add the created device to the given endpoint.
59
37
  await aggregatorEndpoint.add(device);
60
- // Initially set the state of the virtual device's `OnOffBaseServer` to false (off).
61
38
  await device.setStateOf(OnOffBaseServer, { onOff: false });
62
39
  return device;
63
40
  }
64
- /**
65
- * Creates and add the virtual devices to the aggregator.
66
- *
67
- * @param {Matterbridge} matterbridge - The Matterbridge instance.
68
- * @param {Endpoint<AggregatorEndpoint>} aggregatorEndpoint - The aggregator node to add the virtual devices to.
69
- * @returns {Promise<void>} A promise that resolves when the virtual devices are added.
70
- */
71
41
  export async function addVirtualDevices(matterbridge, aggregatorEndpoint) {
72
- if (!hasParameter('novirtual') && matterbridge.bridgeMode === 'bridge' && aggregatorEndpoint) {
42
+ if (matterbridge.matterbridgeInformation.virtualMode !== 'disabled' && matterbridge.bridgeMode === 'bridge' && aggregatorEndpoint) {
73
43
  matterbridge.log.notice(`Creating virtual devices for Matterbridge server node...`);
74
- await addVirtualDevice(aggregatorEndpoint, 'Restart Matterbridge', async () => {
44
+ await addVirtualDevice(aggregatorEndpoint, 'Restart Matterbridge', matterbridge.matterbridgeInformation.virtualMode, async () => {
75
45
  if (matterbridge.restartMode === '')
76
46
  await matterbridge.restartProcess();
77
47
  else
78
48
  await matterbridge.shutdownProcess();
79
49
  });
80
- await addVirtualDevice(aggregatorEndpoint, 'Update Matterbridge', async () => {
50
+ await addVirtualDevice(aggregatorEndpoint, 'Update Matterbridge', matterbridge.matterbridgeInformation.virtualMode, async () => {
81
51
  if (hasParameter('shelly')) {
82
52
  const { getShelly } = await import('./shelly.js');
83
53
  getShelly('/api/updates/sys/perform', 10 * 1000)
@@ -100,7 +70,7 @@ export async function addVirtualDevices(matterbridge, aggregatorEndpoint) {
100
70
  }
101
71
  });
102
72
  if (hasParameter('shelly')) {
103
- await addVirtualDevice(aggregatorEndpoint, 'Reboot Matterbridge', async () => {
73
+ await addVirtualDevice(aggregatorEndpoint, 'Reboot Matterbridge', matterbridge.matterbridgeInformation.virtualMode, async () => {
104
74
  const { postShelly } = await import('./shelly.js');
105
75
  postShelly('/api/system/reboot', {}, 60 * 1000)
106
76
  .then(() => {
@@ -113,4 +83,3 @@ export async function addVirtualDevices(matterbridge, aggregatorEndpoint) {
113
83
  }
114
84
  }
115
85
  }
116
- //# sourceMappingURL=helpers.js.map
package/dist/index.js CHANGED
@@ -1,35 +1,6 @@
1
- /**
2
- * This file contains the entry point of Matterbridge.
3
- *
4
- * @file index.ts
5
- * @author Luca Liguori
6
- * @date 2023-12-29
7
- * @version 1.0.7
8
- *
9
- * Copyright 2023, 2024, 2025 Luca Liguori.
10
- *
11
- * Licensed under the Apache License, Version 2.0 (the "License");
12
- * you may not use this file except in compliance with the License.
13
- * You may obtain a copy of the License at
14
- *
15
- * http://www.apache.org/licenses/LICENSE-2.0
16
- *
17
- * Unless required by applicable law or agreed to in writing, software
18
- * distributed under the License is distributed on an "AS IS" BASIS,
19
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20
- * See the License for the specific language governing permissions and
21
- * limitations under the License. *
22
- */
23
- // Matterbridge
24
1
  import { Matterbridge } from './matterbridge.js';
25
2
  import { hasParameter } from './utils/export.js';
26
- // AnsiLogger module
27
3
  import { AnsiLogger } from './logger/export.js';
28
- // @matter
29
- export { SemanticNamespace, ClosureTag, CompassDirectionTag, CompassLocationTag, DirectionTag, ElectricalMeasurementTag, LaundryTag, LevelTag, LocationTag, NumberTag, PositionTag, PowerSourceTag, RefrigeratorTag, RoomAirConditionerTag, SwitchesTag, } from '@matter/main';
30
- export * from '@matter/main/clusters';
31
- export * from '@matter/main/types';
32
- // Matterbridge
33
4
  export * from './matterbridge.js';
34
5
  export * from './matterbridgeTypes.js';
35
6
  export * from './matterbridgeEndpoint.js';
@@ -40,7 +11,8 @@ export * from './matterbridgePlatform.js';
40
11
  export * from './matterbridgeAccessoryPlatform.js';
41
12
  export * from './matterbridgeDynamicPlatform.js';
42
13
  export * from './roboticVacuumCleaner.js';
43
- const log = new AnsiLogger({ logName: 'Main', logTimestampFormat: 4 /* TimestampFormat.TIME_MILLIS */, logLevel: hasParameter('debug') ? "debug" /* LogLevel.DEBUG */ : "info" /* LogLevel.INFO */ });
14
+ export { addVirtualDevice } from './helpers.js';
15
+ const log = new AnsiLogger({ logName: 'Main', logTimestampFormat: 4, logLevel: hasParameter('debug') ? "debug" : "info" });
44
16
  async function main() {
45
17
  log.debug('***Matterbridge.loadInstance() called');
46
18
  await Matterbridge.loadInstance();
@@ -49,4 +21,3 @@ async function main() {
49
21
  main().catch((error) => {
50
22
  log.error(`Matterbridge.loadInstance() failed with error: ${error instanceof Error ? error.message : error}`);
51
23
  });
52
- //# sourceMappingURL=index.js.map
@@ -1,2 +1 @@
1
1
  export * from 'node-ansi-logger';
2
- //# sourceMappingURL=export.js.map
@@ -1,3 +1 @@
1
- // @matter
2
1
  export * from '@matter/node/behaviors';
3
- //# sourceMappingURL=behaviors.js.map
@@ -1,3 +1 @@
1
- // @matter
2
1
  export * from '@matter/types/clusters';
3
- //# sourceMappingURL=clusters.js.map
@@ -1,3 +1 @@
1
- // @matter
2
1
  export * from '@matter/node/devices';
3
- //# sourceMappingURL=devices.js.map
@@ -1,3 +1 @@
1
- // @matter
2
1
  export { AggregatorEndpoint, ElectricalSensorEndpoint, PowerSourceEndpoint, BridgedNodeEndpoint, RootEndpoint, DeviceEnergyManagementEndpoint, OtaProviderEndpoint, OtaRequestorEndpoint } from '@matter/node/endpoints';
3
- //# sourceMappingURL=endpoints.js.map
@@ -1,6 +1,4 @@
1
- // @matter
2
1
  export * from '@matter/main';
3
2
  export { SemanticNamespace, ClosureTag, CompassDirectionTag, CompassLocationTag, DirectionTag, ElectricalMeasurementTag, LaundryTag, LevelTag, LocationTag, NumberTag, PositionTag, PowerSourceTag, RefrigeratorTag, RoomAirConditionerTag, SwitchesTag, } from '@matter/main';
4
3
  export { AttributeElement, ClusterElement, ClusterModel, CommandElement, EventElement, FieldElement } from '@matter/main/model';
5
4
  export { logEndpoint, MdnsService, Val } from '@matter/main/protocol';
6
- //# sourceMappingURL=export.js.map
@@ -1,4 +1,2 @@
1
- // @matter
2
1
  export * from '@matter/types';
3
2
  export { ClusterRegistry } from '@matter/types';
4
- //# sourceMappingURL=types.js.map