homebridge 2.0.0-alpha.4 → 2.0.0-alpha.41

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 (124) hide show
  1. package/README.md +1 -1
  2. package/bin/homebridge.js +22 -0
  3. package/dist/api.d.ts +210 -0
  4. package/dist/api.d.ts.map +1 -0
  5. package/dist/api.js +140 -0
  6. package/dist/api.js.map +1 -0
  7. package/dist/bridgeService.d.ts +122 -0
  8. package/dist/bridgeService.d.ts.map +1 -0
  9. package/dist/bridgeService.js +396 -0
  10. package/dist/bridgeService.js.map +1 -0
  11. package/dist/childBridgeFork.d.ts +38 -0
  12. package/dist/childBridgeFork.d.ts.map +1 -0
  13. package/dist/childBridgeFork.js +241 -2
  14. package/dist/childBridgeFork.js.map +1 -7
  15. package/dist/childBridgeService.d.ts +204 -0
  16. package/dist/childBridgeService.d.ts.map +1 -0
  17. package/dist/childBridgeService.js +452 -0
  18. package/dist/childBridgeService.js.map +1 -0
  19. package/dist/childMatterBridgeFork.d.ts +108 -0
  20. package/dist/childMatterBridgeFork.d.ts.map +1 -0
  21. package/dist/childMatterBridgeFork.js +330 -0
  22. package/dist/childMatterBridgeFork.js.map +1 -0
  23. package/dist/childMatterBridgeService.d.ts +166 -0
  24. package/dist/childMatterBridgeService.d.ts.map +1 -0
  25. package/dist/childMatterBridgeService.js +623 -0
  26. package/dist/childMatterBridgeService.js.map +1 -0
  27. package/dist/cli.d.ts +3 -0
  28. package/dist/cli.d.ts.map +1 -0
  29. package/dist/cli.js +90 -2
  30. package/dist/cli.js.map +1 -7
  31. package/dist/externalPortService.d.ts +33 -0
  32. package/dist/externalPortService.d.ts.map +1 -0
  33. package/dist/externalPortService.js +59 -0
  34. package/dist/externalPortService.js.map +1 -0
  35. package/dist/index.d.ts +90 -1099
  36. package/dist/index.d.ts.map +1 -0
  37. package/dist/index.js +21 -2
  38. package/dist/index.js.map +1 -7
  39. package/dist/ipcService.d.ts +46 -0
  40. package/dist/ipcService.d.ts.map +1 -0
  41. package/dist/ipcService.js +62 -0
  42. package/dist/ipcService.js.map +1 -0
  43. package/dist/logger.d.ts +78 -0
  44. package/dist/logger.d.ts.map +1 -0
  45. package/dist/logger.js +138 -0
  46. package/dist/logger.js.map +1 -0
  47. package/dist/matter/index.d.ts +13 -0
  48. package/dist/matter/index.d.ts.map +1 -0
  49. package/dist/matter/index.js +12 -0
  50. package/dist/matter/index.js.map +1 -0
  51. package/dist/matter/matterBridge.d.ts +64 -0
  52. package/dist/matter/matterBridge.d.ts.map +1 -0
  53. package/dist/matter/matterBridge.js +154 -0
  54. package/dist/matter/matterBridge.js.map +1 -0
  55. package/dist/matter/matterConfigValidator.d.ts +27 -0
  56. package/dist/matter/matterConfigValidator.d.ts.map +1 -0
  57. package/dist/matter/matterConfigValidator.js +162 -0
  58. package/dist/matter/matterConfigValidator.js.map +1 -0
  59. package/dist/matter/matterDevice.d.ts +107 -0
  60. package/dist/matter/matterDevice.d.ts.map +1 -0
  61. package/dist/matter/matterDevice.js +913 -0
  62. package/dist/matter/matterDevice.js.map +1 -0
  63. package/dist/matter/matterDiagnostics.d.ts +121 -0
  64. package/dist/matter/matterDiagnostics.d.ts.map +1 -0
  65. package/dist/matter/matterDiagnostics.js +323 -0
  66. package/dist/matter/matterDiagnostics.js.map +1 -0
  67. package/dist/matter/matterErrorHandler.d.ts +113 -0
  68. package/dist/matter/matterErrorHandler.d.ts.map +1 -0
  69. package/dist/matter/matterErrorHandler.js +482 -0
  70. package/dist/matter/matterErrorHandler.js.map +1 -0
  71. package/dist/matter/matterNetworkMonitor.d.ts +65 -0
  72. package/dist/matter/matterNetworkMonitor.d.ts.map +1 -0
  73. package/dist/matter/matterNetworkMonitor.js +227 -0
  74. package/dist/matter/matterNetworkMonitor.js.map +1 -0
  75. package/dist/matter/matterServer.d.ts +110 -0
  76. package/dist/matter/matterServer.d.ts.map +1 -0
  77. package/dist/matter/matterServer.js +584 -0
  78. package/dist/matter/matterServer.js.map +1 -0
  79. package/dist/matter/matterSharedTypes.d.ts +167 -0
  80. package/dist/matter/matterSharedTypes.d.ts.map +1 -0
  81. package/dist/matter/matterSharedTypes.js +55 -0
  82. package/dist/matter/matterSharedTypes.js.map +1 -0
  83. package/dist/matter/matterTypes.d.ts +35 -0
  84. package/dist/matter/matterTypes.d.ts.map +1 -0
  85. package/dist/matter/matterTypes.js +278 -0
  86. package/dist/matter/matterTypes.js.map +1 -0
  87. package/dist/matter/portAllocator.d.ts +85 -0
  88. package/dist/matter/portAllocator.d.ts.map +1 -0
  89. package/dist/matter/portAllocator.js +296 -0
  90. package/dist/matter/portAllocator.js.map +1 -0
  91. package/dist/platformAccessory.d.ts +56 -0
  92. package/dist/platformAccessory.d.ts.map +1 -0
  93. package/dist/platformAccessory.js +105 -0
  94. package/dist/platformAccessory.js.map +1 -0
  95. package/dist/plugin.d.ts +30 -0
  96. package/dist/plugin.d.ts.map +1 -0
  97. package/dist/plugin.js +182 -0
  98. package/dist/plugin.js.map +1 -0
  99. package/dist/pluginManager.d.ts +77 -0
  100. package/dist/pluginManager.d.ts.map +1 -0
  101. package/dist/pluginManager.js +375 -0
  102. package/dist/pluginManager.js.map +1 -0
  103. package/dist/server.d.ts +67 -0
  104. package/dist/server.d.ts.map +1 -0
  105. package/dist/server.js +799 -0
  106. package/dist/server.js.map +1 -0
  107. package/dist/storageService.d.ts +13 -0
  108. package/dist/storageService.d.ts.map +1 -0
  109. package/dist/storageService.js +41 -0
  110. package/dist/storageService.js.map +1 -0
  111. package/dist/user.d.ts +13 -0
  112. package/dist/user.d.ts.map +1 -0
  113. package/dist/user.js +29 -0
  114. package/dist/user.js.map +1 -0
  115. package/dist/util/mac.d.ts +5 -0
  116. package/dist/util/mac.d.ts.map +1 -0
  117. package/dist/util/mac.js +14 -0
  118. package/dist/util/mac.js.map +1 -0
  119. package/dist/version.d.ts +3 -0
  120. package/dist/version.d.ts.map +1 -0
  121. package/dist/version.js +16 -0
  122. package/dist/version.js.map +1 -0
  123. package/package.json +31 -34
  124. package/bin/homebridge +0 -19
