homebridge 2.0.0-beta.30 → 2.0.0-beta.31

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 (88) hide show
  1. package/dist/api.d.ts +267 -3
  2. package/dist/api.d.ts.map +1 -1
  3. package/dist/api.js +92 -0
  4. package/dist/api.js.map +1 -1
  5. package/dist/bridgeService.d.ts +4 -2
  6. package/dist/bridgeService.d.ts.map +1 -1
  7. package/dist/bridgeService.js +1 -3
  8. package/dist/bridgeService.js.map +1 -1
  9. package/dist/childBridgeFork.d.ts +29 -2
  10. package/dist/childBridgeFork.d.ts.map +1 -1
  11. package/dist/childBridgeFork.js +294 -4
  12. package/dist/childBridgeFork.js.map +1 -1
  13. package/dist/childBridgeService.d.ts +19 -0
  14. package/dist/childBridgeService.d.ts.map +1 -1
  15. package/dist/childBridgeService.js +38 -3
  16. package/dist/childBridgeService.js.map +1 -1
  17. package/dist/externalPortService.d.ts +27 -6
  18. package/dist/externalPortService.d.ts.map +1 -1
  19. package/dist/externalPortService.js +73 -7
  20. package/dist/externalPortService.js.map +1 -1
  21. package/dist/index.d.ts +47 -1
  22. package/dist/index.d.ts.map +1 -1
  23. package/dist/index.js +15 -0
  24. package/dist/index.js.map +1 -1
  25. package/dist/ipcService.d.ts +20 -0
  26. package/dist/ipcService.d.ts.map +1 -1
  27. package/dist/ipcService.js.map +1 -1
  28. package/dist/logger.d.ts +6 -0
  29. package/dist/logger.d.ts.map +1 -1
  30. package/dist/logger.js +8 -0
  31. package/dist/logger.js.map +1 -1
  32. package/dist/matter/index.d.ts +123 -0
  33. package/dist/matter/index.d.ts.map +1 -0
  34. package/dist/matter/index.js +19 -0
  35. package/dist/matter/index.js.map +1 -0
  36. package/dist/matter/matterAccessoryCache.d.ts +96 -0
  37. package/dist/matter/matterAccessoryCache.d.ts.map +1 -0
  38. package/dist/matter/matterAccessoryCache.js +192 -0
  39. package/dist/matter/matterAccessoryCache.js.map +1 -0
  40. package/dist/matter/matterBehaviors.d.ts +194 -0
  41. package/dist/matter/matterBehaviors.d.ts.map +1 -0
  42. package/dist/matter/matterBehaviors.js +665 -0
  43. package/dist/matter/matterBehaviors.js.map +1 -0
  44. package/dist/matter/matterConfigValidator.d.ts +81 -0
  45. package/dist/matter/matterConfigValidator.d.ts.map +1 -0
  46. package/dist/matter/matterConfigValidator.js +240 -0
  47. package/dist/matter/matterConfigValidator.js.map +1 -0
  48. package/dist/matter/matterErrorHandler.d.ts +106 -0
  49. package/dist/matter/matterErrorHandler.d.ts.map +1 -0
  50. package/dist/matter/matterErrorHandler.js +495 -0
  51. package/dist/matter/matterErrorHandler.js.map +1 -0
  52. package/dist/matter/matterLogFormatter.d.ts +19 -0
  53. package/dist/matter/matterLogFormatter.d.ts.map +1 -0
  54. package/dist/matter/matterLogFormatter.js +144 -0
  55. package/dist/matter/matterLogFormatter.js.map +1 -0
  56. package/dist/matter/matterNetworkMonitor.d.ts +68 -0
  57. package/dist/matter/matterNetworkMonitor.d.ts.map +1 -0
  58. package/dist/matter/matterNetworkMonitor.js +249 -0
  59. package/dist/matter/matterNetworkMonitor.js.map +1 -0
  60. package/dist/matter/matterServer.d.ts +656 -0
  61. package/dist/matter/matterServer.d.ts.map +1 -0
  62. package/dist/matter/matterServer.js +1690 -0
  63. package/dist/matter/matterServer.js.map +1 -0
  64. package/dist/matter/matterServerHelpers.d.ts +81 -0
  65. package/dist/matter/matterServerHelpers.d.ts.map +1 -0
  66. package/dist/matter/matterServerHelpers.js +323 -0
  67. package/dist/matter/matterServerHelpers.js.map +1 -0
  68. package/dist/matter/matterSharedTypes.d.ts +170 -0
  69. package/dist/matter/matterSharedTypes.d.ts.map +1 -0
  70. package/dist/matter/matterSharedTypes.js +52 -0
  71. package/dist/matter/matterSharedTypes.js.map +1 -0
  72. package/dist/matter/matterStorage.d.ts +128 -0
  73. package/dist/matter/matterStorage.d.ts.map +1 -0
  74. package/dist/matter/matterStorage.js +415 -0
  75. package/dist/matter/matterStorage.js.map +1 -0
  76. package/dist/matter/matterTypes.d.ts +745 -0
  77. package/dist/matter/matterTypes.d.ts.map +1 -0
  78. package/dist/matter/matterTypes.js +174 -0
  79. package/dist/matter/matterTypes.js.map +1 -0
  80. package/dist/server.d.ts +23 -1
  81. package/dist/server.d.ts.map +1 -1
  82. package/dist/server.js +385 -7
  83. package/dist/server.js.map +1 -1
  84. package/dist/user.d.ts +1 -0
  85. package/dist/user.d.ts.map +1 -1
  86. package/dist/user.js +3 -0
  87. package/dist/user.js.map +1 -1
  88. package/package.json +16 -15
