@switchbot/homebridge-switchbot 5.0.0-beta.2 → 5.0.0-beta.21

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 (107) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/config.schema.json +17 -2
  3. package/dist/devices-hap/device.d.ts +1 -0
  4. package/dist/devices-hap/device.d.ts.map +1 -1
  5. package/dist/devices-hap/device.js +70 -30
  6. package/dist/devices-hap/device.js.map +1 -1
  7. package/dist/devices-matter/BaseMatterAccessory.d.ts +23 -0
  8. package/dist/devices-matter/BaseMatterAccessory.d.ts.map +1 -1
  9. package/dist/devices-matter/BaseMatterAccessory.js +167 -5
  10. package/dist/devices-matter/BaseMatterAccessory.js.map +1 -1
  11. package/dist/devices-matter/ColorLightAccessory.d.ts.map +1 -1
  12. package/dist/devices-matter/ColorLightAccessory.js +12 -12
  13. package/dist/devices-matter/ColorLightAccessory.js.map +1 -1
  14. package/dist/devices-matter/ColorTemperatureLightAccessory.d.ts.map +1 -1
  15. package/dist/devices-matter/ColorTemperatureLightAccessory.js +5 -7
  16. package/dist/devices-matter/ColorTemperatureLightAccessory.js.map +1 -1
  17. package/dist/devices-matter/DimmableLightAccessory.js +9 -9
  18. package/dist/devices-matter/DimmableLightAccessory.js.map +1 -1
  19. package/dist/devices-matter/ExtendedColorLightAccessory.d.ts.map +1 -1
  20. package/dist/devices-matter/ExtendedColorLightAccessory.js +14 -15
  21. package/dist/devices-matter/ExtendedColorLightAccessory.js.map +1 -1
  22. package/dist/devices-matter/OnOffLightAccessory.d.ts.map +1 -1
  23. package/dist/devices-matter/OnOffLightAccessory.js +8 -16
  24. package/dist/devices-matter/OnOffLightAccessory.js.map +1 -1
  25. package/dist/devices-matter/OnOffOutletAccessory.d.ts +2 -0
  26. package/dist/devices-matter/OnOffOutletAccessory.d.ts.map +1 -1
  27. package/dist/devices-matter/OnOffOutletAccessory.js +10 -7
  28. package/dist/devices-matter/OnOffOutletAccessory.js.map +1 -1
  29. package/dist/devices-matter/OnOffSwitchAccessory.js +2 -2
  30. package/dist/devices-matter/OnOffSwitchAccessory.js.map +1 -1
  31. package/dist/devices-matter/baseMatterAccessory.test.d.ts +2 -0
  32. package/dist/devices-matter/baseMatterAccessory.test.d.ts.map +1 -0
  33. package/dist/devices-matter/baseMatterAccessory.test.js +71 -0
  34. package/dist/devices-matter/baseMatterAccessory.test.js.map +1 -0
  35. package/dist/index.d.ts.map +1 -1
  36. package/dist/index.js +4 -5
  37. package/dist/index.js.map +1 -1
  38. package/dist/index.test.js +7 -2
  39. package/dist/index.test.js.map +1 -1
  40. package/dist/irdevice/irdevice.d.ts +11 -10
  41. package/dist/irdevice/irdevice.d.ts.map +1 -1
  42. package/dist/irdevice/irdevice.js +76 -35
  43. package/dist/irdevice/irdevice.js.map +1 -1
  44. package/dist/platform-hap.d.ts +10 -14
  45. package/dist/platform-hap.d.ts.map +1 -1
  46. package/dist/platform-hap.js +38 -64
  47. package/dist/platform-hap.js.map +1 -1
  48. package/dist/platform-matter.cleanup.test.d.ts +2 -0
  49. package/dist/platform-matter.cleanup.test.d.ts.map +1 -0
  50. package/dist/platform-matter.cleanup.test.js +85 -0
  51. package/dist/platform-matter.cleanup.test.js.map +1 -0
  52. package/dist/platform-matter.d.ts +68 -6
  53. package/dist/platform-matter.d.ts.map +1 -1
  54. package/dist/platform-matter.js +1250 -70
  55. package/dist/platform-matter.js.map +1 -1
  56. package/dist/platform-matter.mapping.test.d.ts +2 -0
  57. package/dist/platform-matter.mapping.test.d.ts.map +1 -0
  58. package/dist/platform-matter.mapping.test.js +50 -0
  59. package/dist/platform-matter.mapping.test.js.map +1 -0
  60. package/dist/platform-matter.test.d.ts +2 -0
  61. package/dist/platform-matter.test.d.ts.map +1 -0
  62. package/dist/platform-matter.test.js +127 -0
  63. package/dist/platform-matter.test.js.map +1 -0
  64. package/dist/platform-matter.unregister.test.d.ts +2 -0
  65. package/dist/platform-matter.unregister.test.d.ts.map +1 -0
  66. package/dist/platform-matter.unregister.test.js +37 -0
  67. package/dist/platform-matter.unregister.test.js.map +1 -0
  68. package/dist/settings.d.ts +1 -0
  69. package/dist/settings.d.ts.map +1 -1
  70. package/dist/settings.js.map +1 -1
  71. package/dist/utils.d.ts +87 -0
  72. package/dist/utils.d.ts.map +1 -1
  73. package/dist/utils.js +254 -0
  74. package/dist/utils.js.map +1 -1
  75. package/dist/utils.test.d.ts +2 -0
  76. package/dist/utils.test.d.ts.map +1 -0
  77. package/dist/utils.test.js +95 -0
  78. package/dist/utils.test.js.map +1 -0
  79. package/dist/verifyconfig.test.js +2 -2
  80. package/dist/verifyconfig.test.js.map +1 -1
  81. package/docs/assets/main.js +2 -2
  82. package/docs/index.html +2 -2
  83. package/docs/variables/default.html +1 -1
  84. package/package.json +14 -14
  85. package/src/devices-hap/device.ts +68 -30
  86. package/src/devices-matter/BaseMatterAccessory.ts +168 -5
  87. package/src/devices-matter/ColorLightAccessory.ts +12 -12
  88. package/src/devices-matter/ColorTemperatureLightAccessory.ts +5 -7
  89. package/src/devices-matter/DimmableLightAccessory.ts +9 -9
  90. package/src/devices-matter/ExtendedColorLightAccessory.ts +14 -15
  91. package/src/devices-matter/OnOffLightAccessory.ts +8 -16
  92. package/src/devices-matter/OnOffOutletAccessory.ts +12 -7
  93. package/src/devices-matter/OnOffSwitchAccessory.ts +2 -2
  94. package/src/devices-matter/baseMatterAccessory.test.ts +88 -0
  95. package/src/index.test.ts +7 -2
  96. package/src/index.ts +4 -5
  97. package/src/irdevice/irdevice.ts +74 -35
  98. package/src/platform-hap.ts +39 -73
  99. package/src/platform-matter.cleanup.test.ts +101 -0
  100. package/src/platform-matter.mapping.test.ts +60 -0
  101. package/src/platform-matter.test.ts +155 -0
  102. package/src/platform-matter.ts +1286 -73
  103. package/src/platform-matter.unregister.test.ts +48 -0
  104. package/src/settings.ts +4 -0
  105. package/src/utils.test.ts +96 -0
  106. package/src/utils.ts +255 -0
  107. package/src/verifyconfig.test.ts +11 -10
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=platform-matter.cleanup.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"platform-matter.cleanup.test.d.ts","sourceRoot":"","sources":["../src/platform-matter.cleanup.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,85 @@
1
+ import { describe, expect, it, vi } from 'vitest';
2
+ import { SwitchBotMatterPlatform } from './platform-matter.js';
3
+ import { formatDeviceIdAsMac } from './utils.js';
4
+ describe('platform-matter lifecycle cleanup', () => {
5
+ it('clearDeviceResources removes timers, instances and BLE handler entries', async () => {
6
+ // Setup stubbed API and logs
7
+ const handlers = {};
8
+ const api = {
9
+ matter: {
10
+ uuid: { generate: (s) => `uuid-${s}` },
11
+ registerPlatformAccessories: vi.fn(),
12
+ unregisterPlatformAccessories: vi.fn(),
13
+ clusterNames: { OnOff: 'OnOff' },
14
+ },
15
+ isMatterAvailable: () => true,
16
+ isMatterEnabled: () => true,
17
+ on: (ev, fn) => { handlers[ev] = fn; },
18
+ _handlers: handlers,
19
+ };
20
+ const log = { info: vi.fn(), debug: vi.fn(), warn: vi.fn(), error: vi.fn(), success: vi.fn() };
21
+ const platform = new SwitchBotMatterPlatform(log, {}, api);
22
+ // Insert a fake timer, accessory instance, and BLE handler
23
+ const deviceId = 'AA:BB:CC:11:22:33';
24
+ const nid = platform.normalizeDeviceId(deviceId);
25
+ const timer = setInterval(() => { }, 100000);
26
+ platform.refreshTimers.set(nid, timer);
27
+ platform.accessoryInstances.set(nid, { dummy: true });
28
+ platform.bleEventHandler[deviceId.toLowerCase()] = () => { };
29
+ // Ensure they exist prior
30
+ expect(platform.refreshTimers.get(nid)).toBeDefined();
31
+ expect(platform.accessoryInstances.get(nid)).toBeDefined();
32
+ expect(platform.bleEventHandler[deviceId.toLowerCase()]).toBeDefined();
33
+ platform.clearDeviceResources(deviceId);
34
+ // Now they should be removed
35
+ expect(platform.refreshTimers.get(nid)).toBeUndefined();
36
+ expect(platform.accessoryInstances.get(nid)).toBeUndefined();
37
+ expect(platform.bleEventHandler[deviceId.toLowerCase()]).toBeUndefined();
38
+ });
39
+ it('shutdown handler clears all timers and handlers when invoked', async () => {
40
+ // Setup stubbed API and logs
41
+ const handlers = {};
42
+ const api = {
43
+ matter: {
44
+ uuid: { generate: (s) => `uuid-${s}` },
45
+ registerPlatformAccessories: vi.fn(),
46
+ unregisterPlatformAccessories: vi.fn(),
47
+ clusterNames: { OnOff: 'OnOff' },
48
+ },
49
+ isMatterAvailable: () => true,
50
+ isMatterEnabled: () => true,
51
+ on: (ev, fn) => { handlers[ev] = fn; },
52
+ _handlers: handlers,
53
+ };
54
+ const log = { info: vi.fn(), debug: vi.fn(), warn: vi.fn(), error: vi.fn(), success: vi.fn() };
55
+ const platform = new SwitchBotMatterPlatform(log, {}, api);
56
+ // Add two timers to the platform (using normalized ids)
57
+ const ids = ['devA', 'devB'];
58
+ for (const id of ids) {
59
+ const nid = platform.normalizeDeviceId(id);
60
+ const t = setInterval(() => { }, 100000);
61
+ platform.refreshTimers.set(nid, t);
62
+ platform.accessoryInstances.set(nid, { dummy: true });
63
+ try {
64
+ const mac = formatDeviceIdAsMac(id).toLowerCase();
65
+ platform.bleEventHandler[mac] = () => { };
66
+ }
67
+ catch {
68
+ // ignore formatting errors in this test
69
+ }
70
+ }
71
+ // Invoke didFinishLaunching to ensure the platform registered its shutdown handler
72
+ await Promise.resolve(api._handlers.didFinishLaunching?.());
73
+ // Shutdown handler should now be registered on api._handlers.shutdown
74
+ expect(typeof api._handlers.shutdown).toBe('function');
75
+ // Call the shutdown handler
76
+ await Promise.resolve(api._handlers.shutdown());
77
+ // All refresh timers should be cleared
78
+ for (const id of ids) {
79
+ const nid = platform.normalizeDeviceId(id);
80
+ expect(platform.refreshTimers.get(nid)).toBeUndefined();
81
+ expect(platform.accessoryInstances.get(nid)).toBeUndefined();
82
+ }
83
+ });
84
+ });
85
+ //# sourceMappingURL=platform-matter.cleanup.test.js.map
@@ -0,0 +1 @@
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atterAccessory } from 'homebridge';
2
+ import type { bodyChange, device } from 'node-switchbot';
2
3
  import type { SwitchBotPlatformConfig } from './settings.js';