@@ -0,0 +1,167 @@
1
+ /**
2
+ * Shared Matter Types
3
+ *
4
+ * These types are used by both the homebridge core and the UI
5
+ * to ensure consistency across the Matter implementation.
6
+ */
7
+ /**
8
+ * Matter bridge status states
9
+ */
10
+ export declare enum MatterBridgeStatus {
11
+ /**
12
+ * When the Matter bridge is loading or restarting
13
+ */
14
+ PENDING = "pending",
15
+ /**
16
+ * The Matter bridge is online and ready for commissioning
17
+ */
18
+ OK = "ok",
19
+ /**
20
+ * The bridge is shutting down or stopped
21
+ */
22
+ DOWN = "down"
23
+ }
24
+ /**
25
+ * Metadata for a Matter bridge instance
26
+ */
27
+ export interface MatterBridgeMetadata {
28
+ /** Bridge type identifier */
29
+ type: 'matter';
30
+ /** Current operational status */
31
+ status: MatterBridgeStatus;
32
+ /** Matter server port */
33
+ port?: number;
34
+ /** QR code payload for commissioning */
35
+ qrCode?: string;
36
+ /** Manual pairing code for commissioning */
37
+ manualPairingCode?: string;
38
+ /** Device serial number */
39
+ serialNumber?: string;
40
+ /** Display name of the bridge */
41
+ name: string;
42
+ /** Plugin identifier */
43
+ plugin: string;
44
+ /** Unique identifier for this bridge instance */
45
+ identifier: string;
46
+ /** Number of devices exposed by this bridge */
47
+ deviceCount: number;
48
+ /** Whether the bridge was manually stopped */
49
+ manuallyStopped?: boolean;
50
+ /** Process ID of the bridge if running as child process */
51
+ pid?: number;
52
+ /** Whether the bridge has been commissioned */
53
+ commissioned?: boolean;
54
+ }
55
+ /**
56
+ * Matter commissioning information
57
+ */
58
+ export interface MatterCommissioningInfo {
59
+ /** QR code payload for commissioning */
60
+ qrCode?: string;
61
+ /** Manual pairing code for commissioning */
62
+ manualPairingCode?: string;
63
+ /** Device serial number */
64
+ serialNumber?: string;
65
+ /** Whether the device is commissioned */
66
+ commissioned: boolean;
67
+ }
68
+ /**
69
+ * Matter accessory information
70
+ */
71
+ export interface MatterAccessoryInfo {
72
+ /** Unique identifier */
73
+ uuid: string;
74
+ /** Display name */
75
+ displayName: string;
76
+ /** HAP category */
77
+ category: number;
78
+ /** Matter device information */
79
+ matterInfo?: {
80
+ /** Whether this is a bridged device */
81
+ bridged: boolean;
82
+ /** Child bridge identifier if bridged */
83
+ childBridge?: string;
84
+ /** Matter device type */
85
+ deviceType?: string;
86
+ };
87
+ /** HAP services */
88
+ services?: Array<{
89
+ type: string;
90
+ subtype?: string;
91
+ displayName?: string;
92
+ characteristics: Array<{
93
+ type: string;
94
+ value: any;
95
+ props: any;
96
+ }>;
97
+ }>;
98
+ }
99
+ /**
100
+ * Matter server configuration
101
+ */
102
+ export interface MatterServerConfig {
103
+ /** Server port */
104
+ port?: number;
105
+ /** Bridge name */
106
+ name?: string;
107
+ /** Unique identifier */
108
+ uniqueId?: string;
109
+ /** Storage path */
110
+ storagePath?: string;
111
+ /** mDNS interface */
112
+ mdnsInterface?: string;
113
+ /** Enable IPv4 */
114
+ ipv4?: boolean;
115
+ /** Enable IPv6 */
116
+ ipv6?: boolean;
117
+ }
118
+ /**
119
+ * Child Matter configuration (extends server config)
120
+ */
121
+ export interface ChildMatterConfiguration extends Partial<MatterServerConfig> {
122
+ /** Whether Matter is enabled */
123
+ enabled?: boolean;
124
+ /** Bridge name override */
125
+ name?: string;
126
+ /** Debug mode flag */
127
+ debug?: boolean;
128
+ }
129
+ /**
130
+ * Matter accessories collection
131
+ */
132
+ export interface MatterAccessoriesResponse {
133
+ /** Child bridge accessories indexed by bridge ID */
134
+ children: {
135
+ [bridgeId: string]: MatterAccessoryInfo[];
136
+ };
137
+ }
138
+ /**
139
+ * IPC message types for Matter child bridges
140
+ */
141
+ export declare enum ChildMatterMessageType {
142
+ /** Sent from child when ready to accept config */
143
+ READY = "ready",
144
+ /** Sent to child with configuration */
145
+ LOAD = "load",
146
+ /** Sent from child when loaded */
147
+ LOADED = "loaded",
148
+ /** Sent to child to start the Matter bridge */
149
+ START = "start",
150
+ /** Sent from child when Matter bridge is online */
151
+ ONLINE = "online",
152
+ /** Sent to/from child to add an accessory */
153
+ ADD_ACCESSORY = "addAccessory",
154
+ /** Sent to/from child to remove an accessory */
155
+ REMOVE_ACCESSORY = "removeAccessory",
156
+ /** Sent from child with status updates */
157
+ STATUS_UPDATE = "statusUpdate",
158
+ /** Sent from child when requesting a port */
159
+ PORT_REQUEST = "portRequest",
160
+ /** Sent from child when an error occurs */
161
+ ERROR = "error",
162
+ /** Sent to child with allocated port */
163
+ PORT_ALLOCATED = "portAllocated",
164
+ /** Sent to child to shut down */
165
+ SHUTDOWN = "shutdown"
166
+ }
167
+ //# sourceMappingURL=matterSharedTypes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"matterSharedTypes.d.ts","sourceRoot":"","sources":["../../src/matter/matterSharedTypes.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;GAEG;AACH,oBAAY,kBAAkB;IAC5B;;OAEG;IACH,OAAO,YAAY;IAEnB;;OAEG;IACH,EAAE,OAAO;IAET;;OAEG;IACH,IAAI,SAAS;CACd;AAED;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,6BAA6B;IAC7B,IAAI,EAAE,QAAQ,CAAA;IACd,iCAAiC;IACjC,MAAM,EAAE,kBAAkB,CAAA;IAC1B,yBAAyB;IACzB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,wCAAwC;IACxC,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,4CAA4C;IAC5C,iBAAiB,CAAC,EAAE,MAAM,CAAA;IAC1B,2BAA2B;IAC3B,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,iCAAiC;IACjC,IAAI,EAAE,MAAM,CAAA;IACZ,wBAAwB;IACxB,MAAM,EAAE,MAAM,CAAA;IACd,iDAAiD;IACjD,UAAU,EAAE,MAAM,CAAA;IAClB,+CAA+C;IAC/C,WAAW,EAAE,MAAM,CAAA;IACnB,8CAA8C;IAC9C,eAAe,CAAC,EAAE,OAAO,CAAA;IACzB,2DAA2D;IAC3D,GAAG,CA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CAAA;IACpB,qBAAqB;IACrB,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,kBAAkB;IAClB,IAAI,CAAC,EAAE,OAAO,CAAA;IACd,kBAAkB;IAClB,IAAI,CAAC,EAAE,OAAO,CAAA;CACf;AAED;;GAEG;AACH,MAAM,WAAW,wBAAyB,SAAQ,OAAO,CAAC,kBAAkB,CAAC;IAC3E,gCAAgC;IAChC,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,2BAA2B;IAC3B,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,sBAAsB;IACtB,KAAK,CAAC,EAAE,OAAO,CAAA;CAChB;AAED;;GAEG;AACH,MAAM,WAAW,yBAAyB;IACxC,oDAAoD;IACpD,QAAQ,EAAE;QAAE,CAAC,QAAQ,EAAE,MAAM,GAAG,mBAAmB,EAAE,CAAA;KAAE,CAAA;CACxD;AAED;;GAEG;AACH,oBAAY,sBAAsB;IAChC,kDAAkD;IAClD,KAAK,UAAU;IACf,uCAAuC;IACvC,IAAI,SAAS;IACb,kCAAkC;IAClC,MAAM,WAAW;IACjB,+CAA+C;IAC/C,KAAK,UAAU;IACf,mDAAmD;IACnD,MAAM,WAAW;IACjB,6CAA6C;IAC7C,aAAa,iBAAiB;IAC9B,gDAAgD;IAChD,gBAAgB,oBAAoB;IACpC,0CAA0C;IAC1C,aAAa,iBAAiB;IAC9B,6CAA6C;IAC7C,YAAY,gBAAgB;IAC5B,2CAA2C;IAC3C,KAAK,UAAU;IACf,wCAAwC;IACxC,cAAc,kBAAkB;IAChC,iCAAiC;IACjC,QAAQ,aAAa;CACtB"}
@@ -0,0 +1,55 @@
1
+ /**
2
+ * Shared Matter Types
3
+ *
4
+ * These types are used by both the homebridge core and the UI
5
+ * to ensure consistency across the Matter implementation.
6
+ */
7
+ /**
8
+ * Matter bridge status states
9
+ */
10
+ export var MatterBridgeStatus;
11
+ (function (MatterBridgeStatus) {
12
+ /**
13
+ * When the Matter bridge is loading or restarting
14
+ */
15
+ MatterBridgeStatus["PENDING"] = "pending";
16
+ /**
17
+ * The Matter bridge is online and ready for commissioning
18
+ */
19
+ MatterBridgeStatus["OK"] = "ok";
20
+ /**
21
+ * The bridge is shutting down or stopped
22
+ */
23
+ MatterBridgeStatus["DOWN"] = "down";
24
+ })(MatterBridgeStatus || (MatterBridgeStatus = {}));
25
+ /**
26
+ * IPC message types for Matter child bridges
27
+ */
28
+ export var ChildMatterMessageType;
29
+ (function (ChildMatterMessageType) {
30
+ /** Sent from child when ready to accept config */
31
+ ChildMatterMessageType["READY"] = "ready";
32
+ /** Sent to child with configuration */
33
+ ChildMatterMessageType["LOAD"] = "load";
34
+ /** Sent from child when loaded */
35
+ ChildMatterMessageType["LOADED"] = "loaded";
36
+ /** Sent to child to start the Matter bridge */
37
+ ChildMatterMessageType["START"] = "start";
38
+ /** Sent from child when Matter bridge is online */
39
+ ChildMatterMessageType["ONLINE"] = "online";
40
+ /** Sent to/from child to add an accessory */
41
+ ChildMatterMessageType["ADD_ACCESSORY"] = "addAccessory";
42
+ /** Sent to/from child to remove an accessory */
43
+ ChildMatterMessageType["REMOVE_ACCESSORY"] = "removeAccessory";
44
+ /** Sent from child with status updates */
45
+ ChildMatterMessageType["STATUS_UPDATE"] = "statusUpdate";
46
+ /** Sent from child when requesting a port */
47
+ ChildMatterMessageType["PORT_REQUEST"] = "portRequest";
48
+ /** Sent from child when an error occurs */
49
+ ChildMatterMessageType["ERROR"] = "error";
50
+ /** Sent to child with allocated port */
51
+ ChildMatterMessageType["PORT_ALLOCATED"] = "portAllocated";
52
+ /** Sent to child to shut down */
53
+ ChildMatterMessageType["SHUTDOWN"] = "shutdown";
54
+ })(ChildMatterMessageType || (ChildMatterMessageType = {}));
55
+ //# sourceMappingURL=matterSharedTypes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"matterSharedTypes.js","sourceRoot":"","sources":["../../src/matter/matterSharedTypes.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;GAEG;AACH,MAAM,CAAN,IAAY,kBAeX;AAfD,WAAY,kBAAkB;IAC5B;;OAEG;IACH,yCAAmB,CAAA;IAEnB;;OAEG;IACH,+BAAS,CAAA;IAET;;OAEG;IACH,mCAAa,CAAA;AACf,CAAC,EAfW,kBAAkB,KAAlB,kBAAkB,QAe7B;AAwHD;;GAEG;AACH,MAAM,CAAN,IAAY,sBAyBX;AAzBD,WAAY,sBAAsB;IAChC,kDAAkD;IAClD,yCAAe,CAAA;IACf,uCAAuC;IACvC,uCAAa,CAAA;IACb,kCAAkC;IAClC,2CAAiB,CAAA;IACjB,+CAA+C;IAC/C,yCAAe,CAAA;IACf,mDAAmD;IACnD,2CAAiB,CAAA;IACjB,6CAA6C;IAC7C,wDAA8B,CAAA;IAC9B,gDAAgD;IAChD,8DAAoC,CAAA;IACpC,0CAA0C;IAC1C,wDAA8B,CAAA;IAC9B,6CAA6C;IAC7C,sDAA4B,CAAA;IAC5B,2CAA2C;IAC3C,yCAAe,CAAA;IACf,wCAAwC;IACxC,0DAAgC,CAAA;IAChC,iCAAiC;IACjC,+CAAqB,CAAA;AACvB,CAAC,EAzBW,sBAAsB,KAAtB,sBAAsB,QAyBjC"}
@@ -0,0 +1,35 @@
1
+ import { HomebridgeOptions } from '../server.js';
2
+ /**
3
+ * Matter bridge configuration interface
4
+ */
5
+ export interface MatterConfiguration {
6
+ port?: number;
7
+ name?: string;
8
+ }
9
+ /**
10
+ * Matter bridge options extending Homebridge options
11
+ */
12
+ export interface MatterBridgeOptions extends HomebridgeOptions {
13
+ matterBridgeServerPort?: number;
14
+ configPath?: string;
15
+ }
16
+ declare const MatterClusters: Record<string, unknown>;
17
+ declare const MatterDeviceTypes: Record<string, unknown>;
18
+ /**
19
+ * Maps common HomeKit service types to appropriate Matter clusters
20
+ */
21
+ export declare const HAPToMatterClusterMapping: Record<string, string[]>;
22
+ /**
23
+ * Maps common HomeKit service types to appropriate Matter device types
24
+ */
25
+ export declare const HAPToMatterDeviceMapping: Record<string, string>;
26
+ /**
27
+ * Helper function to get Matter device type for a HomeKit service
28
+ */
29
+ export declare function getMatterDeviceTypeForHAPService(serviceType: string, characteristics?: string[]): string | null;
30
+ /**
31
+ * Helper function to get Matter clusters for a HomeKit service
32
+ */
33
+ export declare function getMatterClustersForHAPService(serviceType: string, characteristics?: string[]): string[];
34
+ export { MatterClusters, MatterDeviceTypes };
35
+ //# sourceMappingURL=matterTypes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"matterTypes.d.ts","sourceRoot":"","sources":["../../src/matter/matterTypes.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAA;AAEhD;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,IAAI,CAAC,EAAE,MAAM,CAAA;CACd;AAED;;GAEG;AACH,MAAM,WAAW,mBAAoB,SAAQ,iBAAiB;IAC5D,sBAAsB,CAAC,EAAE,MAAM,CAAA;IAC/B,UAAU,CAAC,EAAE,MAAM,CAAA;CACpB;AAGD,QAAA,MAAM,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAM,CAAA;AAClD,QAAA,MAAM,iBAAiB,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAM,CAAA;AAuHrD;;GAEG;AACH,eAAO,MAAM,yBAAyB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAoF9D,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,wBAAwB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAmC3D,CAAA;AAED;;GAEG;AACH,wBAAgB,gCAAgC,CAAC,WAAW,EAAE,MAAM,EAAE,eAAe,CAAC,EAAE,MAAM,EAAE,GAAG,MAAM,GAAG,IAAI,CAwB/G;AAED;;GAEG;AACH,wBAAgB,8BAA8B,CAAC,WAAW,EAAE,MAAM,EAAE,eAAe,CAAC,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE,CA2BxG;AAED,OAAO,EAAE,cAAc,EAAE,iBAAiB,EAAE,CAAA"}
@@ -0,0 +1,278 @@
1
+ // Import Matter.js clusters and device types
2
+ import * as clusters from '@matter/main/clusters';
3
+ import * as devices from '@matter/main/devices';
4
+ /**
5
+ * Matter Device Types and Clusters for plugin developers
6
+ *
7
+ * This module provides access to standard Matter device types and clusters
8
+ * that plugin developers can use to create Matter-compatible devices.
9
+ */
10
+ import { Logger } from '../logger.js';
11
+ const log = Logger.withPrefix('Matter');
12
+ const MatterClusters = {};
13
+ const MatterDeviceTypes = {};
14
+ try {
15
+ // Import commonly used clusters from Matter.js
16
+ // Export the most commonly used clusters for HomeKit-to-Matter conversion
17
+ Object.assign(MatterClusters, {
18
+ // Basic clusters
19
+ OnOffCluster: clusters.OnOffCluster,
20
+ LevelControlCluster: clusters.LevelControlCluster,
21
+ ColorControlCluster: clusters.ColorControlCluster,
22
+ IdentifyCluster: clusters.IdentifyCluster,
23
+ // Sensor clusters
24
+ TemperatureMeasurementCluster: clusters.TemperatureMeasurementCluster,
25
+ RelativeHumidityMeasurementCluster: clusters.RelativeHumidityMeasurementCluster,
26
+ IlluminanceMeasurementCluster: clusters.IlluminanceMeasurementCluster,
27
+ OccupancySensingCluster: clusters.OccupancySensingCluster,
28
+ PressureMeasurementCluster: clusters.PressureMeasurementCluster,
29
+ FlowMeasurementCluster: clusters.FlowMeasurementCluster,
30
+ // Security clusters
31
+ DoorLockCluster: clusters.DoorLockCluster,
32
+ SmokeCoAlarmCluster: clusters.SmokeCoAlarmCluster,
33
+ BooleanStateCluster: clusters.BooleanStateCluster,
34
+ // HVAC clusters
35
+ ThermostatCluster: clusters.ThermostatCluster,
36
+ FanControlCluster: clusters.FanControlCluster,
37
+ // Window covering clusters
38
+ WindowCoveringCluster: clusters.WindowCoveringCluster,
39
+ // Switch clusters
40
+ SwitchCluster: clusters.SwitchCluster,
41
+ // General clusters
42
+ BasicInformationCluster: clusters.BasicInformationCluster,
43
+ BridgedDeviceBasicInformationCluster: clusters.BridgedDeviceBasicInformationCluster,
44
+ DescriptorCluster: clusters.DescriptorCluster,
45
+ PowerSourceCluster: clusters.PowerSourceCluster,
46
+ GeneralDiagnosticsCluster: clusters.GeneralDiagnosticsCluster,
47
+ // Media clusters
48
+ MediaInputCluster: clusters.MediaInputCluster,
49
+ MediaPlaybackCluster: clusters.MediaPlaybackCluster,
50
+ AudioOutputCluster: clusters.AudioOutputCluster,
51
+ // Appliance clusters
52
+ ModeSelectCluster: clusters.ModeSelectCluster,
53
+ OperationalStateCluster: clusters.OperationalStateCluster,
54
+ });
55
+ log.debug('Matter clusters loaded successfully');
56
+ }
57
+ catch (error) {
58
+ log.warn('Failed to load Matter clusters:', error);
59
+ Object.keys(MatterClusters).forEach(key => delete MatterClusters[key]);
60
+ }
61
+ try {
62
+ // Export the most commonly used device types for HomeKit-to-Matter conversion
63
+ Object.assign(MatterDeviceTypes, {
64
+ // Lighting devices
65
+ OnOffLight: devices.OnOffLightDevice,
66
+ DimmableLight: devices.DimmableLightDevice,
67
+ ColorTemperatureLight: devices.ColorTemperatureLightDevice,
68
+ ExtendedColorLight: devices.ExtendedColorLightDevice,
69
+ // Switch devices
70
+ OnOffLightSwitch: devices.OnOffLightSwitchDevice,
71
+ DimmerSwitch: devices.DimmerSwitchDevice,
72
+ // Outlet devices
73
+ OnOffPlugInUnit: devices.OnOffPlugInUnitDevice,
74
+ DimmablePlugInUnit: devices.DimmablePlugInUnitDevice,
75
+ // Sensor devices
76
+ TemperatureSensor: devices.TemperatureSensorDevice,
77
+ HumiditySensor: devices.HumiditySensorDevice,
78
+ LightSensor: devices.LightSensorDevice,
79
+ OccupancySensor: devices.OccupancySensorDevice,
80
+ ContactSensor: devices.ContactSensorDevice,
81
+ PressureSensor: devices.PressureSensorDevice,
82
+ FlowSensor: devices.FlowSensorDevice,
83
+ OnOffSensor: devices.OnOffSensorDevice,
84
+ // Security devices
85
+ DoorLock: devices.DoorLockDevice,
86
+ DoorLockController: devices.DoorLockControllerDevice,
87
+ SmokeCoAlarm: devices.SmokeCoAlarmDevice,
88
+ WaterLeakDetector: devices.WaterLeakDetectorDevice,
89
+ WaterFreezeDetector: devices.WaterFreezeDetectorDevice,
90
+ // HVAC devices
91
+ Thermostat: devices.ThermostatDevice,
92
+ Fan: devices.FanDevice,
93
+ // Window covering devices
94
+ WindowCovering: devices.WindowCoveringDevice,
95
+ WindowCoveringController: devices.WindowCoveringControllerDevice,
96
+ // Appliance devices
97
+ // ModeSelect: devices.ModeSelect, // Removed because it does not exist
98
+ // Water management
99
+ // WaterValve: devices.WaterValve, // Removed because it does not exist
100
+ // Pump: devices.Pump, // Removed because it does not exist
101
+ // PumpController: devices.PumpController, // Removed because it does not exist
102
+ // Other common devices
103
+ // ControlBridge: devices.ControlBridge, // Removed because it does not exist
104
+ // Speaker: devices.Speaker, // Removed because it does not exist
105
+ });
106
+ log.debug('Matter device types loaded successfully');
107
+ }
108
+ catch (error) {
109
+ log.warn('Failed to load Matter device types:', error);
110
+ Object.keys(MatterDeviceTypes).forEach(key => delete MatterDeviceTypes[key]);
111
+ }
112
+ /**
113
+ * Maps common HomeKit service types to appropriate Matter clusters
114
+ */
115
+ export const HAPToMatterClusterMapping = {
116
+ // Lighting services
117
+ Lightbulb: [
118
+ 'OnOffCluster',
119
+ 'LevelControlCluster',
120
+ 'ColorControlCluster',
121
+ ],
122
+ // Switch services
123
+ Switch: [
124
+ 'OnOffCluster',
125
+ ],
126
+ // Outlet services
127
+ Outlet: [
128
+ 'OnOffCluster',
129
+ ],
130
+ // Sensor services
131
+ TemperatureSensor: [
132
+ 'TemperatureMeasurementCluster',
133
+ ],
134
+ HumiditySensor: [
135
+ 'RelativeHumidityMeasurementCluster',
136
+ ],
137
+ LightSensor: [
138
+ 'IlluminanceMeasurementCluster',
139
+ ],
140
+ MotionSensor: [
141
+ 'OccupancySensingCluster',
142
+ ],
143
+ OccupancySensor: [
144
+ 'OccupancySensingCluster',
145
+ ],
146
+ ContactSensor: [
147
+ 'BooleanStateCluster',
148
+ ],
149
+ LeakSensor: [
150
+ 'BooleanStateCluster',
151
+ ],
152
+ SmokeSensor: [
153
+ 'SmokeCoAlarmCluster',
154
+ ],
155
+ CarbonMonoxideSensor: [
156
+ 'SmokeCoAlarmCluster',
157
+ ],
158
+ // Security services
159
+ LockManagement: [
160
+ 'DoorLockCluster',
161
+ ],
162
+ SecuritySystem: [
163
+ 'BooleanStateCluster',
164
+ ],
165
+ // HVAC services
166
+ Thermostat: [
167
+ 'ThermostatCluster',
168
+ ],
169
+ Fan: [
170
+ 'FanControlCluster',
171
+ ],
172
+ Fanv2: [
173
+ 'FanControlCluster',
174
+ ],
175
+ HeaterCooler: [
176
+ 'ThermostatCluster',
177
+ ],
178
+ // Window covering services
179
+ WindowCovering: [
180
+ 'WindowCoveringCluster',
181
+ ],
182
+ // Other services
183
+ StatelessProgrammableSwitch: [
184
+ 'SwitchCluster',
185
+ ],
186
+ Valve: [
187
+ 'OnOffCluster',
188
+ ],
189
+ IrrigationSystem: [
190
+ 'OnOffCluster',
191
+ ],
192
+ };
193
+ /**
194
+ * Maps common HomeKit service types to appropriate Matter device types
195
+ */
196
+ export const HAPToMatterDeviceMapping = {
197
+ // Lighting services
198
+ Lightbulb: 'OnOffLight', // Default to basic light, can be upgraded based on characteristics
199
+ // Switch services
200
+ Switch: 'OnOffLightSwitch',
201
+ // Outlet services
202
+ Outlet: 'OnOffPlugInUnit',
203
+ // Sensor services
204
+ TemperatureSensor: 'TemperatureSensor',
205
+ HumiditySensor: 'HumiditySensor',
206
+ LightSensor: 'LightSensor',
207
+ MotionSensor: 'OccupancySensor',
208
+ OccupancySensor: 'OccupancySensor',
209
+ ContactSensor: 'ContactSensor',
210
+ LeakSensor: 'WaterLeakDetector',
211
+ SmokeSensor: 'SmokeCoAlarm',
212
+ CarbonMonoxideSensor: 'SmokeCoAlarm',
213
+ // Security services
214
+ LockManagement: 'DoorLock',
215
+ // HVAC services
216
+ Thermostat: 'Thermostat',
217
+ Fan: 'Fan',
218
+ Fanv2: 'Fan',
219
+ // Window covering services
220
+ WindowCovering: 'WindowCovering',
221
+ // Other services
222
+ StatelessProgrammableSwitch: 'OnOffLightSwitch', // Use light switch as closest match
223
+ Valve: 'OnOffPlugInUnit', // Use outlet as closest match for valve control
224
+ };
225
+ /**
226
+ * Helper function to get Matter device type for a HomeKit service
227
+ */
228
+ export function getMatterDeviceTypeForHAPService(serviceType, characteristics) {
229
+ const baseDeviceType = HAPToMatterDeviceMapping[serviceType];
230
+ if (!baseDeviceType) {
231
+ return null;
232
+ }
233
+ // Upgrade device type based on available characteristics for lighting
234
+ if (serviceType === 'Lightbulb' && characteristics) {
235
+ if (characteristics.includes('Hue') && characteristics.includes('Saturation')) {
236
+ return 'ExtendedColorLight';
237
+ }
238
+ else if (characteristics.includes('ColorTemperature')) {
239
+ return 'ColorTemperatureLight';
240
+ }
241
+ else if (characteristics.includes('Brightness')) {
242
+ return 'DimmableLight';
243
+ }
244
+ }
245
+ // Upgrade outlet type based on dimming capability
246
+ if (serviceType === 'Outlet' && characteristics?.includes('Brightness')) {
247
+ return 'DimmablePlugInUnit';
248
+ }
249
+ return baseDeviceType;
250
+ }
251
+ /**
252
+ * Helper function to get Matter clusters for a HomeKit service
253
+ */
254
+ export function getMatterClustersForHAPService(serviceType, characteristics) {
255
+ const baseClusters = HAPToMatterClusterMapping[serviceType] || [];
256
+ // Add conditional clusters based on characteristics
257
+ const result = [...baseClusters];
258
+ if (characteristics) {
259
+ if (serviceType === 'Lightbulb') {
260
+ // Only add level control if brightness is supported
261
+ if (characteristics.includes('Brightness') && !result.includes('LevelControlCluster')) {
262
+ result.push('LevelControlCluster');
263
+ }
264
+ // Only add color control if color characteristics are supported
265
+ if ((characteristics.includes('Hue') || characteristics.includes('ColorTemperature'))
266
+ && !result.includes('ColorControlCluster')) {
267
+ result.push('ColorControlCluster');
268
+ }
269
+ }
270
+ }
271
+ // Always add basic required clusters
272
+ if (!result.includes('IdentifyCluster')) {
273
+ result.push('IdentifyCluster');
274
+ }
275
+ return result;
276
+ }
277
+ export { MatterClusters, MatterDeviceTypes };
278
+ //# sourceMappingURL=matterTypes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"matterTypes.js","sourceRoot":"","sources":["../../src/matter/matterTypes.ts"],"names":[],"mappings":"AAAA,6CAA6C;AAC7C,OAAO,KAAK,QAAQ,MAAM,uBAAuB,CAAA;AACjD,OAAO,KAAK,OAAO,MAAM,sBAAsB,CAAA;AAE/C;;;;;GAKG;AACH,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AAmBrC,MAAM,GAAG,GAAG,MAAM,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAA;AACvC,MAAM,cAAc,GAA4B,EAAE,CAAA;AAClD,MAAM,iBAAiB,GAA4B,EAAE,CAAA;AAErD,IAAI,CAAC;IACH,+CAA+C;IAE/C,0EAA0E;IAC1E,MAAM,CAAC,MAAM,CAAC,cAAc,EAAE;QAC5B,iBAAiB;QACjB,YAAY,EAAE,QAAQ,CAAC,YAAY;QACnC,mBAAmB,EAAE,QAAQ,CAAC,mBAAmB;QACjD,mBAAmB,EAAE,QAAQ,CAAC,mBAAmB;QACjD,eAAe,EAAE,QAAQ,CAAC,eAAe;QAEzC,kBAAkB;QAClB,6BAA6B,EAAE,QAAQ,CAAC,6BAA6B;QACrE,kCAAkC,EAAE,QAAQ,CAAC,kCAAkC;QAC/E,6BAA6B,EAAE,QAAQ,CAAC,6BAA6B;QACrE,uBAAuB,EAAE,QAAQ,CAAC,uBAAuB;QACzD,0BAA0B,EAAE,QAAQ,CAAC,0BAA0B;QAC/D,sBAAsB,EAAE,QAAQ,CAAC,sBAAsB;QAEvD,oBAAoB;QACpB,eAAe,EAAE,QAAQ,CAAC,eAAe;QACzC,mBAAmB,EAAE,QAAQ,CAAC,mBAAmB;QACjD,mBAAmB,EAAE,QAAQ,CAAC,mBAAmB;QAEjD,gBAAgB;QAChB,iBAAiB,EAAE,QAAQ,CAAC,iBAAiB;QAC7C,i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/**
8
+ * Port allocation result
9
+ */
10
+ export interface PortAllocation {
11
+ port: number;
12
+ type: 'matter' | 'hap';
13
+ identifier: string;
14
+ allocated: Date;
15
+ }
16
+ /**
17
+ * Port allocator with thread-safe allocation and tracking
18
+ */
19
+ export declare class PortAllocator {
20
+ private static instance;
21
+ private allocatedPorts;
22
+ private reservedRanges;
23
+ private mutex;
24
+ private defaultMatterStart;
25
+ private defaultMatterEnd;
26
+ private defaultHAPStart;
27
+ private defaultHAPEnd;
28
+ private constructor();
29
+ /**
30
+ * Get singleton instance
31
+ */
32
+ static getInstance(): PortAllocator;
33
+ /**
34
+ * Allocate a port for Matter or HAP
35
+ */
36
+ allocatePort(type: 'matter' | 'hap', identifier: string, preferredPort?: number): Promise<number>;
37
+ /**
38
+ * Release an allocated port
39
+ */
40
+ releasePort(port: number): Promise<void>;
41
+ /**
42
+ * Release all ports for an identifier
43
+ */
44
+ releasePorts(identifier: string): Promise<void>;
45
+ /**
46
+ * Check if a port is available
47
+ */
48
+ private isPortAvailable;
49
+ /**
50
+ * Find any available port
51
+ */
52
+ private findAvailablePort;
53
+ /**
54
+ * Get all allocated ports
55
+ */
56
+ getAllocatedPorts(): Map<number, PortAllocation>;
57
+ /**
58
+ * Check for port conflicts
59
+ */
60
+ checkForConflicts(): Promise<Array<{
61
+ port: number;
62
+ identifier: string;
63
+ available: boolean;
64
+ }>>;
65
+ /**
66
+ * Clear all allocations (use with caution)
67
+ */
68
+ clearAllocations(): void;
69
+ /**
70
+ * Set custom port range for a type
71
+ */
72
+ setPortRange(type: 'matter' | 'hap', start: number, end: number): void;
73
+ /**
74
+ * Get statistics about port allocation
75
+ */
76
+ getStats(): {
77
+ totalAllocated: number;
78
+ matterPorts: number;
79
+ hapPorts: number;
80
+ oldestAllocation?: Date;
81
+ newestAllocation?: Date;
82
+ };
83
+ }
84
+ export declare const portAllocator: PortAllocator;
85
+ //# sourceMappingURL=portAllocator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"port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