@@ -0,0 +1,123 @@
1
+ /**
2
+ * Matter Protocol Support for Homebridge
3
+ *
4
+ * This module provides Matter protocol support through a Plugin API,
5
+ * allowing plugin developers to explicitly register Matter accessories.
6
+ */
7
+ import type { ColorControl, DoorLock, FanControl, Groups, Identify, LevelControl, ModeBase, OnOff, ScenesManagement, ServiceArea, Thermostat, WindowCovering } from '@matter/main/clusters';
8
+ export { type MatterConfigValidationResult, MatterConfigValidator } from './matterConfigValidator.js';
9
+ export { MatterServer } from './matterServer.js';
10
+ export { HomebridgeMatterStorage, MatterStorageManager } from './matterStorage.js';
11
+ export { clusterNames, clusters, devices, deviceTypes, type InternalMatterAccessory, type MatterAccessory, type MatterClusterHandlers, type MatterClusterName, type MatterCommandHandler, MatterCommissioningError, type MatterConfig, MatterDeviceError, MatterError, type MatterErrorDetails, MatterErrorType, MatterNetworkError, MatterStorageError, } from './matterTypes.js';
12
+ /**
13
+ * Matter Cluster Command Request Types
14
+ * Use these types for handler arguments to get full type safety
15
+ *
16
+ * @example
17
+ * ```typescript
18
+ * import type { MatterRequests } from 'homebridge'
19
+ *
20
+ * handlers: {
21
+ * levelControl: {
22
+ * moveToLevel: async (args: MatterRequests.MoveToLevel) => {
23
+ * console.log(`Level: ${args.level}`)
24
+ * }
25
+ * }
26
+ * }
27
+ * ```
28
+ */
29
+ export declare namespace MatterRequests {
30
+ type OffWithEffect = OnOff.OffWithEffectRequest;
31
+ type OnWithTimedOff = OnOff.OnWithTimedOffRequest;
32
+ type MoveToLevel = LevelControl.MoveToLevelRequest;
33
+ type Move = LevelControl.MoveRequest;
34
+ type Step = LevelControl.StepRequest;
35
+ type Stop = LevelControl.StopRequest;
36
+ type MoveToClosestFrequency = LevelControl.MoveToClosestFrequencyRequest;
37
+ type MoveToHue = ColorControl.MoveToHueRequest;
38
+ type MoveHue = ColorControl.MoveHueRequest;
39
+ type StepHue = ColorControl.StepHueRequest;
40
+ type MoveToSaturation = ColorControl.MoveToSaturationRequest;
41
+ type MoveSaturation = ColorControl.MoveSaturationRequest;
42
+ type StepSaturation = ColorControl.StepSaturationRequest;
43
+ type MoveToHueAndSaturation = ColorControl.MoveToHueAndSaturationRequest;
44
+ type MoveToColor = ColorControl.MoveToColorRequest;
45
+ type MoveColor = ColorControl.MoveColorRequest;
46
+ type StepColor = ColorControl.StepColorRequest;
47
+ type MoveToColorTemperature = ColorControl.MoveToColorTemperatureRequest;
48
+ type MoveColorTemperature = ColorControl.MoveColorTemperatureRequest;
49
+ type StepColorTemperature = ColorControl.StepColorTemperatureRequest;
50
+ type StopMoveStep = ColorControl.StopMoveStepRequest;
51
+ type EnhancedMoveToHue = ColorControl.EnhancedMoveToHueRequest;
52
+ type EnhancedMoveHue = ColorControl.EnhancedMoveHueRequest;
53
+ type EnhancedStepHue = ColorControl.EnhancedStepHueRequest;
54
+ type EnhancedMoveToHueAndSaturation = ColorControl.EnhancedMoveToHueAndSaturationRequest;
55
+ type ColorLoopSet = ColorControl.ColorLoopSetRequest;
56
+ type IdentifyRequest = Identify.IdentifyRequest;
57
+ type TriggerEffect = Identify.TriggerEffectRequest;
58
+ type AddGroup = Groups.AddGroupRequest;
59
+ type ViewGroup = Groups.ViewGroupRequest;
60
+ type GetGroupMembership = Groups.GetGroupMembershipRequest;
61
+ type RemoveGroup = Groups.RemoveGroupRequest;
62
+ type AddGroupIfIdentifying = Groups.AddGroupIfIdentifyingRequest;
63
+ type AddScene = ScenesManagement.AddSceneRequest;
64
+ type ViewScene = ScenesManagement.ViewSceneRequest;
65
+ type RemoveScene = ScenesManagement.RemoveSceneRequest;
66
+ type RemoveAllScenes = ScenesManagement.RemoveAllScenesRequest;
67
+ type StoreScene = ScenesManagement.StoreSceneRequest;
68
+ type RecallScene = ScenesManagement.RecallSceneRequest;
69
+ type GetSceneMembership = ScenesManagement.GetSceneMembershipRequest;
70
+ type CopyScene = ScenesManagement.CopySceneRequest;
71
+ type LockDoor = DoorLock.LockDoorRequest;
72
+ type UnlockDoor = DoorLock.UnlockDoorRequest;
73
+ type UnlockWithTimeout = DoorLock.UnlockWithTimeoutRequest;
74
+ type UnboltDoor = DoorLock.UnboltDoorRequest;
75
+ type SetUser = DoorLock.SetUserRequest;
76
+ type GetUser = DoorLock.GetUserRequest;
77
+ type ClearUser = DoorLock.ClearUserRequest;
78
+ type SetUserStatus = DoorLock.SetUserStatusRequest;
79
+ type GetUserStatus = DoorLock.GetUserStatusRequest;
80
+ type SetUserType = DoorLock.SetUserTypeRequest;
81
+ type GetUserType = DoorLock.GetUserTypeRequest;
82
+ type SetCredential = DoorLock.SetCredentialRequest;
83
+ type GetCredentialStatus = DoorLock.GetCredentialStatusRequest;
84
+ type ClearCredential = DoorLock.ClearCredentialRequest;
85
+ type SetPinCode = DoorLock.SetPinCodeRequest;
86
+ type GetPinCode = DoorLock.GetPinCodeRequest;
87
+ type ClearPinCode = DoorLock.ClearPinCodeRequest;
88
+ type SetRfidCode = DoorLock.SetRfidCodeRequest;
89
+ type GetRfidCode = DoorLock.GetRfidCodeRequest;
90
+ type ClearRfidCode = DoorLock.ClearRfidCodeRequest;
91
+ type SetWeekDaySchedule = DoorLock.SetWeekDayScheduleRequest;
92
+ type GetWeekDaySchedule = DoorLock.GetWeekDayScheduleRequest;
93
+ type ClearWeekDaySchedule = DoorLock.ClearWeekDayScheduleRequest;
94
+ type SetYearDaySchedule = DoorLock.SetYearDayScheduleRequest;
95
+ type GetYearDaySchedule = DoorLock.GetYearDayScheduleRequest;
96
+ type ClearYearDaySchedule = DoorLock.ClearYearDayScheduleRequest;
97
+ type SetHolidaySchedule = DoorLock.SetHolidayScheduleRequest;
98
+ type GetHolidaySchedule = DoorLock.GetHolidayScheduleRequest;
99
+ type ClearHolidaySchedule = DoorLock.ClearHolidayScheduleRequest;
100
+ type SetAliroReaderConfig = DoorLock.SetAliroReaderConfigRequest;
101
+ type GoToLiftPercentage = WindowCovering.GoToLiftPercentageRequest;
102
+ type GoToTiltPercentage = WindowCovering.GoToTiltPercentageRequest;
103
+ type GoToLiftValue = WindowCovering.GoToLiftValueRequest;
104
+ type GoToTiltValue = WindowCovering.GoToTiltValueRequest;
105
+ type SetpointRaiseLower = Thermostat.SetpointRaiseLowerRequest;
106
+ type SetActivePreset = Thermostat.SetActivePresetRequest;
107
+ type SetActiveSchedule = Thermostat.SetActiveScheduleRequest;
108
+ type GetWeeklySchedule = Thermostat.GetWeeklyScheduleRequest;
109
+ type SetWeeklySchedule = Thermostat.SetWeeklyScheduleRequest;
110
+ type FanStep = FanControl.StepRequest;
111
+ type ChangeToMode = ModeBase.ChangeToModeRequest;
112
+ type SelectAreas = ServiceArea.SelectAreasRequest;
113
+ type SkipArea = ServiceArea.SkipAreaRequest;
114
+ }
115
+ /**
116
+ * Matter Cluster Types & Enums
117
+ * Import these to access type-safe enum values for cluster attributes using the original matter.js names.
118
+ *
119
+ * All 130+ Matter clusters are exported here with their original matter.js names, providing access to
120
+ * enums, types, and constants with full TypeScript autocomplete support.
121
+ */
122
+ export * as MatterTypes from '@matter/main/clusters';
123
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/matter/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,KAAK,EACV,YAAY,EACZ,QAAQ,EACR,UAAU,EACV,MAAM,EACN,QAAQ,EACR,YAAY,EACZ,QAAQ,EACR,KAAK,EACL,gBAAgB,EAChB,WAAW,EACX,UAAU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kB,CAAA;IACxD,KAAY,QAAQ,GAAG,WAAW,CAAC,eAAe,CAAA;CACnD;AAED;;;;;;GAMG;AACH,OAAO,KAAK,WAAW,MAAM,uBAAuB,CAAA"}
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Matter Protocol Support for Homebridge
3
+ *
4
+ * This module provides Matter protocol support through a Plugin API,
5
+ * allowing plugin developers to explicitly register Matter accessories.
6
+ */
7
+ export { MatterConfigValidator } from './matterConfigValidator.js';
8
+ export { MatterServer } from './matterServer.js';
9
+ export { HomebridgeMatterStorage, MatterStorageManager } from './matterStorage.js';
10
+ export { clusterNames, clusters, devices, deviceTypes, MatterCommissioningError, MatterDeviceError, MatterError, MatterErrorType, MatterNetworkError, MatterStorageError, } from './matterTypes.js';
11
+ /**
12
+ * Matter Cluster Types & Enums
13
+ * Import these to access type-safe enum values for cluster attributes using the original matter.js names.
14
+ *
15
+ * All 130+ Matter clusters are exported here with their original matter.js names, providing access to
16
+ * enums, types, and constants with full TypeScript autocomplete support.
17
+ */
18
+ export * as MatterTypes from '@matter/main/clusters';
19
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/matter/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAkBH,OAAO,EAAqC,qBAAqB,EAAE,MAAM,4BAA4B,CAAA;AACrG,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAChD,OAAO,EAAE,uBAAuB,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAA;AAClF,OAAO,EACL,YAAY,EACZ,QAAQ,EACR,OAAO,EACP,WAAW,EAMX,wBAAwB,EAExB,iBAAiB,EACjB,WAAW,EAEX,eAAe,EACf,kBAAkB,EAClB,kBAAkB,GACnB,MAAM,kBAAkB,CAAA;AA0KzB;;;;;;GAMG;AACH,OAAO,KAAK,WAAW,MAAM,uBAAuB,CAAA"}
@@ -0,0 +1,96 @@
1
+ /**
2
+ * Matter Accessory Cache
3
+ *
4
+ * Handles persistence of Matter accessories across Homebridge restarts.
5
+ * Similar to HAP's cached accessories, but designed for Matter's simpler API.
6
+ */
7
+ import type { InternalMatterAccessory } from './matterTypes.js';
8
+ /**
9
+ * Serializable Matter accessory part (excludes functions and runtime state)
10
+ */
11
+ export interface SerializedMatterAccessoryPart {
12
+ id: string;
13
+ displayName?: string;
14
+ deviceType: {
15
+ name?: string;
16
+ code?: number;
17
+ };
18
+ clusters: {
19
+ [clusterName: string]: {
20
+ [attributeName: string]: unknown;
21
+ };
22
+ };
23
+ }
24
+ /**
25
+ * Serializable Matter accessory (excludes functions and runtime state)
26
+ */
27
+ export interface SerializedMatterAccessory {
28
+ plugin: string;
29
+ platform: string;
30
+ uuid: string;
31
+ displayName: string;
32
+ deviceType: {
33
+ name?: string;
34
+ code?: number;
35
+ };
36
+ serialNumber: string;
37
+ manufacturer: string;
38
+ model: string;
39
+ firmwareRevision?: string;
40
+ hardwareRevision?: string;
41
+ softwareVersion?: string;
42
+ context?: Record<string, unknown>;
43
+ clusters?: {
44
+ [clusterName: string]: {
45
+ [attributeName: string]: unknown;
46
+ };
47
+ };
48
+ parts?: SerializedMatterAccessoryPart[];
49
+ }
50
+ /**
51
+ * Matter Accessory Cache Manager
52
+ */
53
+ export declare class MatterAccessoryCache {
54
+ private readonly cacheFilePath;
55
+ private cachedAccessories;
56
+ private cacheLoaded;
57
+ private saveQueue;
58
+ private directoryEnsured;
59
+ constructor(storagePath: string, bridgeId: string);
60
+ /**
61
+ * Load cached accessories from disk
62
+ * Returns a map of cached accessories keyed by UUID
63
+ */
64
+ load(): Promise<Map<string, SerializedMatterAccessory>>;
65
+ /**
66
+ * Save accessories to cache (serialized to prevent concurrent write conflicts)
67
+ * Uses a queue pattern to ensure saves are truly serialized even when called concurrently
68
+ */
69
+ save(accessories: Map<string, InternalMatterAccessory>): Promise<void>;
70
+ /**
71
+ * Internal save implementation
72
+ * Performs atomic write to prevent cache corruption on system crashes
73
+ */
74
+ private performSave;
75
+ /**
76
+ * Get cached accessory by UUID
77
+ */
78
+ getCached(uuid: string): SerializedMatterAccessory | undefined;
79
+ /**
80
+ * Check if an accessory is cached
81
+ */
82
+ hasCached(uuid: string): boolean;
83
+ /**
84
+ * Remove an accessory from cache
85
+ */
86
+ removeCached(uuid: string): void;
87
+ /**
88
+ * Get all cached accessories
89
+ */
90
+ getAllCached(): Map<string, SerializedMatterAccessory>;
91
+ /**
92
+ * Serialize a Matter accessory for storage
93
+ */
94
+ private serializeAccessory;
95
+ }
96
+ //# sourceMappingURL=matterAccessoryCache.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"matterAccessoryCache.d.ts","sourceRoot":"","sources":["../../src/matter/matterAccessoryCache.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,kBAAkB,CAAA;AAU/D;;GAEG;AACH,MAAM,WAAW,6BAA6B;IAC5C,EAAE,EAAE,MAAM,CAAA;IACV,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,UAAU,EAAE;QACV,IAAI,CAAC,EAAE,MAAM,CAAA;QACb,IAAI,CAAC,EAAE,MAAM,CAAA;KACd,CAAA;IACD,QAAQ,EAAE;QACR,CAAC,WAAW,EAAE,MAAM,GAAG;YACrB,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO,CAAA;SACjC,CAAA;KACF,CAAA;CACF;AAED;;GAEG;AACH,MAAM,WAAW,yBAAyB;IACxC,MAAM,EAAE,MAAM,CAAA;IACd,QAAQ,EAAE,MAAM,CAAA;IAChB,IAAI,EAAE,MAAM,CAAA;IACZ,WAAW,EAAE,MAAM,CAAA;IACnB,UAAU,EAAE;QACV,IAAI,CAAC,EAAE,MAAM,CAAA;QACb,IAAI,CAAC,EAAE,MAAM,CAAA;KACd,CAAA;IACD,YAAY,EAAE,MAAM,CAAA;IACpB,YAAY,EAAE,MAAM,CAAA;IACpB,KAAK,EAAE,MAAM,CAAA;IACb,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of Matter accessories across Homebridge restarts.
5
+ * Similar to HAP's cached accessories, but designed for Matter's simpler API.
6
+ */
7
+ import { dirname, join } from 'node:path';
8
+ import fs from 'fs-extra';
9
+ import { Logger } from '../logger.js';
10
+ const log = Logger.withPrefix('Matter/Accessories');
11
+ /**
12
+ * Matter Accessory Cache Manager
13
+ */
14
+ export class MatterAccessoryCache {
15
+ cacheFilePath;
16
+ cachedAccessories = new Map();
17
+ cacheLoaded = false;
18
+ saveQueue = Promise.resolve();
19
+ directoryEnsured = false;
20
+ constructor(storagePath, bridgeId) {
21
+ this.cacheFilePath = join(storagePath, bridgeId, 'accessories.json');
22
+ }
23
+ /**
24
+ * Load cached accessories from disk
25
+ * Returns a map of cached accessories keyed by UUID
26
+ */
27
+ async load() {
28
+ if (this.cacheLoaded) {
29
+ return this.cachedAccessories;
30
+ }
31
+ try {
32
+ // Check if cache file exists
33
+ if (!await fs.pathExists(this.cacheFilePath)) {
34
+ log.info('No cached Matter accessories found (first run)');
35
+ this.cacheLoaded = true;
36
+ return this.cachedAccessories;
37
+ }
38
+ // Read and parse cache file
39
+ const cacheData = await fs.readJson(this.cacheFilePath);
40
+ if (!Array.isArray(cacheData)) {
41
+ throw new TypeError('Cache file does not contain an array');
42
+ }
43
+ // Load accessories into map (only those with valid UUIDs)
44
+ for (const serialized of cacheData) {
45
+ if (serialized.uuid) {
46
+ this.cachedAccessories.set(serialized.uuid, serialized);
47
+ }
48
+ }
49
+ log.info(`Loaded ${this.cachedAccessories.size} cached Matter accessories`);
50
+ // Directory must exist if we successfully loaded the cache file
51
+ this.directoryEnsured = true;
52
+ this.cacheLoaded = true;
53
+ return this.cachedAccessories;
54
+ }
55
+ catch (error) {
56
+ // If JSON parsing failed (corrupted file), delete it and start fresh
57
+ log.error(`Failed to load Matter accessory cache from ${this.cacheFilePath}: ${error.message}`);
58
+ log.warn('Deleting corrupted cache file and starting fresh');
59
+ try {
60
+ await fs.remove(this.cacheFilePath);
61
+ }
62
+ catch (removeError) {
63
+ // non-fatal: couldn't delete corrupted file
64
+ log.debug('Could not delete corrupted cache file:', removeError);
65
+ }
66
+ this.cacheLoaded = true;
67
+ return this.cachedAccessories;
68
+ }
69
+ }
70
+ /**
71
+ * Save accessories to cache (serialized to prevent concurrent write conflicts)
72
+ * Uses a queue pattern to ensure saves are truly serialized even when called concurrently
73
+ */
74
+ async save(accessories) {
75
+ // Chain this save to the end of the queue
76
+ // This ensures all saves run sequentially without race conditions
77
+ this.saveQueue = this.saveQueue.then(() => this.performSave(accessories));
78
+ // Wait for this save to complete
79
+ await this.saveQueue;
80
+ }
81
+ /**
82
+ * Internal save implementation
83
+ * Performs atomic write to prevent cache corruption on system crashes
84
+ */
85
+ async performSave(accessories) {
86
+ const tempFilePath = `${this.cacheFilePath}.tmp`;
87
+ try {
88
+ // Serialize accessories (strip out functions and non-serializable objects)
89
+ const serialized = Array.from(accessories.values())
90
+ .map(accessory => this.serializeAccessory(accessory));
91
+ // Ensure directory exists (only check once, not on every save)
92
+ if (!this.directoryEnsured) {
93
+ const directory = dirname(this.cacheFilePath);
94
+ await fs.ensureDir(directory);
95
+ // Verify directory was created successfully
96
+ const dirExists = await fs.pathExists(directory);
97
+ if (!dirExists) {
98
+ throw new Error(`Failed to create cache directory: ${directory}`);
99
+ }
100
+ this.directoryEnsured = true;
101
+ log.debug(`Cache directory ensured: ${directory}`);
102
+ }
103
+ // Write to temporary file first (atomic write pattern to prevent corruption)
104
+ await fs.writeJson(tempFilePath, serialized, { spaces: 2 });
105
+ // Atomically move temp file to final location
106
+ // Use move instead of rename for better cross-device compatibility
107
+ await fs.move(tempFilePath, this.cacheFilePath, { overwrite: true });
108
+ log.debug(`Saved ${serialized.length} Matter accessor${serialized.length === 1 ? 'y' : 'ies'} to cache`);
109
+ }
110
+ catch (error) {
111
+ log.error(`Failed to save Matter accessory cache: ${error.message}`);
112
+ // Clean up temp file if it exists
113
+ try {
114
+ if (await fs.pathExists(tempFilePath)) {
115
+ await fs.remove(tempFilePath);
116
+ }
117
+ }
118
+ catch (cleanupError) {
119
+ // non-fatal: couldn't clean up temp file
120
+ log.debug('Could not clean up temporary cache file:', cleanupError);
121
+ }
122
+ }
123
+ }
124
+ /**
125
+ * Get cached accessory by UUID
126
+ */
127
+ getCached(uuid) {
128
+ return this.cachedAccessories.get(uuid);
129
+ }
130
+ /**
131
+ * Check if an accessory is cached
132
+ */
133
+ hasCached(uuid) {
134
+ return this.cachedAccessories.has(uuid);
135
+ }
136
+ /**
137
+ * Remove an accessory from cache
138
+ */
139
+ removeCached(uuid) {
140
+ this.cachedAccessories.delete(uuid);
141
+ }
142
+ /**
143
+ * Get all cached accessories
144
+ */
145
+ getAllCached() {
146
+ return new Map(this.cachedAccessories);
147
+ }
148
+ /**
149
+ * Serialize a Matter accessory for storage
150
+ */
151
+ serializeAccessory(accessory) {
152
+ // Extract device type information (EndpointType has name and code properties)
153
+ const deviceType = accessory.deviceType;
154
+ const deviceTypeInfo = {
155
+ name: deviceType?.name,
156
+ code: deviceType?.code,
157
+ };
158
+ // Serialize parts if present (excluding handlers which are functions)
159
+ let serializedParts;
160
+ if (accessory.parts && accessory.parts.length > 0) {
161
+ serializedParts = accessory.parts.map((part) => {
162
+ const partDeviceType = part.deviceType;
163
+ return {
164
+ id: part.id,
165
+ displayName: part.displayName,
166
+ deviceType: {
167
+ name: partDeviceType?.name,
168
+ code: partDeviceType?.code,
169
+ },
170
+ clusters: structuredClone(part.clusters),
171
+ };
172
+ });
173
+ }
174
+ return {
175
+ plugin: accessory._associatedPlugin || '',
176
+ platform: accessory._associatedPlatform || '',
177
+ uuid: accessory.uuid,
178
+ displayName: accessory.displayName,
179
+ deviceType: deviceTypeInfo,
180
+ serialNumber: accessory.serialNumber,
181
+ manufacturer: accessory.manufacturer,
182
+ model: accessory.model,
183
+ firmwareRevision: accessory.firmwareRevision,
184
+ hardwareRevision: accessory.hardwareRevision,
185
+ softwareVersion: accessory.softwareVersion,
186
+ context: accessory.context,
187
+ clusters: structuredClone(accessory.clusters),
188
+ parts: serializedParts,
189
+ };
190
+ }
191
+ }
192
+ //# sourceMappingURL=matterAccessoryCache.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"matterAccessoryCache.js","sourceRoot":"","sources":["../../src/matter/matterAccessoryCache.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAEzC,OAAO,EAAE,MAAM,UAAU,CAAA;AAEzB,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AAErC,MAAM,GAAG,GAAG,MAAM,CAAC,UAAU,CAAC,oBAAoB,CAAC,CAAA;AA8CnD;;GAEG;AACH,MAAM,OAAO,oBAAoB;IACd,aAAa,CAAQ;IAC9B,iBAAiB,GAA2C,IAAI,GAAG,EAAE,CAAA;IACrE,WAAW,GAAG,KAAK,CAAA;IACnB,SAAS,GAAkB,OAAO,CAAC,OAAO,EAAE,CAAA;IAC5C,gBAAgB,GAAG,KAAK,CAAA;IAEhC,YAAY,WAAmB,EAAE,QAAgB;QAC/C,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC,WAAW,EAAE,QAAQ,EAAE,kBAAkB,CAAC,CAAA;IACtE,CAAC;IAED;;;OAGG;IACH,KAAK,CAAC,IAAI;QACR,IAAI,IAAI,CAAC,WAAW,EAAE,CAAC;YACrB,OAAO,IAAI,CAAC,iBAAiB,CAAA;QAC/B,CAAC;QAED,IAAI,CAAC;YACH,6BAA6B;YAC7B,IAAI,CAAC,MAAM,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,aAAa,CAAC,EAAE,CAAC;gBAC7C,GAAG,CAAC,IAAI,CAAC,gDAAgD,CAAC,CAAA;gBAC1D,IAAI,CAAC,WAAW,GAAG,IAAI,CAAA;gBACvB,OAAO,IAAI,CAAC,iBAAiB,CAAA;YAC/B,CAAC;YAED,4BAA4B;YAC5B,MAAM,SAAS,GAAG,MAAM,EAAE,CAAC,QAAQ,CAAC,IAAI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
1
+ /**
2
+ * Custom Matter Behavior Classes for Homebridge
3
+ *
4
+ * These custom behaviors extend the base Matter.js behaviors and override
5
+ * command methods to allow plugins to inject custom handlers.
6
+ *
7
+ * Note: Only clusters with user-triggered commands need custom behaviors.
8
+ * Read-only clusters (like sensors) don't need custom behaviors since
9
+ * they only report state, they don't receive commands.
10
+ */
11
+ import type { MaybePromise } from '@matter/main';
12
+ import type { ColorControl, Identify, LevelControl, ServiceArea, Thermostat, WindowCovering } from '@matter/main/clusters';
13
+ import type { MatterAccessoryMap, MatterCommandHandler } from './matterTypes.js';
14
+ import { ColorControlServer, DoorLockServer, FanControlServer, IdentifyServer, LevelControlServer, OnOffServer, RvcCleanModeServer, RvcOperationalStateServer, RvcRunModeServer, ServiceAreaServer, ThermostatServer, WindowCoveringBaseServer } from '@matter/main/behaviors';
15
+ import { RvcOperationalState } from '@matter/main/clusters';
16
+ /**
17
+ * Result type for Matter commands
18
+ * MaybePromise allows both sync and async returns, matching Matter.js base classes
19
+ */
20
+ type MatterCommandResult = MaybePromise<void>;
21
+ /**
22
+ * Set the accessories map reference for cache syncing
23
+ */
24
+ export declare function setAccessoriesMap(map: MatterAccessoryMap): void;
25
+ /**
26
+ * Register a part endpoint mapping
27
+ * This associates a part endpoint ID with its parent accessory UUID and part ID
28
+ *
29
+ * @param endpointId - The endpoint ID (e.g., '{parentUuid}-part-{partId}')
30
+ * @param parentUuid - The parent accessory UUID
31
+ * @param partId - The part identifier within the parent
32
+ */
33
+ export declare function registerPartEndpoint(endpointId: string, parentUuid: string, partId: string): void;
34
+ /**
35
+ * Register a handler for a specific endpoint/cluster/command
36
+ *
37
+ * @param endpointId - Unique endpoint identifier (typically the accessory UUID)
38
+ * @param clusterName - Name of the Matter cluster (e.g., 'onOff', 'levelControl')
39
+ * @param commandName - Name of the command method (e.g., 'on', 'off', 'moveToLevel')
40
+ * @param handler - Callback function to execute when the command is received
41
+ *
42
+ * @example
43
+ * ```typescript
44
+ * registerHandler('my-light-uuid', 'onOff', 'on', async () => {
45
+ * console.log('Light turned on!')
46
+ * })
47
+ * ```
48
+ */
49
+ export declare function registerHandler(endpointId: string, clusterName: string, commandName: string, handler: MatterCommandHandler): void;
50
+ /**
51
+ * Custom OnOff Server that calls plugin handlers
52
+ */
53
+ export declare class HomebridgeOnOffServer extends OnOffServer {
54
+ on(): MatterCommandResult;
55
+ off(): MatterCommandResult;
56
+ toggle(): MatterCommandResult;
57
+ }
58
+ /**
59
+ * Custom LevelControl Server that calls plugin handlers
60
+ */
61
+ export declare class HomebridgeLevelControlServer extends LevelControlServer {
62
+ moveToLevel(request: LevelControl.MoveToLevelRequest): MatterCommandResult;
63
+ moveToLevelWithOnOff(request: LevelControl.MoveToLevelRequest): MaybePromise;
64
+ move(request: LevelControl.MoveRequest): MaybePromise;
65
+ step(request: LevelControl.StepRequest): MaybePromise;
66
+ stop(request: LevelControl.StopRequest): MaybePromise;
67
+ }
68
+ /**
69
+ * Custom WindowCovering Server that calls plugin handlers
70
+ */
71
+ export declare class HomebridgeWindowCoveringServer extends WindowCoveringBaseServer {
72
+ /**
73
+ * Sync window covering position state to cache
74
+ * @param endpointId - The endpoint ID
75
+ * @param targetProperty - Target position property name (e.g., 'targetPositionLiftPercent100ths')
76
+ * @param currentProperty - Current position property name (e.g., 'currentPositionLiftPercent100ths')
77
+ */
78
+ private syncPositionStateToCache;
79
+ upOrOpen(): MaybePromise;
80
+ downOrClose(): MaybePromise;
81
+ stopMotion(): MaybePromise;
82
+ goToLiftPercentage(request: WindowCovering.GoToLiftPercentageRequest): MaybePromise;
83
+ goToTiltPercentage(request: WindowCovering.GoToTiltPercentageRequest): MaybePromise;
84
+ }
85
+ /**
86
+ * Custom FanControl Server that calls plugin handlers
87
+ */
88
+ export declare class HomebridgeFanControlServer extends FanControlServer {
89
+ #private;
90
+ initialize(): void;
91
+ }
92
+ /**
93
+ * Custom DoorLock Server that calls plugin handlers
94
+ */
95
+ export declare class HomebridgeDoorLockServer extends DoorLockServer {
96
+ lockDoor(): MaybePromise;
97
+ unlockDoor(): MaybePromise;
98
+ }
99
+ /**
100
+ * Custom Thermostat Server that calls plugin handlers
101
+ */
102
+ export declare class HomebridgeThermostatServer extends ThermostatServer {
103
+ #private;
104
+ initialize(): void;
105
+ setpointRaiseLower(request: Thermostat.SetpointRaiseLowerRequest): MaybePromise;
106
+ }
107
+ /**
108
+ * Custom Identify Server that calls plugin handlers
109
+ */
110
+ export declare class HomebridgeIdentifyServer extends IdentifyServer {
111
+ identify(request: Identify.IdentifyRequest): MaybePromise;
112
+ }
113
+ /**
114
+ * Custom ColorControl Server that calls plugin handlers
115
+ *
116
+ * ColorControl handles color changes for lights (hue, saturation, XY color, color temperature).
117
+ * Plugin developers can override these *Logic methods to handle color changes in their hardware.
118
+ *
119
+ * Features (Xy, ColorTemperature, HueSaturation) are added by the device type, not this behavior.
120
+ * This ensures each device only gets the features it needs.
121
+ */
122
+ export declare class HomebridgeColorControlServer extends ColorControlServer {
123
+ /**
124
+ * Called when color temperature is changed
125
+ * @param colorTemperatureMireds - Target color temperature in mireds (micro reciprocal degrees)
126
+ * @param transitionTime - Transition time in seconds (0 = as fast as possible)
127
+ */
128
+ moveToColorTemperatureLogic(colorTemperatureMireds: number, transitionTime: number): MaybePromise;
129
+ /**
130
+ * Called when hue and saturation are changed together
131
+ * @param hue - Target hue value (0-254 for normal hue, 0-65535 for enhanced hue)
132
+ * @param saturation - Target saturation value (0-254)
133
+ * @param transitionTime - Transition time in seconds (0 = as fast as possible)
134
+ */
135
+ moveToHueAndSaturationLogic(hue: number, saturation: number, transitionTime: number): MaybePromise;
136
+ /**
137
+ * Called when XY color coordinates are changed
138
+ * @param targetX - Target X value (0-65535 representing 0.0-1.0 in CIE color space)
139
+ * @param targetY - Target Y value (0-65535 representing 0.0-1.0 in CIE color space)
140
+ * @param transitionTime - Transition time in seconds (0 = as fast as possible)
141
+ */
142
+ moveToColorLogic(targetX: number, targetY: number, transitionTime: number): MaybePromise;
143
+ /**
144
+ * Called when hue is changed individually
145
+ * @param targetHue - Target hue value
146
+ * @param direction - Direction to move (shortest, longest, up, down)
147
+ * @param transitionTime - Transition time in seconds
148
+ * @param isEnhancedHue - Whether this is enhanced hue (16-bit) or normal hue (8-bit)
149
+ */
150
+ moveToHueLogic(targetHue: number, direction: ColorControl.Direction, transitionTime: number, isEnhancedHue?: boolean): MaybePromise;
151
+ /**
152
+ * Called when saturation is changed individually
153
+ * @param targetSaturation - Target saturation value (0-254)
154
+ * @param transitionTime - Transition time in seconds
155
+ */
156
+ moveToSaturationLogic(targetSaturation: number, transitionTime: number): MaybePromise;
157
+ /**
158
+ * Called when all color movement should be stopped
159
+ */
160
+ stopAllColorMovement(): MaybePromise;
161
+ }
162
+ /**
163
+ * Custom RvcOperationalState Server that calls plugin handlers
164
+ * Handles robotic vacuum cleaner operational state commands
165
+ */
166
+ export declare class HomebridgeRvcOperationalStateServer extends RvcOperationalStateServer {
167
+ pause(): MaybePromise<RvcOperationalState.OperationalCommandResponse>;
168
+ resume(): MaybePromise<RvcOperationalState.OperationalCommandResponse>;
169
+ goHome(): MaybePromise<RvcOperationalState.OperationalCommandResponse>;
170
+ }
171
+ /**
172
+ * Custom RvcRunMode Server that calls plugin handlers
173
+ * Handles robotic vacuum cleaner run mode changes
174
+ */
175
+ export declare class HomebridgeRvcRunModeServer extends RvcRunModeServer {
176
+ changeToMode(request: any): any;
177
+ }
178
+ /**
179
+ * Custom RvcCleanMode Server that calls plugin handlers
180
+ * Handles robotic vacuum cleaner cleaning mode changes
181
+ */
182
+ export declare class HomebridgeRvcCleanModeServer extends RvcCleanModeServer {
183
+ changeToMode(request: any): any;
184
+ }
185
+ /**
186
+ * Custom ServiceArea Server that calls plugin handlers
187
+ * Handles service area selection for robotic vacuum cleaners
188
+ */
189
+ export declare class HomebridgeServiceAreaServer extends ServiceAreaServer {
190
+ selectAreas(request: ServiceArea.SelectAreasRequest): MaybePromise<ServiceArea.SelectAreasResponse>;
191
+ skipArea(request: ServiceArea.SkipAreaRequest): MaybePromise<ServiceArea.SkipAreaResponse>;
192
+ }
193
+ export {};
194
+ //# sourceMappingURL=matterBehaviors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"matterBehaviors.d.ts","sourceRoot":"","sources":["../../src/matter/matterBehaviors.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAA;AAChD,OAAO,KAAK,EACV,YAAY,EACZ,QAAQ,EACR,YAAY,EACZ,WAAW,EACX,UAAU,EACV,cAAc,EACf,MAAM,uBAAuB,CAAA;AAE9B,OAAO,KAAK,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAA;AAEhF,OAAO,EACL,kBAAkB,EAClB,cAAc,EACd,gBAAgB,EAChB,cAAc,EACd,kBAAkB,EAClB,WAAW,EACX,kBAAkB,EAClB,yBAAyB,EACzB,gBAAgB,EAChB,iBAAiB,EACjB,gBAAgB,EAChB,wBAAwB,EACzB,MAAM,wBAAwB,CAAA;AAC/B,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAA;AAO3D;;;GAGG;AACH,KAAK,mBAAmB,GAAG,YAAY,CAAC,IAAI,CAAC,CAAA;AAuF7C;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,kBAAkB,GAAG,IAAI,CAE/D;AAED;;;;;;;GAOG;AACH,wBAAgB,oBAAoB,CAAC,UAAU,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,IAAI,CAGjG;AAgCD;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,eAAe,CAC7B,UAAU,EAAE,MAAM,EAClB,WAAW,EAAE,MAAM,EACnB,WAAW,EAAE,MAAM,EACnB,OAAO,EAAE,oBAAoB,QAc9B;AAqDD;;GAEG;AACH,qBAAa,qBAAsB,SAAQ,WAAW;IAC3C,EAAE,IAAI,mBAAmB;IAUzB,GAAG,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