@homebridge-plugins/homebridge-matter 0.1.6 → 0.2.0-beta.1

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 (147) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/dist/devices/BaseMatterAccessory.d.ts +61 -0
  3. package/dist/devices/BaseMatterAccessory.js +97 -0
  4. package/dist/devices/BaseMatterAccessory.js.map +1 -0
  5. package/dist/devices/ColorLightAccessory.d.ts +17 -0
  6. package/dist/devices/ColorLightAccessory.js +96 -0
  7. package/dist/devices/ColorLightAccessory.js.map +1 -0
  8. package/dist/devices/ColorTemperatureLightAccessory.d.ts +15 -0
  9. package/dist/devices/ColorTemperatureLightAccessory.js +83 -0
  10. package/dist/devices/ColorTemperatureLightAccessory.js.map +1 -0
  11. package/dist/devices/ContactSensorAccessory.d.ts +9 -0
  12. package/dist/devices/ContactSensorAccessory.js +30 -0
  13. package/dist/devices/ContactSensorAccessory.js.map +1 -0
  14. package/dist/devices/DimmableLightAccessory.d.ts +55 -0
  15. package/dist/devices/DimmableLightAccessory.js +170 -0
  16. package/dist/devices/DimmableLightAccessory.js.map +1 -0
  17. package/dist/devices/DoorLockAccessory.d.ts +11 -0
  18. package/dist/devices/DoorLockAccessory.js +53 -0
  19. package/dist/devices/DoorLockAccessory.js.map +1 -0
  20. package/dist/devices/ExtendedColorLightAccessory.d.ts +18 -0
  21. package/dist/devices/ExtendedColorLightAccessory.js +108 -0
  22. package/dist/devices/ExtendedColorLightAccessory.js.map +1 -0
  23. package/dist/devices/FanAccessory.d.ts +11 -0
  24. package/dist/devices/FanAccessory.js +51 -0
  25. package/dist/devices/FanAccessory.js.map +1 -0
  26. package/dist/devices/HumiditySensorAccessory.d.ts +9 -0
  27. package/dist/devices/HumiditySensorAccessory.js +33 -0
  28. package/dist/devices/HumiditySensorAccessory.js.map +1 -0
  29. package/dist/devices/LeakSensorAccessory.d.ts +9 -0
  30. package/dist/devices/LeakSensorAccessory.js +30 -0
  31. package/dist/devices/LeakSensorAccessory.js.map +1 -0
  32. package/dist/devices/LightSensorAccessory.d.ts +9 -0
  33. package/dist/devices/LightSensorAccessory.js +33 -0
  34. package/dist/devices/LightSensorAccessory.js.map +1 -0
  35. package/dist/devices/MotionSensorAccessory.d.ts +9 -0
  36. package/dist/devices/MotionSensorAccessory.js +42 -0
  37. package/dist/devices/MotionSensorAccessory.js.map +1 -0
  38. package/dist/devices/OnOffLightAccessory.d.ts +35 -0
  39. package/dist/devices/OnOffLightAccessory.js +117 -0
  40. package/dist/devices/OnOffLightAccessory.js.map +1 -0
  41. package/dist/devices/OnOffOutletAccessory.d.ts +11 -0
  42. package/dist/devices/OnOffOutletAccessory.js +43 -0
  43. package/dist/devices/OnOffOutletAccessory.js.map +1 -0
  44. package/dist/devices/OnOffSwitchAccessory.d.ts +11 -0
  45. package/dist/devices/OnOffSwitchAccessory.js +43 -0
  46. package/dist/devices/OnOffSwitchAccessory.js.map +1 -0
  47. package/dist/devices/RoboticVacuumAccessory.d.ts +17 -0
  48. package/dist/devices/RoboticVacuumAccessory.js +99 -0
  49. package/dist/devices/RoboticVacuumAccessory.js.map +1 -0
  50. package/dist/devices/SmokeCOAlarmAccessory.d.ts +10 -0
  51. package/dist/devices/SmokeCOAlarmAccessory.js +49 -0
  52. package/dist/devices/SmokeCOAlarmAccessory.js.map +1 -0
  53. package/dist/devices/TemperatureSensorAccessory.d.ts +9 -0
  54. package/dist/devices/TemperatureSensorAccessory.js +33 -0
  55. package/dist/devices/TemperatureSensorAccessory.js.map +1 -0
  56. package/dist/devices/ThermostatAccessory.d.ts +12 -0
  57. package/dist/devices/ThermostatAccessory.js +56 -0
  58. package/dist/devices/ThermostatAccessory.js.map +1 -0
  59. package/dist/devices/VenetianBlindAccessory.d.ts +16 -0
  60. package/dist/devices/VenetianBlindAccessory.js +94 -0
  61. package/dist/devices/VenetianBlindAccessory.js.map +1 -0
  62. package/dist/devices/WindowBlindAccessory.d.ts +14 -0
  63. package/dist/devices/WindowBlindAccessory.js +77 -0
  64. package/dist/devices/WindowBlindAccessory.js.map +1 -0
  65. package/dist/devices/index.d.ts +24 -10
  66. package/dist/devices/index.js +23 -18
  67. package/dist/devices/index.js.map +1 -1
  68. package/dist/homebridge-ui/public/index.html +10 -0
  69. package/dist/platform.d.ts +0 -23
  70. package/dist/platform.js +108 -68
  71. package/dist/platform.js.map +1 -1
  72. package/package.json +1 -1
  73. package/dist/devices/section-12-robotic/index.d.ts +0 -6
  74. package/dist/devices/section-12-robotic/index.js +0 -7
  75. package/dist/devices/section-12-robotic/index.js.map +0 -1
  76. package/dist/devices/section-12-robotic/robotic-vacuum-cleaner.d.ts +0 -2
  77. package/dist/devices/section-12-robotic/robotic-vacuum-cleaner.js +0 -983
  78. package/dist/devices/section-12-robotic/robotic-vacuum-cleaner.js.map +0 -1
  79. package/dist/devices/section-4-lighting/color-temperature-light.d.ts +0 -14
  80. package/dist/devices/section-4-lighting/color-temperature-light.js +0 -75
  81. package/dist/devices/section-4-lighting/color-temperature-light.js.map +0 -1
  82. package/dist/devices/section-4-lighting/dimmable-light.d.ts +0 -14
  83. package/dist/devices/section-4-lighting/dimmable-light.js +0 -87
  84. package/dist/devices/section-4-lighting/dimmable-light.js.map +0 -1
  85. package/dist/devices/section-4-lighting/extended-color-light.d.ts +0 -17
  86. package/dist/devices/section-4-lighting/extended-color-light.js +0 -162
  87. package/dist/devices/section-4-lighting/extended-color-light.js.map +0 -1
  88. package/dist/devices/section-4-lighting/index.d.ts +0 -9
  89. package/dist/devices/section-4-lighting/index.js +0 -10
  90. package/dist/devices/section-4-lighting/index.js.map +0 -1
  91. package/dist/devices/section-4-lighting/on-off-light.d.ts +0 -16
  92. package/dist/devices/section-4-lighting/on-off-light.js +0 -133
  93. package/dist/devices/section-4-lighting/on-off-light.js.map +0 -1
  94. package/dist/devices/section-5-smart-plugs/index.d.ts +0 -6
  95. package/dist/devices/section-5-smart-plugs/index.js +0 -7
  96. package/dist/devices/section-5-smart-plugs/index.js.map +0 -1
  97. package/dist/devices/section-5-smart-plugs/on-off-plug-in-unit.d.ts +0 -12
  98. package/dist/devices/section-5-smart-plugs/on-off-plug-in-unit.js +0 -44
  99. package/dist/devices/section-5-smart-plugs/on-off-plug-in-unit.js.map +0 -1
  100. package/dist/devices/section-6-switches/index.d.ts +0 -6
  101. package/dist/devices/section-6-switches/index.js +0 -7
  102. package/dist/devices/section-6-switches/index.js.map +0 -1
  103. package/dist/devices/section-6-switches/on-off-light-switch.d.ts +0 -12
  104. package/dist/devices/section-6-switches/on-off-light-switch.js +0 -44
  105. package/dist/devices/section-6-switches/on-off-light-switch.js.map +0 -1
  106. package/dist/devices/section-7-sensors/contact-sensor.d.ts +0 -12
  107. package/dist/devices/section-7-sensors/contact-sensor.js +0 -32
  108. package/dist/devices/section-7-sensors/contact-sensor.js.map +0 -1
  109. package/dist/devices/section-7-sensors/humidity-sensor.d.ts +0 -12
  110. package/dist/devices/section-7-sensors/humidity-sensor.js +0 -34
  111. package/dist/devices/section-7-sensors/humidity-sensor.js.map +0 -1
  112. package/dist/devices/section-7-sensors/index.d.ts +0 -12
  113. package/dist/devices/section-7-sensors/index.js +0 -13
  114. package/dist/devices/section-7-sensors/index.js.map +0 -1
  115. package/dist/devices/section-7-sensors/light-sensor.d.ts +0 -12
  116. package/dist/devices/section-7-sensors/light-sensor.js +0 -34
  117. package/dist/devices/section-7-sensors/light-sensor.js.map +0 -1
  118. package/dist/devices/section-7-sensors/occupancy-sensor.d.ts +0 -14
  119. package/dist/devices/section-7-sensors/occupancy-sensor.js +0 -39
  120. package/dist/devices/section-7-sensors/occupancy-sensor.js.map +0 -1
  121. package/dist/devices/section-7-sensors/smoke-co-alarm.d.ts +0 -13
  122. package/dist/devices/section-7-sensors/smoke-co-alarm.js +0 -43
  123. package/dist/devices/section-7-sensors/smoke-co-alarm.js.map +0 -1
  124. package/dist/devices/section-7-sensors/temperature-sensor.d.ts +0 -12
  125. package/dist/devices/section-7-sensors/temperature-sensor.js +0 -34
  126. package/dist/devices/section-7-sensors/temperature-sensor.js.map +0 -1
  127. package/dist/devices/section-7-sensors/water-leak-detector.d.ts +0 -12
  128. package/dist/devices/section-7-sensors/water-leak-detector.js +0 -32
  129. package/dist/devices/section-7-sensors/water-leak-detector.js.map +0 -1
  130. package/dist/devices/section-8-closure/door-lock.d.ts +0 -13
  131. package/dist/devices/section-8-closure/door-lock.js +0 -47
  132. package/dist/devices/section-8-closure/door-lock.js.map +0 -1
  133. package/dist/devices/section-8-closure/index.d.ts +0 -7
  134. package/dist/devices/section-8-closure/index.js +0 -8
  135. package/dist/devices/section-8-closure/index.js.map +0 -1
  136. package/dist/devices/section-8-closure/window-covering.d.ts +0 -16
  137. package/dist/devices/section-8-closure/window-covering.js +0 -142
  138. package/dist/devices/section-8-closure/window-covering.js.map +0 -1
  139. package/dist/devices/section-9-hvac/fan.d.ts +0 -14
  140. package/dist/devices/section-9-hvac/fan.js +0 -58
  141. package/dist/devices/section-9-hvac/fan.js.map +0 -1
  142. package/dist/devices/section-9-hvac/index.d.ts +0 -7
  143. package/dist/devices/section-9-hvac/index.js +0 -8
  144. package/dist/devices/section-9-hvac/index.js.map +0 -1
  145. package/dist/devices/section-9-hvac/thermostat.d.ts +0 -14
  146. package/dist/devices/section-9-hvac/thermostat.js +0 -62
  147. package/dist/devices/section-9-hvac/thermostat.js.map +0 -1
