@homebridge-plugins/homebridge-matter 0.1.6 → 0.2.0-beta.0
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.
- package/CHANGELOG.md +6 -0
- package/dist/devices/BaseMatterAccessory.d.ts +61 -0
- package/dist/devices/BaseMatterAccessory.js +97 -0
- package/dist/devices/BaseMatterAccessory.js.map +1 -0
- package/dist/devices/ColorLightAccessory.d.ts +17 -0
- package/dist/devices/ColorLightAccessory.js +93 -0
- package/dist/devices/ColorLightAccessory.js.map +1 -0
- package/dist/devices/ColorTemperatureLightAccessory.d.ts +15 -0
- package/dist/devices/ColorTemperatureLightAccessory.js +81 -0
- package/dist/devices/ColorTemperatureLightAccessory.js.map +1 -0
- package/dist/devices/ContactSensorAccessory.d.ts +9 -0
- package/dist/devices/ContactSensorAccessory.js +30 -0
- package/dist/devices/ContactSensorAccessory.js.map +1 -0
- package/dist/devices/DimmableLightAccessory.d.ts +55 -0
- package/dist/devices/DimmableLightAccessory.js +169 -0
- package/dist/devices/DimmableLightAccessory.js.map +1 -0
- package/dist/devices/DoorLockAccessory.d.ts +11 -0
- package/dist/devices/DoorLockAccessory.js +51 -0
- package/dist/devices/DoorLockAccessory.js.map +1 -0
- package/dist/devices/ExtendedColorLightAccessory.d.ts +18 -0
- package/dist/devices/ExtendedColorLightAccessory.js +104 -0
- package/dist/devices/ExtendedColorLightAccessory.js.map +1 -0
- package/dist/devices/FanAccessory.d.ts +11 -0
- package/dist/devices/FanAccessory.js +50 -0
- package/dist/devices/FanAccessory.js.map +1 -0
- package/dist/devices/HumiditySensorAccessory.d.ts +9 -0
- package/dist/devices/HumiditySensorAccessory.js +33 -0
- package/dist/devices/HumiditySensorAccessory.js.map +1 -0
- package/dist/devices/LeakSensorAccessory.d.ts +9 -0
- package/dist/devices/LeakSensorAccessory.js +30 -0
- package/dist/devices/LeakSensorAccessory.js.map +1 -0
- package/dist/devices/LightSensorAccessory.d.ts +9 -0
- package/dist/devices/LightSensorAccessory.js +33 -0
- package/dist/devices/LightSensorAccessory.js.map +1 -0
- package/dist/devices/MotionSensorAccessory.d.ts +9 -0
- package/dist/devices/MotionSensorAccessory.js +42 -0
- package/dist/devices/MotionSensorAccessory.js.map +1 -0
- package/dist/devices/OnOffLightAccessory.d.ts +35 -0
- package/dist/devices/OnOffLightAccessory.js +117 -0
- package/dist/devices/OnOffLightAccessory.js.map +1 -0
- package/dist/devices/OnOffOutletAccessory.d.ts +11 -0
- package/dist/devices/OnOffOutletAccessory.js +43 -0
- package/dist/devices/OnOffOutletAccessory.js.map +1 -0
- package/dist/devices/OnOffSwitchAccessory.d.ts +11 -0
- package/dist/devices/OnOffSwitchAccessory.js +43 -0
- package/dist/devices/OnOffSwitchAccessory.js.map +1 -0
- package/dist/devices/RoboticVacuumAccessory.d.ts +17 -0
- package/dist/devices/RoboticVacuumAccessory.js +97 -0
- package/dist/devices/RoboticVacuumAccessory.js.map +1 -0
- package/dist/devices/SmokeCOAlarmAccessory.d.ts +10 -0
- package/dist/devices/SmokeCOAlarmAccessory.js +49 -0
- package/dist/devices/SmokeCOAlarmAccessory.js.map +1 -0
- package/dist/devices/TemperatureSensorAccessory.d.ts +9 -0
- package/dist/devices/TemperatureSensorAccessory.js +33 -0
- package/dist/devices/TemperatureSensorAccessory.js.map +1 -0
- package/dist/devices/ThermostatAccessory.d.ts +12 -0
- package/dist/devices/ThermostatAccessory.js +55 -0
- package/dist/devices/ThermostatAccessory.js.map +1 -0
- package/dist/devices/VenetianBlindAccessory.d.ts +16 -0
- package/dist/devices/VenetianBlindAccessory.js +92 -0
- package/dist/devices/VenetianBlindAccessory.js.map +1 -0
- package/dist/devices/WindowBlindAccessory.d.ts +14 -0
- package/dist/devices/WindowBlindAccessory.js +76 -0
- package/dist/devices/WindowBlindAccessory.js.map +1 -0
- package/dist/devices/index.d.ts +24 -10
- package/dist/devices/index.js +23 -18
- package/dist/devices/index.js.map +1 -1
- package/dist/homebridge-ui/public/index.html +10 -0
- package/dist/platform.d.ts +0 -23
- package/dist/platform.js +108 -68
- package/dist/platform.js.map +1 -1
- package/package.json +1 -1
- package/dist/devices/section-12-robotic/index.d.ts +0 -6
- package/dist/devices/section-12-robotic/index.js +0 -7
- package/dist/devices/section-12-robotic/index.js.map +0 -1
- package/dist/devices/section-12-robotic/robotic-vacuum-cleaner.d.ts +0 -2
- package/dist/devices/section-12-robotic/robotic-vacuum-cleaner.js +0 -983
- package/dist/devices/section-12-robotic/robotic-vacuum-cleaner.js.map +0 -1
- package/dist/devices/section-4-lighting/color-temperature-light.d.ts +0 -14
- package/dist/devices/section-4-lighting/color-temperature-light.js +0 -75
- package/dist/devices/section-4-lighting/color-temperature-light.js.map +0 -1
- package/dist/devices/section-4-lighting/dimmable-light.d.ts +0 -14
- package/dist/devices/section-4-lighting/dimmable-light.js +0 -87
- package/dist/devices/section-4-lighting/dimmable-light.js.map +0 -1
- package/dist/devices/section-4-lighting/extended-color-light.d.ts +0 -17
- package/dist/devices/section-4-lighting/extended-color-light.js +0 -162
- package/dist/devices/section-4-lighting/extended-color-light.js.map +0 -1
- package/dist/devices/section-4-lighting/index.d.ts +0 -9
- package/dist/devices/section-4-lighting/index.js +0 -10
- package/dist/devices/section-4-lighting/index.js.map +0 -1
- package/dist/devices/section-4-lighting/on-off-light.d.ts +0 -16
- package/dist/devices/section-4-lighting/on-off-light.js +0 -133
- package/dist/devices/section-4-lighting/on-off-light.js.map +0 -1
- package/dist/devices/section-5-smart-plugs/index.d.ts +0 -6
- package/dist/devices/section-5-smart-plugs/index.js +0 -7
- package/dist/devices/section-5-smart-plugs/index.js.map +0 -1
- package/dist/devices/section-5-smart-plugs/on-off-plug-in-unit.d.ts +0 -12
- package/dist/devices/section-5-smart-plugs/on-off-plug-in-unit.js +0 -44
- package/dist/devices/section-5-smart-plugs/on-off-plug-in-unit.js.map +0 -1
- package/dist/devices/section-6-switches/index.d.ts +0 -6
- package/dist/devices/section-6-switches/index.js +0 -7
- package/dist/devices/section-6-switches/index.js.map +0 -1
- package/dist/devices/section-6-switches/on-off-light-switch.d.ts +0 -12
- package/dist/devices/section-6-switches/on-off-light-switch.js +0 -44
- package/dist/devices/section-6-switches/on-off-light-switch.js.map +0 -1
- package/dist/devices/section-7-sensors/contact-sensor.d.ts +0 -12
- package/dist/devices/section-7-sensors/contact-sensor.js +0 -32
- package/dist/devices/section-7-sensors/contact-sensor.js.map +0 -1
- package/dist/devices/section-7-sensors/humidity-sensor.d.ts +0 -12
- package/dist/devices/section-7-sensors/humidity-sensor.js +0 -34
- package/dist/devices/section-7-sensors/humidity-sensor.js.map +0 -1
- package/dist/devices/section-7-sensors/index.d.ts +0 -12
- package/dist/devices/section-7-sensors/index.js +0 -13
- package/dist/devices/section-7-sensors/index.js.map +0 -1
- package/dist/devices/section-7-sensors/light-sensor.d.ts +0 -12
- package/dist/devices/section-7-sensors/light-sensor.js +0 -34
- package/dist/devices/section-7-sensors/light-sensor.js.map +0 -1
- package/dist/devices/section-7-sensors/occupancy-sensor.d.ts +0 -14
- package/dist/devices/section-7-sensors/occupancy-sensor.js +0 -39
- package/dist/devices/section-7-sensors/occupancy-sensor.js.map +0 -1
- package/dist/devices/section-7-sensors/smoke-co-alarm.d.ts +0 -13
- package/dist/devices/section-7-sensors/smoke-co-alarm.js +0 -43
- package/dist/devices/section-7-sensors/smoke-co-alarm.js.map +0 -1
- package/dist/devices/section-7-sensors/temperature-sensor.d.ts +0 -12
- package/dist/devices/section-7-sensors/temperature-sensor.js +0 -34
- package/dist/devices/section-7-sensors/temperature-sensor.js.map +0 -1
- package/dist/devices/section-7-sensors/water-leak-detector.d.ts +0 -12
- package/dist/devices/section-7-sensors/water-leak-detector.js +0 -32
- package/dist/devices/section-7-sensors/water-leak-detector.js.map +0 -1
- package/dist/devices/section-8-closure/door-lock.d.ts +0 -13
- package/dist/devices/section-8-closure/door-lock.js +0 -47
- package/dist/devices/section-8-closure/door-lock.js.map +0 -1
- package/dist/devices/section-8-closure/index.d.ts +0 -7
- package/dist/devices/section-8-closure/index.js +0 -8
- package/dist/devices/section-8-closure/index.js.map +0 -1
- package/dist/devices/section-8-closure/window-covering.d.ts +0 -16
- package/dist/devices/section-8-closure/window-covering.js +0 -142
- package/dist/devices/section-8-closure/window-covering.js.map +0 -1
- package/dist/devices/section-9-hvac/fan.d.ts +0 -14
- package/dist/devices/section-9-hvac/fan.js +0 -58
- package/dist/devices/section-9-hvac/fan.js.map +0 -1
- package/dist/devices/section-9-hvac/index.d.ts +0 -7
- package/dist/devices/section-9-hvac/index.js +0 -8
- package/dist/devices/section-9-hvac/index.js.map +0 -1
- package/dist/devices/section-9-hvac/thermostat.d.ts +0 -14
- package/dist/devices/section-9-hvac/thermostat.js +0 -62
- package/dist/devices/section-9-hvac/thermostat.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -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;IAC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O,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,93 @@
|
|
|
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
|
+
const { level } = request;
|
|
59
|
+
const brightnessPercent = Math.round((level / 254) * 100);
|
|
60
|
+
this.logInfo(`setting brightness to ${brightnessPercent}%.`);
|
|
61
|
+
// TODO: await myLightAPI.setBrightness(brightnessPercent)
|
|
62
|
+
}
|
|
63
|
+
async handleSetColor(request) {
|
|
64
|
+
const { colorX, colorY, transitionTime } = request;
|
|
65
|
+
const xFloat = (colorX / 65535).toFixed(4);
|
|
66
|
+
const yFloat = (colorY / 65535).toFixed(4);
|
|
67
|
+
this.logInfo(`setting xy color to (${xFloat}, ${yFloat}).`);
|
|
68
|
+
// TODO: await myLightAPI.setXY(xFloat, yFloat, transitionTime)
|
|
69
|
+
}
|
|
70
|
+
async handleSetHueSaturation(request) {
|
|
71
|
+
const { hue, saturation, transitionTime } = request;
|
|
72
|
+
const hueDegrees = Math.round((hue / 254) * 360);
|
|
73
|
+
const saturationPercent = Math.round((saturation / 254) * 100);
|
|
74
|
+
this.logInfo(`setting color to ${hueDegrees}°, ${saturationPercent}%.`);
|
|
75
|
+
// TODO: await myLightAPI.setColor(hueDegrees, saturationPercent, transitionTime)
|
|
76
|
+
}
|
|
77
|
+
updateOnOffState(isOn) {
|
|
78
|
+
this.updateState(this.api.matter.clusterNames.OnOff, { onOff: isOn });
|
|
79
|
+
}
|
|
80
|
+
updateBrightness(percent) {
|
|
81
|
+
const matterLevel = Math.max(1, Math.round((percent / 100) * 254));
|
|
82
|
+
this.updateState(this.api.matter.clusterNames.LevelControl, { currentLevel: matterLevel });
|
|
83
|
+
}
|
|
84
|
+
updateHueSaturation(hue, saturation) {
|
|
85
|
+
const matterHue = Math.round((hue / 360) * 254);
|
|
86
|
+
const matterSat = Math.round((saturation / 100) * 254);
|
|
87
|
+
this.updateState(this.api.matter.clusterNames.ColorControl, {
|
|
88
|
+
currentHue: matterHue,
|
|
89
|
+
currentSaturation: matterSat,
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
//# 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;Q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ebridge';
|
|
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,81 @@
|
|
|
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
|
+
const { level } = request;
|
|
59
|
+
const brightnessPercent = Math.round((level / 254) * 100);
|
|
60
|
+
this.logInfo(`setting brightness to ${brightnessPercent}% (level: ${level}).`);
|
|
61
|
+
// TODO: await myLightAPI.setBrightness(brightnessPercent)
|
|
62
|
+
}
|
|
63
|
+
async handleSetColorTemperature(request) {
|
|
64
|
+
const { colorTemperatureMireds, transitionTime } = request;
|
|
65
|
+
const kelvin = Math.round(1000000 / colorTemperatureMireds);
|
|
66
|
+
this.logInfo((`setting color temp to ${kelvin}k (${colorTemperatureMireds} mireds).`));
|
|
67
|
+
// TODO: await myLightAPI.setColorTemperature(kelvin, transitionTime)
|
|
68
|
+
}
|
|
69
|
+
updateOnOffState(isOn) {
|
|
70
|
+
this.updateState(this.api.matter.clusterNames.OnOff, { onOff: isOn });
|
|
71
|
+
}
|
|
72
|
+
updateBrightness(percent) {
|
|
73
|
+
const matterLevel = Math.max(1, Math.round((percent / 100) * 254));
|
|
74
|
+
this.updateState(this.api.matter.clusterNames.LevelControl, { currentLevel: matterLevel });
|
|
75
|
+
}
|
|
76
|
+
updateColorTemperature(kelvin) {
|
|
77
|
+
const mireds = Math.round(1000000 / kelvin);
|
|
78
|
+
this.updateState(this.api.matter.clusterNames.ColorControl, { colorTemperatureMireds: mireds });
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
//# sourceMappingURL=ColorTemperatureLightAccessory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ColorTemperatureLightAccessory.js","sourceRoot":"","sources":["../../src/devices/ColorTemperatureLightAccessory.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAA;AAE9D,MAAM,OAAO,8BAA+B,SAAQ,mBAAmB;IACrE,YAAY,GAAQ,EAAE,GAAW;QAC/B,MAAM,YAAY,GAAG,WAAW,CAAA;QAChC,KAAK,CAAC,GAAG,EAAE,GAAG,EAAE;YACd,IAAI,EAAE,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,YAAY,CAAC;YAC5C,WAAW,EAAE,0BAA0B;YACvC,UAAU,EAAE,GAAG,CAAC,MAAM,CAAC,WAAW,CAAC,qBAAqB;YACxD,YAAY;YACZ,YAAY,EAAE,mBAAmB;YACjC,KAAK,EAAE,6BAA6B;YACpC,gBAAgB,EAAE,OAAO;YACzB,gBAAgB,EAAE,OAAO;YAEzB,QAAQ,EAAE;gBACR,KAAK,EAAE;oBACL,KAAK,EAAE,KAAK;iBACb;gBACD,YAAY,EAAE;oBACZ,YAAY,EAAE,GAAG;oBACjB,QAAQ,EAAE,CAAC;oBACX,QAAQ,EAAE,GAAG;iBACd;gBACD,YAAY,EAAE;oBACZ,SAAS,EAAE,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,YAAY,CAAC,SAAS,CAAC,sBAAsB;oBACzE,sBAAsB,EA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AM,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,GAAG,sBAAsB,CAAC,CAAA;QAC3D,IAAI,CAAC,OAAO,CAAC,CAAC,yBAAyB,MAAM,MAAM,sBAAsB,WAAW,CAAC,CAAC,CAAA;QACtF,qEAAqE;IACvE,CAAC;IAEM,gBAAgB,CAAC,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
|
+
}
|
|
@@ -0,0 +1,169 @@
|
|
|
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 { BaseMatterAccessory } from './BaseMatterAccessory.js';
|
|
8
|
+
/**
|
|
9
|
+
* Dimmable Light Device Class
|
|
10
|
+
*
|
|
11
|
+
* Demonstrates:
|
|
12
|
+
* - Multiple clusters (OnOff + LevelControl)
|
|
13
|
+
* - Type-safe request handlers
|
|
14
|
+
* - Value conversion (Matter level ↔ percentage)
|
|
15
|
+
* - Custom public methods for external control
|
|
16
|
+
*/
|
|
17
|
+
export class DimmableLightAccessory extends BaseMatterAccessory {
|
|
18
|
+
// Track current state
|
|
19
|
+
currentLevel = 127; // 50% brightness
|
|
20
|
+
constructor(api, log) {
|
|
21
|
+
const serialNumber = 'LIGHT-002';
|
|
22
|
+
const displayName = 'Dimmable Light';
|
|
23
|
+
const manufacturer = 'Homebridge Matter';
|
|
24
|
+
const model = 'HB-MATTER-LIGHT-DIMMABLE';
|
|
25
|
+
const firmwareRevision = '2.0.0';
|
|
26
|
+
const hardwareRevision = '1.0.0';
|
|
27
|
+
super(api, log, {
|
|
28
|
+
uuid: api.matter.uuid.generate(serialNumber),
|
|
29
|
+
displayName,
|
|
30
|
+
deviceType: api.matter.deviceTypes.DimmableLight,
|
|
31
|
+
serialNumber,
|
|
32
|
+
manufacturer,
|
|
33
|
+
model,
|
|
34
|
+
firmwareRevision,
|
|
35
|
+
hardwareRevision,
|
|
36
|
+
clusters: {
|
|
37
|
+
onOff: {
|
|
38
|
+
onOff: false,
|
|
39
|
+
},
|
|
40
|
+
levelControl: {
|
|
41
|
+
currentLevel: 127, // 50% brightness (range 1-254)
|
|
42
|
+
minLevel: 1,
|
|
43
|
+
maxLevel: 254,
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
handlers: {
|
|
47
|
+
onOff: {
|
|
48
|
+
on: async () => this.handleOn(),
|
|
49
|
+
off: async () => this.handleOff(),
|
|
50
|
+
},
|
|
51
|
+
levelControl: {
|
|
52
|
+
moveToLevelWithOnOff: async (request) => this.handleSetLevel(request),
|
|
53
|
+
},
|
|
54
|
+
},
|
|
55
|
+
});
|
|
56
|
+
this.logInfo('initialized.');
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Handle the "on" command
|
|
60
|
+
*/
|
|
61
|
+
async handleOn() {
|
|
62
|
+
this.logInfo('turning on.');
|
|
63
|
+
try {
|
|
64
|
+
// TODO: Control your physical device
|
|
65
|
+
// await myLightAPI.turnOn()
|
|
66
|
+
this.logInfo('physical device turned on.');
|
|
67
|
+
}
|
|
68
|
+
catch (error) {
|
|
69
|
+
this.logError('failed to turn on:', error);
|
|
70
|
+
throw error;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Handle the "off" command
|
|
75
|
+
*/
|
|
76
|
+
async handleOff() {
|
|
77
|
+
this.logInfo('turning off.');
|
|
78
|
+
try {
|
|
79
|
+
// TODO: Control your physical device
|
|
80
|
+
// await myLightAPI.turnOff()
|
|
81
|
+
this.logInfo('physical device turned off.');
|
|
82
|
+
}
|
|
83
|
+
catch (error) {
|
|
84
|
+
this.logError('failed to turn off:', error);
|
|
85
|
+
throw error;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Handle brightness level changes
|
|
90
|
+
*/
|
|
91
|
+
async handleSetLevel(request) {
|
|
92
|
+
const { level, transitionTime } = request;
|
|
93
|
+
// Convert Matter level (1-254) to percentage (0-100%)
|
|
94
|
+
const brightnessPercent = Math.round((level / 254) * 100);
|
|
95
|
+
this.currentLevel = level;
|
|
96
|
+
this.logInfo(`setting brightness to ${brightnessPercent}% (level: ${level}).`);
|
|
97
|
+
try {
|
|
98
|
+
// TODO: Control your physical device
|
|
99
|
+
// await myLightAPI.setBrightness(brightnessPercent, transitionTime)
|
|
100
|
+
this.logInfo((`physical device brightness set to ${brightnessPercent}%.`));
|
|
101
|
+
}
|
|
102
|
+
catch (error) {
|
|
103
|
+
this.logError('Failed to set brightness:', error);
|
|
104
|
+
throw error;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Update on/off state from external source
|
|
109
|
+
*/
|
|
110
|
+
updateOnOffState(isOn) {
|
|
111
|
+
this.updateState(this.api.matter.clusterNames.OnOff, { onOff: isOn });
|
|
112
|
+
this.logInfo(`state synced: ${isOn ? 'ON' : 'OFF'}.`);
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Update brightness level from external source
|
|
116
|
+
* @param percent - Brightness percentage (0-100)
|
|
117
|
+
*/
|
|
118
|
+
updateBrightness(percent) {
|
|
119
|
+
// Validate input
|
|
120
|
+
if (percent < 0 || percent > 100) {
|
|
121
|
+
this.logWarn(`Invalid brightness percentage: ${percent}. Must be 0-100.`);
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
124
|
+
// Convert percent to Matter level (1-254)
|
|
125
|
+
const matterLevel = Math.max(1, Math.round((percent / 100) * 254));
|
|
126
|
+
this.currentLevel = matterLevel;
|
|
127
|
+
this.updateState(this.api.matter.clusterNames.LevelControl, {
|
|
128
|
+
currentLevel: matterLevel,
|
|
129
|
+
});
|
|
130
|
+
this.logInfo((`brightness synced: ${percent}% (level: ${matterLevel}).`));
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Get current brightness as percentage
|
|
134
|
+
*/
|
|
135
|
+
getBrightness() {
|
|
136
|
+
return Math.round((this.currentLevel / 254) * 100);
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Set brightness and power state together
|
|
140
|
+
* Useful for syncing complete state from external source
|
|
141
|
+
*/
|
|
142
|
+
updateFullState(isOn, percent) {
|
|
143
|
+
this.updateOnOffState(isOn);
|
|
144
|
+
if (isOn) {
|
|
145
|
+
this.updateBrightness(percent);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* Example monitoring setup
|
|
150
|
+
*/
|
|
151
|
+
startMonitoring() {
|
|
152
|
+
// Example: MQTT listener
|
|
153
|
+
// mqttClient.on('message', (topic, message) => {
|
|
154
|
+
// const { state, brightness } = JSON.parse(message.toString())
|
|
155
|
+
// this.updateFullState(state === 'ON', brightness)
|
|
156
|
+
// })
|
|
157
|
+
// Example: Polling
|
|
158
|
+
// setInterval(async () => {
|
|
159
|
+
// try {
|
|
160
|
+
// const response = await fetch('https://api.mydevice.com/light/state')
|
|
161
|
+
// const data = await response.json()
|
|
162
|
+
// this.updateFullState(data.power === 'on', data.brightness)
|
|
163
|
+
// } catch (error) {
|
|
164
|
+
// this.logError('Polling error:', error)
|
|
165
|
+
// }
|
|
166
|
+
// }, 5000)
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
//# sourceMappingURL=DimmableLightAccessory.js.map
|