3
- /**
4
- * MatterPlatform
5
- * Demonstrates all available Matter device types in Homebridge
6
- *
7
- * Organized by official Matter Specification v1.4.1 categories
8
- */
9
4
  export declare class SwitchBotMatterPlatform implements DynamicPlatformPlugin {
10
5
  readonly log: Logging;
11
6
  readonly config: SwitchBotPlatformConfig;
12
7
  readonly api: API;
13
8
  readonly matterAccessories: Map<string, SerializedMatterAccessory>;
9
+ private switchBotAPI?;
10
+ private switchBotBLE?;
11
+ private discoveredDevices;
12
+ private accessoryInstances;
13
+ private refreshTimers;
14
+ private bleEventHandler;
15
+ private platformLogging?;
16
+ infoLog: (...args: any[]) => void;
17
+ successLog: (...args: any[]) => void;
18
+ debugSuccessLog: (...args: any[]) => void;
19
+ warnLog: (...args: any[]) => void;
20
+ debugWarnLog: (...args: any[]) => void;
21
+ errorLog: (...args: any[]) => void;
22
+ debugErrorLog: (...args: any[]) => void;
23
+ debugLog: (...args: any[]) => void;
24
+ loggingIsDebug: () => Promise<boolean>;
25
+ enablingPlatformLogging: () => Promise<boolean>;
14
26
  constructor(log: Logging, config: SwitchBotPlatformConfig, api: API);
27
+ /**
28
+ * Normalize a deviceId for matching (uppercase alphanumerics only)
29
+ */
30
+ private normalizeDeviceId;
31
+ /**
32
+ * Clear per-device resources: refresh timers, accessory instance registry, BLE handlers
33
+ */
34
+ private clearDeviceResources;
35
+ /**
36
+ * Merge two arrays by deviceId. For each item in a1 (user-provided devices list),
37
+ * find matching item in a2 (discovered devices) and merge them with user overrides last.
38
+ */
39
+ private mergeByDeviceId;
40
+ /**
41
+ * Merge discovered devices with deviceConfig (per deviceType) and per-device overrides
42
+ * from `config.options.devices`, matching the behavior used in platform-hap.
43
+ */
44
+ private mergeDiscoveredDevices;
45
+ /**
46
+ * Select effective connection type for a device: prefer explicit device.connectionType,
47
+ * otherwise prefer BLE when platform BLE is enabled and device provides a BLE model/id.
48
+ */
49
+ private chooseConnectionType;
50
+ /**
51
+ * Map a SwitchBot device object to a MatterAccessory using the device-specific
52
+ * Matter accessory classes in `src/devices-matter`.
53
+ */
54
+ private createAccessoryFromDevice;
55
+ /**
56
+ * Discover devices via SwitchBot OpenAPI and cache them for later use
57
+ */
58
+ private discoverDevices;
59
+ /**
60
+ * Retry wrapper for control commands using SwitchBot OpenAPI
61
+ */
62
+ retryCommand(deviceObj: device, bodyChange: bodyChange, maxRetries?: number, delayBetweenRetries?: number): Promise<{
63
+ response: any;
64
+ statusCode: number;
65
+ }>;
66
+ /**
67
+ * Parse BLE advertisement/serviceData into normalized fields for a given device.
68
+ * Returns null when serviceData is falsy or parsing fails.
69
+ */
70
+ private parseAdvertisementForDevice;
71
+ /**
72
+ * Central helper to apply a SwitchBot status object to a Matter accessory.
73
+ * Tries to call accessory instance update helpers when available, otherwise
74
+ * falls back to calling api.matter.updateAccessoryState directly.
75
+ */
76
+ private applyStatusToAccessory;
15
77
  /**
16
78
  * Required for DynamicPlatformPlugin
17
79
  * Called when homebridge restores cached accessories from disk at startup
@@ -1 +1 @@
1
- {"version":3,"file":"platform-matter.d.ts","sourceRoot":"","sources":["../src/platform-matter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,GAAG,EACH,qBAAqB,EACrB,OAAO,EAEP,yBAAyB,EAC1B,MAAM,YAAY,CAAA;AAEnB,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,eAAe,CAAA;AA4B5D;;;;;GAKG;AACH,qBAAa,uBAAwB,YAAW,qBAAqB;aASjD,GAAG,EAAE,OAAO;aACZ,MAAM,EAAE,uBAAuB;aAC/B,GAAG,EAAE,GAAG;IAL1B,SAAgB,iBAAiB,EAAE,GAAG,CAAC,MAAM,EAAE,yBAAyB,CAAC,CAAY;gBAGnE,GAAG,EAAE,OAAO,EACZ,MAAM,EAAE,uBAAuB,EAC/B,GAAG,EAAE,GAAG;IAwC1B;;;OAGG;IACH,kBAAkB;IAM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