package/CHANGELOG.md CHANGED
@@ -2,6 +2,13 @@
2
2
 
3
3
  All notable changes to `@homebridge-plugins/homebridge-matter` will be documented in this file.
4
4
 
5
+ ## v0.2.0 (Unreleased)
6
+
7
+ ### Changes
8
+
9
+ - refactor codebase for class-based devices
10
+ - add logging for all `MatterRequest` events
11
+
5
12
  ## v0.1.6 (2025-10-24)
6
13
 
7
14
  ### Changes
@@ -0,0 +1,61 @@
1
+ /**
2
+ * Base Matter Accessory Class
3
+ *
4
+ * This base class implements the MatterAccessory interface and provides
5
+ * common functionality that all Matter devices can use.
6
+ *
7
+ * Individual device types should extend this class and call super() with
8
+ * the required configuration.
9
+ */
10
+ import type { EndpointType } from '@matter/main';
11
+ import type { API, Logger, MatterAccessory } from 'homebridge';
12
+ export interface BaseMatterAccessoryConfig {
13
+ uuid: string;
14
+ displayName: string;
15
+ deviceType: EndpointType;
16
+ serialNumber: string;
17
+ manufacturer: string;
18
+ model: string;
19
+ firmwareRevision: string;
20
+ hardwareRevision: string;
21
+ context?: Record<string, any>;
22
+ clusters: MatterAccessory['clusters'];
23
+ handlers?: MatterAccessory['handlers'];
24
+ }
25
+ /**
26
+ * Base class for all Matter accessories
27
+ * Implements the MatterAccessory interface and provides common methods
28
+ */
29
+ export declare abstract class BaseMatterAccessory implements MatterAccessory {
30
+ readonly uuid: string;
31
+ readonly displayName: string;
32
+ readonly deviceType: EndpointType;
33
+ readonly serialNumber: string;
34
+ readonly manufacturer: string;
35
+ readonly model: string;
36
+ readonly firmwareRevision: string;
37
+ readonly hardwareRevision: string;
38
+ readonly context: Record<string, any>;
39
+ readonly clusters: MatterAccessory['clusters'];
40
+ readonly handlers?: MatterAccessory['handlers'];
41
+ protected readonly api: API;
42
+ protected readonly log: Logger;
43
+ constructor(api: API, log: Logger, config: BaseMatterAccessoryConfig);
44
+ /**
45
+ * Update the accessory state
46
+ * Helper method to update cluster attributes
47
+ */
48
+ protected updateState(cluster: string, attributes: Record<string, any>): void;
49
+ /**
50
+ * Log helper methods
51
+ */
52
+ protected logInfo(message: string, ...args: any[]): void;
53
+ protected logError(message: string, ...args: any[]): void;
54
+ protected logDebug(message: string, ...args: any[]): void;
55
+ protected logWarn(message: string, ...args: any[]): void;
56
+ /**
57
+ * Convert this class instance to a plain MatterAccessory object
58
+ * This is what gets registered with Homebridge
59
+ */
60
+ toAccessory(): MatterAccessory;
61
+ }
@@ -0,0 +1,97 @@
1
+ /**
2
+ * Base Matter Accessory Class
3
+ *
4
+ * This base class implements the MatterAccessory interface and provides
5
+ * common functionality that all Matter devices can use.
6
+ *
7
+ * Individual device types should extend this class and call super() with
8
+ * the required configuration.
9
+ */
10
+ /**
11
+ * Base class for all Matter accessories
12
+ * Implements the MatterAccessory interface and provides common methods
13
+ */
14
+ export class BaseMatterAccessory {
15
+ // Required MatterAccessory properties
16
+ uuid;
17
+ displayName;
18
+ deviceType;
19
+ serialNumber;
20
+ manufacturer;
21
+ model;
22
+ firmwareRevision;
23
+ hardwareRevision;
24
+ context;
25
+ clusters;
26
+ handlers;
27
+ // Protected properties available to child classes
28
+ api;
29
+ log;
30
+ constructor(api, log, config) {
31
+ this.api = api;
32
+ this.log = log;
33
+ // Set all required properties
34
+ this.uuid = config.uuid;
35
+ this.displayName = config.displayName;
36
+ this.deviceType = config.deviceType;
37
+ this.serialNumber = config.serialNumber;
38
+ this.manufacturer = config.manufacturer;
39
+ this.model = config.model;
40
+ this.firmwareRevision = config.firmwareRevision;
41
+ this.hardwareRevision = config.hardwareRevision;
42
+ this.clusters = config.clusters;
43
+ this.handlers = config.handlers;
44
+ // Set context with all metadata
45
+ this.context = {
46
+ serialNumber: this.serialNumber,
47
+ manufacturer: this.manufacturer,
48
+ model: this.model,
49
+ firmwareRevision: this.firmwareRevision,
50
+ hardwareRevision: this.hardwareRevision,
51
+ ...config.context,
52
+ };
53
+ }
54
+ /**
55
+ * Update the accessory state
56
+ * Helper method to update cluster attributes
57
+ */
58
+ updateState(cluster, attributes) {
59
+ this.api.matter.updateAccessoryState(this.uuid, cluster, attributes);
60
+ this.log.debug(`[${this.displayName}] Updated ${cluster} state:`, attributes);
61
+ }
62
+ /**
63
+ * Log helper methods
64
+ */
65
+ logInfo(message, ...args) {
66
+ this.log.info(`[${this.displayName}] ${message}`, ...args);
67
+ }
68
+ logError(message, ...args) {
69
+ this.log.error(`[${this.displayName}] ${message}`, ...args);
70
+ }
71
+ logDebug(message, ...args) {
72
+ this.log.debug(`[${this.displayName}] ${message}`, ...args);
73
+ }
74
+ logWarn(message, ...args) {
75
+ this.log.warn(`[${this.displayName}] ${message}`, ...args);
76
+ }
77
+ /**
78
+ * Convert this class instance to a plain MatterAccessory object
79
+ * This is what gets registered with Homebridge
80
+ */
81
+ toAccessory() {
82
+ return {
83
+ uuid: this.uuid,
84
+ displayName: this.displayName,
85
+ deviceType: this.deviceType,
86
+ serialNumber: this.serialNumber,
87
+ manufacturer: this.manufacturer,
88
+ model: this.model,
89
+ firmwareRevision: this.firmwareRevision,
90
+ hardwareRevision: this.hardwareRevision,
91
+ context: this.context,
92
+ clusters: this.clusters,
93
+ handlers: this.handlers,
94
+ };
95
+ }
96
+ }
97
+ //# sourceMappingURL=BaseMatterAccessory.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BaseMatterAccessory.js","sourceRoot":"","sources":["../../src/devices/BaseMatterAccessory.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAmBH;;;GAGG;AACH,MAAM,OAAgB,mBAAmB;IACvC,sCAAsC;IACtB,IAAI,CAAQ;IACZ,WAAW,CAAQ;IACnB,UAAU,CAAc;IACxB,YAAY,CAAQ;IACpB,YAAY,CAAQ;IACpB,KAAK,CAAQ;IACb,gBAAgB,CAAQ;IACxB,gBAAgB,CAAQ;IACxB,OAAO,CAAqB;IAC5B,QAAQ,CAA6B;IACrC,QAAQ,CAA8B;IAEtD,kDAAkD;IAC/B,GAAG,CAAK;IACR,GAAG,CAAQ;IAE9B,YACE,GAAQ,EACR,GAAW,EACX,MAAiC;QAEjC,IAAI,CAAC,GAAG,GAAG,GAAG,CAAA;QACd,IAAI,CAAC,GAAG,GAAG,GAAG,CAAA;QAEd,8BAA8B;QAC9B,IAAI,CAAC,IAAI,GAAG,MAAM,CAAC,IAAI,CAAA;QACvB,IAAI,CAAC,WAAW,GAAG,MAAM,CAAC,WAAW,CAAA;QACrC,IAAI,CAAC,UAAU,GAAG,MAAM,CAAC,UAAU,CAAA;QACnC,IAAI,CAAC,YAAY,GAAG,MAAM,CAAC,YAAY,CAAA;QACvC,IAAI,CAAC,YAAY,GAAG,MAAM,CAAC,YAAY,CAAA;QACvC,IAAI,CAAC,K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W;QAChD,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,IAAI,CAAC,WAAW,KAAK,OAAO,EAAE,EAAE,GAAG,IAAI,CAAC,CAAA;IAC7D,CAAC;IAES,OAAO,CAAC,OAAe,EAAE,GAAG,IAAW;QAC/C,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,WAAW,KAAK,OAAO,EAAE,EAAE,GAAG,IAAI,CAAC,CAAA;IAC5D,CAAC;IAED;;;OAGG;IACI,WAAW;QAChB,OAAO;YACL,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,WAAW,EAAE,IAAI,CAAC,WAAW;YAC7B,UAAU,EAAE,IAAI,CAAC,UAAU;YAC3B,YAAY,EAAE,IAAI,CAAC,YAAY;YAC/B,YAAY,EAAE,IAAI,CAAC,YAAY;YAC/B,KAAK,EAAE,IAAI,CAAC,KAAK;YACjB,gBAAgB,EAAE,IAAI,CAAC,gBAAgB;YACvC,gBAAgB,EAAE,IAAI,CAAC,gBAAgB;YACvC,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,QAAQ,EAAE,IAAI,CAAC,QAAQ;YACvB,QAAQ,EAAE,IAAI,CAAC,QAAQ;SACxB,CAAA;IACH,CAAC;CACF"}
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Color Light Accessory Class (HS only)
3
+ * Hue and Saturation color control
4
+ */
5
+ import type { API, Logger } from 'homebridge';
6
+ import { BaseMatterAccessory } from './BaseMatterAccessory.js';
7
+ export declare class ColorLightAccessory extends BaseMatterAccessory {
8
+ constructor(api: API, log: Logger);
9
+ private handleOn;
10
+ private handleOff;
11
+ private handleSetLevel;
12
+ private handleSetColor;
13
+ private handleSetHueSaturation;
14
+ updateOnOffState(isOn: boolean): void;
15
+ updateBrightness(percent: number): void;
16
+ updateHueSaturation(hue: number, saturation: number): void;
17
+ }
@@ -0,0 +1,96 @@
1
+ /**
2
+ * Color Light Accessory Class (HS only)
3
+ * Hue and Saturation color control
4
+ */
5
+ import { BaseMatterAccessory } from './BaseMatterAccessory.js';
6
+ export class ColorLightAccessory extends BaseMatterAccessory {
7
+ constructor(api, log) {
8
+ const serialNumber = 'LIGHT-004';
9
+ super(api, log, {
10
+ uuid: api.matter.uuid.generate(serialNumber),
11
+ displayName: 'Colour Light (HS)',
12
+ deviceType: api.matter.deviceTypes.ExtendedColorLight,
13
+ serialNumber,
14
+ manufacturer: 'Homebridge Matter',
15
+ model: 'HB-MATTER-LIGHT-COLOUR-HS',
16
+ firmwareRevision: '2.0.0',
17
+ hardwareRevision: '1.0.0',
18
+ clusters: {
19
+ onOff: { onOff: false },
20
+ levelControl: {
21
+ currentLevel: 127,
22
+ minLevel: 1,
23
+ maxLevel: 254,
24
+ },
25
+ colorControl: {
26
+ colorMode: api.matter.types.ColorControl.ColorMode.CurrentHueAndCurrentSaturation,
27
+ currentHue: 0,
28
+ currentSaturation: 254,
29
+ currentX: 41942,
30
+ currentY: 21626,
31
+ },
32
+ },
33
+ handlers: {
34
+ onOff: {
35
+ on: async () => this.handleOn(),
36
+ off: async () => this.handleOff(),
37
+ },
38
+ levelControl: {
39
+ moveToLevelWithOnOff: async (request) => this.handleSetLevel(request),
40
+ },
41
+ colorControl: {
42
+ moveToColorLogic: async (request) => this.handleSetColor(request),
43
+ moveToHueAndSaturationLogic: async (request) => this.handleSetHueSaturation(request),
44
+ },
45
+ },
46
+ });
47
+ this.logInfo('initialized.');
48
+ }
49
+ async handleOn() {
50
+ this.logInfo('turning on.');
51
+ // TODO: await myLightAPI.turnOn()
52
+ }
53
+ async handleOff() {
54
+ this.logInfo('turning off.');
55
+ // TODO: await myLightAPI.turnOff()
56
+ }
57
+ async handleSetLevel(request) {
58
+ this.logInfo(`MoveToLevel request: ${JSON.stringify(request)}`);
59
+ const { level } = request;
60
+ const brightnessPercent = Math.round((level / 254) * 100);
61
+ this.logInfo(`setting brightness to ${brightnessPercent}%.`);
62
+ // TODO: await myLightAPI.setBrightness(brightnessPercent)
63
+ }
64
+ async handleSetColor(request) {
65
+ this.logInfo(`MoveToColor request: ${JSON.stringify(request)}`);
66
+ const { colorX, colorY, transitionTime } = request;
67
+ const xFloat = (colorX / 65535).toFixed(4);
68
+ const yFloat = (colorY / 65535).toFixed(4);
69
+ this.logInfo(`setting xy color to (${xFloat}, ${yFloat}).`);
70
+ // TODO: await myLightAPI.setXY(xFloat, yFloat, transitionTime)
71
+ }
72
+ async handleSetHueSaturation(request) {
73
+ this.logInfo(`MoveToHueAndSaturation request: ${JSON.stringify(request)}`);
74
+ const { hue, saturation, transitionTime } = request;
75
+ const hueDegrees = Math.round((hue / 254) * 360);
76
+ const saturationPercent = Math.round((saturation / 254) * 100);
77
+ this.logInfo(`setting color to ${hueDegrees}°, ${saturationPercent}%.`);
78
+ // TODO: await myLightAPI.setColor(hueDegrees, saturationPercent, transitionTime)
79
+ }
80
+ updateOnOffState(isOn) {
81
+ this.updateState(this.api.matter.clusterNames.OnOff, { onOff: isOn });
82
+ }
83
+ updateBrightness(percent) {
84
+ const matterLevel = Math.max(1, Math.round((percent / 100) * 254));
85
+ this.updateState(this.api.matter.clusterNames.LevelControl, { currentLevel: matterLevel });
86
+ }
87
+ updateHueSaturation(hue, saturation) {
88
+ const matterHue = Math.round((hue / 360) * 254);
89
+ const matterSat = Math.round((saturation / 100) * 254);
90
+ this.updateState(this.api.matter.clusterNames.ColorControl, {
91
+ currentHue: matterHue,
92
+ currentSaturation: matterSat,
93
+ });
94
+ }
95
+ }
96
+ //# sourceMappingURL=ColorLightAccessory.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ColorLightAccessory.js","sourceRoot":"","sources":["../../src/devices/ColorLightAccessory.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAA;AAE9D,MAAM,OAAO,mBAAoB,SAAQ,mBAAmB;IAC1D,YAAY,GAAQ,EAAE,GAAW;QAC/B,MAAM,YAAY,GAAG,WAAW,CAAA;QAChC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AM,CAAC,YAAY,CAAC,YAAY,EAAE;YAC1D,UAAU,EAAE,SAAS;YACrB,iBAAiB,EAAE,SAAS;SAC7B,CAAC,CAAA;IACJ,CAAC;CACF"}
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Color Temperature Light Accessory Class
3
+ */
4
+ import type { API, Logger } from 'homebridge';
5
+ import { BaseMatterAccessory } from './BaseMatterAccessory.js';
6
+ export declare class ColorTemperatureLightAccessory extends BaseMatterAccessory {
7
+ constructor(api: API, log: Logger);
8
+ private handleOn;
9
+ private handleOff;
10
+ private handleSetLevel;
11
+ private handleSetColorTemperature;
12
+ updateOnOffState(isOn: boolean): void;
13
+ updateBrightness(percent: number): void;
14
+ updateColorTemperature(kelvin: number): void;
15
+ }
@@ -0,0 +1,83 @@
1
+ /**
2
+ * Color Temperature Light Accessory Class
3
+ */
4
+ import { BaseMatterAccessory } from './BaseMatterAccessory.js';
5
+ export class ColorTemperatureLightAccessory extends BaseMatterAccessory {
6
+ constructor(api, log) {
7
+ const serialNumber = 'LIGHT-003';
8
+ super(api, log, {
9
+ uuid: api.matter.uuid.generate(serialNumber),
10
+ displayName: 'Colour Temperature Light',
11
+ deviceType: api.matter.deviceTypes.ColorTemperatureLight,
12
+ serialNumber,
13
+ manufacturer: 'Homebridge Matter',
14
+ model: 'HB-MATTER-LIGHT-COLOUR-TEMP',
15
+ firmwareRevision: '2.0.0',
16
+ hardwareRevision: '1.0.0',
17
+ clusters: {
18
+ onOff: {
19
+ onOff: false,
20
+ },
21
+ levelControl: {
22
+ currentLevel: 127,
23
+ minLevel: 1,
24
+ maxLevel: 254,
25
+ },
26
+ colorControl: {
27
+ colorMode: api.matter.types.ColorControl.ColorMode.ColorTemperatureMireds,
28
+ colorTemperatureMireds: 250,
29
+ colorTempPhysicalMinMireds: 147,
30
+ colorTempPhysicalMaxMireds: 454,
31
+ coupleColorTempToLevelMinMireds: 147,
32
+ },
33
+ },
34
+ handlers: {
35
+ onOff: {
36
+ on: async () => this.handleOn(),
37
+ off: async () => this.handleOff(),
38
+ },
39
+ levelControl: {
40
+ moveToLevelWithOnOff: async (request) => this.handleSetLevel(request),
41
+ },
42
+ colorControl: {
43
+ moveToColorTemperatureLogic: async (request) => this.handleSetColorTemperature(request),
44
+ },
45
+ },
46
+ });
47
+ this.logInfo('initialized.');
48
+ }
49
+ async handleOn() {
50
+ this.logInfo('turning on.');
51
+ // TODO: await myLightAPI.turnOn()
52
+ }
53
+ async handleOff() {
54
+ this.logInfo('turning off.');
55
+ // TODO: await myLightAPI.turnOff()
56
+ }
57
+ async handleSetLevel(request) {
58
+ this.logInfo(`MoveToLevel request: ${JSON.stringify(request)}`);
59
+ const { level } = request;
60
+ const brightnessPercent = Math.round((level / 254) * 100);
61
+ this.logInfo(`setting brightness to ${brightnessPercent}% (level: ${level}).`);
62
+ // TODO: await myLightAPI.setBrightness(brightnessPercent)
63
+ }
64
+ async handleSetColorTemperature(request) {
65
+ this.logInfo(`MoveToColorTemperature request: ${JSON.stringify(request)}`);
66
+ const { colorTemperatureMireds, transitionTime } = request;
67
+ const kelvin = Math.round(1000000 / colorTemperatureMireds);
68
+ this.logInfo((`setting color temp to ${kelvin}k (${colorTemperatureMireds} mireds).`));
69
+ // TODO: await myLightAPI.setColorTemperature(kelvin, transitionTime)
70
+ }
71
+ updateOnOffState(isOn) {
72
+ this.updateState(this.api.matter.clusterNames.OnOff, { onOff: isOn });
73
+ }
74
+ updateBrightness(percent) {
75
+ const matterLevel = Math.max(1, Math.round((percent / 100) * 254));
76
+ this.updateState(this.api.matter.clusterNames.LevelControl, { currentLevel: matterLevel });
77
+ }
78
+ updateColorTemperature(kelvin) {
79
+ const mireds = Math.round(1000000 / kelvin);
80
+ this.updateState(this.api.matter.clusterNames.ColorControl, { colorTemperatureMireds: mireds });
81
+ }
82
+ }
83
+ //# sourceMappingURL=ColorTemperatureLightAccessory.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ColorTemperatureLightAccessory.js","sourceRoot":"","sources":["../../src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IAAa;QACnC,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,YAAY,CAAC,KAAK,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAA;IACvE,CAAC;IAEM,gBAAgB,CAAC,OAAe;QACrC,MAAM,WAAW,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,OAAO,GAAG,GAAG,CAAC,GAAG,GAAG,CAAC,CAAC,CAAA;QAClE,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,YAAY,CAAC,YAAY,EAAE,EAAE,YAAY,EAAE,WAAW,EAAE,CAAC,CAAA;IAC5F,CAAC;IAEM,sBAAsB,CAAC,MAAc;QAC1C,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,GAAG,MAAM,CAAC,CAAA;QAC3C,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,YAAY,CAAC,YAAY,EAAE,EAAE,sBAAsB,EAAE,MAAM,EAAE,CAAC,CAAA;IACjG,CAAC;CACF"}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Contact Sensor Accessory Class
3
+ */
4
+ import type { API, Logger } from 'homebridge';
5
+ import { BaseMatterAccessory } from './BaseMatterAccessory.js';
6
+ export declare class ContactSensorAccessory extends BaseMatterAccessory {
7
+ constructor(api: API, log: Logger);
8
+ updateContactState(isOpen: boolean): void;
9
+ }
@@ -0,0 +1,30 @@
1
+ /**
2
+ * Contact Sensor Accessory Class
3
+ */
4
+ import { BaseMatterAccessory } from './BaseMatterAccessory.js';
5
+ export class ContactSensorAccessory extends BaseMatterAccessory {
6
+ constructor(api, log) {
7
+ const serialNumber = 'SENSOR-001';
8
+ super(api, log, {
9
+ uuid: api.matter.uuid.generate(serialNumber),
10
+ displayName: 'Contact Sensor',
11
+ deviceType: api.matter.deviceTypes.ContactSensor,
12
+ serialNumber,
13
+ manufacturer: 'Homebridge Matter',
14
+ model: 'HB-MATTER-SENSOR-CONTACT',
15
+ firmwareRevision: '2.0.0',
16
+ hardwareRevision: '1.0.0',
17
+ clusters: {
18
+ booleanState: {
19
+ stateValue: false, // false = closed, true = open
20
+ },
21
+ },
22
+ });
23
+ this.logInfo('initialized.');
24
+ }
25
+ updateContactState(isOpen) {
26
+ this.updateState(this.api.matter.clusterNames.BooleanState, { stateValue: isOpen });
27
+ this.logInfo(`contact state: ${isOpen ? 'OPEN' : 'CLOSED'}.`);
28
+ }
29
+ }
30
+ //# sourceMappingURL=ContactSensorAccessory.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ContactSensorAccessory.js","sourceRoot":"","sources":["../../src/devices/ContactSensorAccessory.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAA;AAE9D,MAAM,OAAO,sBAAuB,SAAQ,mBAAmB;IAC7D,YAAY,GAAQ,EAAE,GAAW;QAC/B,MAAM,YAAY,GAAG,YAAY,CAAA;QACjC,KAAK,CAAC,GAAG,EAAE,GAAG,EAAE;YACd,IAAI,EAAE,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,YAAY,CAAC;YAC5C,WAAW,EAAE,gBAAgB;YAC7B,UAAU,EAAE,GAAG,CAAC,MAAM,CAAC,WAAW,CAAC,aAAa;YAChD,YAAY;YACZ,YAAY,EAAE,mBAAmB;YACjC,KAAK,EAAE,0BAA0B;YACjC,gBAAgB,EAAE,OAAO;YACzB,gBAAgB,EAAE,OAAO;YAEzB,QAAQ,EAAE;gBACR,YAAY,EAAE;oBACZ,UAAU,EAAE,KAAK,EAAE,8BAA8B;iBAClD;aACF;SACF,CAAC,CAAA;QAEF,IAAI,CAAC,OAAO,CAAC,cAAc,CAAC,CAAA;IAC9B,CAAC;IAEM,kBAAkB,CAAC,MAAe;QACvC,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,YAAY,CAAC,YAAY,EAAE,EAAE,UAAU,EAAE,MAAM,EAAE,CAAC,CAAA;QACnF,IAAI,CAAC,OAAO,CAAC,kBAAkB,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,QAAQ,GAAG,CAAC,CAAA;IAC/D,CAAC;CACF"}
@@ -0,0 +1,55 @@
1
+ /**
2
+ * Dimmable Light Accessory Class
3
+ *
4
+ * Example of a more complex device with multiple clusters.
5
+ * Shows how to handle devices with on/off + level control.
6
+ */
7
+ import type { API, Logger } from 'homebridge';
8
+ import { BaseMatterAccessory } from './BaseMatterAccessory.js';
9
+ /**
10
+ * Dimmable Light Device Class
11
+ *
12
+ * Demonstrates:
13
+ * - Multiple clusters (OnOff + LevelControl)
14
+ * - Type-safe request handlers
15
+ * - Value conversion (Matter level ↔ percentage)
16
+ * - Custom public methods for external control
17
+ */
18
+ export declare class DimmableLightAccessory extends BaseMatterAccessory {
19
+ private currentLevel;
20
+ constructor(api: API, log: Logger);
21
+ /**
22
+ * Handle the "on" command
23
+ */
24
+ private handleOn;
25
+ /**
26
+ * Handle the "off" command
27
+ */
28
+ private handleOff;
29
+ /**
30
+ * Handle brightness level changes
31
+ */
32
+ private handleSetLevel;
33
+ /**
34
+ * Update on/off state from external source
35
+ */
36
+ updateOnOffState(isOn: boolean): void;
37
+ /**
38
+ * Update brightness level from external source
39
+ * @param percent - Brightness percentage (0-100)
40
+ */
41
+ updateBrightness(percent: number): void;
42
+ /**
43
+ * Get current brightness as percentage
44
+ */
45
+ getBrightness(): number;
46
+ /**
47
+ * Set brightness and power state together
48
+ * Useful for syncing complete state from external source
49
+ */
50
+ updateFullState(isOn: boolean, percent: number): void;
51
+ /**
52
+ * Example monitoring setup
53
+ */
54
+ startMonitoring(): void;
55
+ }