@switchbot/homebridge-switchbot 5.0.0-beta.1 → 5.0.0-beta.2
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/dist/devices-matter/ColorLightAccessory.d.ts +3 -1
- package/dist/devices-matter/ColorLightAccessory.d.ts.map +1 -1
- package/dist/devices-matter/ColorLightAccessory.js +35 -36
- package/dist/devices-matter/ColorLightAccessory.js.map +1 -1
- package/dist/devices-matter/ColorTemperatureLightAccessory.d.ts +3 -1
- package/dist/devices-matter/ColorTemperatureLightAccessory.d.ts.map +1 -1
- package/dist/devices-matter/ColorTemperatureLightAccessory.js +32 -37
- package/dist/devices-matter/ColorTemperatureLightAccessory.js.map +1 -1
- package/dist/devices-matter/ContactSensorAccessory.d.ts +3 -1
- package/dist/devices-matter/ContactSensorAccessory.d.ts.map +1 -1
- package/dist/devices-matter/ContactSensorAccessory.js +16 -13
- package/dist/devices-matter/ContactSensorAccessory.js.map +1 -1
- package/dist/devices-matter/DimmableLightAccessory.d.ts +3 -1
- package/dist/devices-matter/DimmableLightAccessory.d.ts.map +1 -1
- package/dist/devices-matter/DimmableLightAccessory.js +24 -27
- package/dist/devices-matter/DimmableLightAccessory.js.map +1 -1
- package/dist/devices-matter/DoorLockAccessory.d.ts +3 -1
- package/dist/devices-matter/DoorLockAccessory.d.ts.map +1 -1
- package/dist/devices-matter/DoorLockAccessory.js +25 -22
- package/dist/devices-matter/DoorLockAccessory.js.map +1 -1
- package/dist/devices-matter/ExtendedColorLightAccessory.d.ts +3 -1
- package/dist/devices-matter/ExtendedColorLightAccessory.d.ts.map +1 -1
- package/dist/devices-matter/ExtendedColorLightAccessory.js +40 -41
- package/dist/devices-matter/ExtendedColorLightAccessory.js.map +1 -1
- package/dist/devices-matter/FanAccessory.d.ts +3 -1
- package/dist/devices-matter/FanAccessory.d.ts.map +1 -1
- package/dist/devices-matter/FanAccessory.js +31 -23
- package/dist/devices-matter/FanAccessory.js.map +1 -1
- package/dist/devices-matter/HumiditySensorAccessory.d.ts +3 -1
- package/dist/devices-matter/HumiditySensorAccessory.d.ts.map +1 -1
- package/dist/devices-matter/HumiditySensorAccessory.js +16 -15
- package/dist/devices-matter/HumiditySensorAccessory.js.map +1 -1
- package/dist/devices-matter/LeakSensorAccessory.d.ts +3 -1
- package/dist/devices-matter/LeakSensorAccessory.d.ts.map +1 -1
- package/dist/devices-matter/LeakSensorAccessory.js +16 -13
- package/dist/devices-matter/LeakSensorAccessory.js.map +1 -1
- package/dist/devices-matter/LightSensorAccessory.d.ts +3 -1
- package/dist/devices-matter/LightSensorAccessory.d.ts.map +1 -1
- package/dist/devices-matter/LightSensorAccessory.js +16 -15
- package/dist/devices-matter/LightSensorAccessory.js.map +1 -1
- package/dist/devices-matter/OccupancySensorAccessory.d.ts +3 -1
- package/dist/devices-matter/OccupancySensorAccessory.d.ts.map +1 -1
- package/dist/devices-matter/OccupancySensorAccessory.js +17 -21
- package/dist/devices-matter/OccupancySensorAccessory.js.map +1 -1
- package/dist/devices-matter/OnOffLightAccessory.d.ts +3 -1
- package/dist/devices-matter/OnOffLightAccessory.d.ts.map +1 -1
- package/dist/devices-matter/OnOffLightAccessory.js +22 -21
- package/dist/devices-matter/OnOffLightAccessory.js.map +1 -1
- package/dist/devices-matter/OnOffOutletAccessory.d.ts +3 -3
- package/dist/devices-matter/OnOffOutletAccessory.d.ts.map +1 -1
- package/dist/devices-matter/OnOffOutletAccessory.js +24 -27
- package/dist/devices-matter/OnOffOutletAccessory.js.map +1 -1
- package/dist/devices-matter/OnOffSwitchAccessory.d.ts +3 -1
- package/dist/devices-matter/OnOffSwitchAccessory.d.ts.map +1 -1
- package/dist/devices-matter/OnOffSwitchAccessory.js +18 -19
- package/dist/devices-matter/OnOffSwitchAccessory.js.map +1 -1
- package/dist/devices-matter/RoboticVacuumAccessory.d.ts +3 -1
- package/dist/devices-matter/RoboticVacuumAccessory.d.ts.map +1 -1
- package/dist/devices-matter/RoboticVacuumAccessory.js +77 -145
- package/dist/devices-matter/RoboticVacuumAccessory.js.map +1 -1
- package/dist/devices-matter/TemperatureSensorAccessory.d.ts +3 -1
- package/dist/devices-matter/TemperatureSensorAccessory.d.ts.map +1 -1
- package/dist/devices-matter/TemperatureSensorAccessory.js +18 -15
- package/dist/devices-matter/TemperatureSensorAccessory.js.map +1 -1
- package/dist/devices-matter/ThermostatAccessory.d.ts +3 -1
- package/dist/devices-matter/ThermostatAccessory.d.ts.map +1 -1
- package/dist/devices-matter/ThermostatAccessory.js +37 -29
- package/dist/devices-matter/ThermostatAccessory.js.map +1 -1
- package/dist/devices-matter/VenetianBlindAccessory.d.ts +3 -1
- package/dist/devices-matter/VenetianBlindAccessory.d.ts.map +1 -1
- package/dist/devices-matter/VenetianBlindAccessory.js +39 -40
- package/dist/devices-matter/VenetianBlindAccessory.js.map +1 -1
- package/dist/devices-matter/WindowBlindAccessory.d.ts +3 -1
- package/dist/devices-matter/WindowBlindAccessory.d.ts.map +1 -1
- package/dist/devices-matter/WindowBlindAccessory.js +36 -37
- package/dist/devices-matter/WindowBlindAccessory.js.map +1 -1
- package/docs/variables/default.html +1 -1
- package/package.json +1 -1
- package/src/devices-matter/ColorLightAccessory.ts +37 -40
- package/src/devices-matter/ColorTemperatureLightAccessory.ts +35 -41
- package/src/devices-matter/ContactSensorAccessory.ts +18 -14
- package/src/devices-matter/DimmableLightAccessory.ts +26 -30
- package/src/devices-matter/DoorLockAccessory.ts +28 -24
- package/src/devices-matter/ExtendedColorLightAccessory.ts +43 -47
- package/src/devices-matter/FanAccessory.ts +33 -25
- package/src/devices-matter/HumiditySensorAccessory.ts +18 -16
- package/src/devices-matter/LeakSensorAccessory.ts +18 -14
- package/src/devices-matter/LightSensorAccessory.ts +18 -16
- package/src/devices-matter/OccupancySensorAccessory.ts +18 -22
- package/src/devices-matter/OnOffLightAccessory.ts +23 -23
- package/src/devices-matter/OnOffOutletAccessory.ts +25 -31
- package/src/devices-matter/OnOffSwitchAccessory.ts +20 -21
- package/src/devices-matter/RoboticVacuumAccessory.ts +79 -156
- package/src/devices-matter/TemperatureSensorAccessory.ts +20 -16
- package/src/devices-matter/ThermostatAccessory.ts +39 -34
- package/src/devices-matter/VenetianBlindAccessory.ts +41 -44
- package/src/devices-matter/WindowBlindAccessory.ts +37 -39
|
@@ -8,56 +8,52 @@ import type { API, Logger, MatterRequests } from 'homebridge'
|
|
|
8
8
|
import { BaseMatterAccessory } from './BaseMatterAccessory.js'
|
|
9
9
|
|
|
10
10
|
export class ExtendedColorLightAccessory extends BaseMatterAccessory {
|
|
11
|
-
constructor(api: API, log: Logger) {
|
|
12
|
-
const serialNumber = 'LIGHT-005'
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
currentHue: 0,
|
|
33
|
-
currentSaturation: 254,
|
|
34
|
-
currentX: 41942,
|
|
35
|
-
currentY: 21626,
|
|
36
|
-
colorTemperatureMireds: 250,
|
|
37
|
-
colorTempPhysicalMinMireds: 147,
|
|
38
|
-
colorTempPhysicalMaxMireds: 454,
|
|
39
|
-
coupleColorTempToLevelMinMireds: 147,
|
|
40
|
-
},
|
|
11
|
+
constructor(api: API, log: Logger, opts?: Partial<import('./BaseMatterAccessory').BaseMatterAccessoryConfig & { deviceId?: string }>) {
|
|
12
|
+
const serialNumber = opts?.serialNumber ?? 'LIGHT-005'
|
|
13
|
+
const displayName = opts?.displayName ?? 'Extended Colour Light (HS+CCT)'
|
|
14
|
+
const manufacturer = opts?.manufacturer ?? 'Homebridge Matter'
|
|
15
|
+
const model = opts?.model ?? 'HB-MATTER-LIGHT-EXTENDED-COLOUR'
|
|
16
|
+
const firmwareRevision = opts?.firmwareRevision ?? '2.0.0'
|
|
17
|
+
const hardwareRevision = opts?.hardwareRevision ?? '1.0.0'
|
|
18
|
+
|
|
19
|
+
const clusters = opts?.clusters ?? {
|
|
20
|
+
onOff: { onOff: false },
|
|
21
|
+
levelControl: { currentLevel: 127, minLevel: 1, maxLevel: 254 },
|
|
22
|
+
colorControl: {
|
|
23
|
+
colorMode: api.matter.types.ColorControl.ColorMode.CurrentHueAndCurrentSaturation,
|
|
24
|
+
currentHue: 0,
|
|
25
|
+
currentSaturation: 254,
|
|
26
|
+
currentX: 41942,
|
|
27
|
+
currentY: 21626,
|
|
28
|
+
colorTemperatureMireds: 250,
|
|
29
|
+
colorTempPhysicalMinMireds: 147,
|
|
30
|
+
colorTempPhysicalMaxMireds: 454,
|
|
31
|
+
coupleColorTempToLevelMinMireds: 147,
|
|
41
32
|
},
|
|
33
|
+
}
|
|
42
34
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
this.handleSetLevel(request),
|
|
51
|
-
},
|
|
52
|
-
colorControl: {
|
|
53
|
-
moveToColorLogic: async (request: MatterRequests.MoveToColor) =>
|
|
54
|
-
this.handleSetColor(request),
|
|
55
|
-
moveToHueAndSaturationLogic: async (request: MatterRequests.MoveToHueAndSaturation) =>
|
|
56
|
-
this.handleSetHueSaturation(request),
|
|
57
|
-
moveToColorTemperatureLogic: async (request: MatterRequests.MoveToColorTemperature) =>
|
|
58
|
-
this.handleSetColorTemperature(request),
|
|
59
|
-
},
|
|
35
|
+
const handlers = opts?.handlers ?? {
|
|
36
|
+
onOff: { on: async () => this.handleOn(), off: async () => this.handleOff() },
|
|
37
|
+
levelControl: { moveToLevelWithOnOff: async (request: MatterRequests.MoveToLevel) => this.handleSetLevel(request) },
|
|
38
|
+
colorControl: {
|
|
39
|
+
moveToColorLogic: async (request: MatterRequests.MoveToColor) => this.handleSetColor(request),
|
|
40
|
+
moveToHueAndSaturationLogic: async (request: MatterRequests.MoveToHueAndSaturation) => this.handleSetHueSaturation(request),
|
|
41
|
+
moveToColorTemperatureLogic: async (request: MatterRequests.MoveToColorTemperature) => this.handleSetColorTemperature(request),
|
|
60
42
|
},
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
super(api, log, {
|
|
46
|
+
uuid: opts?.uuid ?? api.matter.uuid.generate(serialNumber),
|
|
47
|
+
displayName,
|
|
48
|
+
deviceType: api.matter.deviceTypes.ExtendedColorLight,
|
|
49
|
+
serialNumber,
|
|
50
|
+
manufacturer,
|
|
51
|
+
model,
|
|
52
|
+
firmwareRevision,
|
|
53
|
+
hardwareRevision,
|
|
54
|
+
clusters,
|
|
55
|
+
handlers,
|
|
56
|
+
context: { deviceId: opts?.deviceId, ...(opts?.context ?? {}) },
|
|
61
57
|
})
|
|
62
58
|
|
|
63
59
|
this.logInfo('initialized.')
|
|
@@ -7,35 +7,43 @@ import type { API, Logger, MatterRequests } from 'homebridge'
|
|
|
7
7
|
import { BaseMatterAccessory } from './BaseMatterAccessory.js'
|
|
8
8
|
|
|
9
9
|
export class FanAccessory extends BaseMatterAccessory {
|
|
10
|
-
constructor(api: API, log: Logger) {
|
|
11
|
-
const serialNumber = 'FAN-001'
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
manufacturer: 'Homebridge Matter',
|
|
18
|
-
model: 'HB-MATTER-FAN',
|
|
19
|
-
firmwareRevision: '2.0.0',
|
|
20
|
-
hardwareRevision: '1.0.0',
|
|
10
|
+
constructor(api: API, log: Logger, opts?: Partial<import('./BaseMatterAccessory').BaseMatterAccessoryConfig & { deviceId?: string }>) {
|
|
11
|
+
const serialNumber = opts?.serialNumber ?? 'FAN-001'
|
|
12
|
+
const displayName = opts?.displayName ?? 'Fan'
|
|
13
|
+
const manufacturer = opts?.manufacturer ?? 'Homebridge Matter'
|
|
14
|
+
const model = opts?.model ?? 'HB-MATTER-FAN'
|
|
15
|
+
const firmwareRevision = opts?.firmwareRevision ?? '2.0.0'
|
|
16
|
+
const hardwareRevision = opts?.hardwareRevision ?? '1.0.0'
|
|
21
17
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
},
|
|
18
|
+
const clusters = opts?.clusters ?? {
|
|
19
|
+
fanControl: {
|
|
20
|
+
fanMode: api.matter.types.FanControl.FanMode.Off,
|
|
21
|
+
fanModeSequence: api.matter.types.FanControl.FanModeSequence.OffLowMedHigh,
|
|
22
|
+
percentSetting: 0,
|
|
23
|
+
percentCurrent: 0,
|
|
29
24
|
},
|
|
25
|
+
}
|
|
30
26
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
this.handlePercentSettingChange(request),
|
|
37
|
-
},
|
|
27
|
+
const handlers = opts?.handlers ?? {
|
|
28
|
+
fanControl: {
|
|
29
|
+
step: async (request: MatterRequests.FanStep) => this.handleStep(request),
|
|
30
|
+
fanModeChange: async (request: { fanMode: number, oldFanMode: number }) => this.handleFanModeChange(request),
|
|
31
|
+
percentSettingChange: async (request: { percentSetting: number | null, oldPercentSetting: number | null }) => this.handlePercentSettingChange(request),
|
|
38
32
|
},
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
super(api, log, {
|
|
36
|
+
uuid: opts?.uuid ?? api.matter.uuid.generate(serialNumber),
|
|
37
|
+
displayName,
|
|
38
|
+
deviceType: api.matter.deviceTypes.Fan,
|
|
39
|
+
serialNumber,
|
|
40
|
+
manufacturer,
|
|
41
|
+
model,
|
|
42
|
+
firmwareRevision,
|
|
43
|
+
hardwareRevision,
|
|
44
|
+
clusters,
|
|
45
|
+
handlers,
|
|
46
|
+
context: { deviceId: opts?.deviceId, ...(opts?.context ?? {}) },
|
|
39
47
|
})
|
|
40
48
|
|
|
41
49
|
this.logInfo('initialized.')
|
|
@@ -7,25 +7,27 @@ import type { API, Logger } from 'homebridge'
|
|
|
7
7
|
import { BaseMatterAccessory } from './BaseMatterAccessory.js'
|
|
8
8
|
|
|
9
9
|
export class HumiditySensorAccessory extends BaseMatterAccessory {
|
|
10
|
-
constructor(api: API, log: Logger) {
|
|
11
|
-
const serialNumber = 'SENSOR-005'
|
|
10
|
+
constructor(api: API, log: Logger, opts?: Partial<import('./BaseMatterAccessory').BaseMatterAccessoryConfig & { deviceId?: string }>) {
|
|
11
|
+
const serialNumber = opts?.serialNumber ?? 'SENSOR-005'
|
|
12
|
+
const displayName = opts?.displayName ?? 'Humidity Sensor'
|
|
13
|
+
const manufacturer = opts?.manufacturer ?? 'Homebridge Matter'
|
|
14
|
+
const model = opts?.model ?? 'HB-MATTER-SENSOR-HUMIDITY'
|
|
15
|
+
const firmwareRevision = opts?.firmwareRevision ?? '2.0.0'
|
|
16
|
+
const hardwareRevision = opts?.hardwareRevision ?? '1.0.0'
|
|
17
|
+
|
|
18
|
+
const clusters = opts?.clusters ?? { relativeHumidityMeasurement: { measuredValue: 5500, minMeasuredValue: 0, maxMeasuredValue: 10000 } }
|
|
19
|
+
|
|
12
20
|
super(api, log, {
|
|
13
|
-
uuid: api.matter.uuid.generate(serialNumber),
|
|
14
|
-
displayName
|
|
21
|
+
uuid: opts?.uuid ?? api.matter.uuid.generate(serialNumber),
|
|
22
|
+
displayName,
|
|
15
23
|
deviceType: api.matter.deviceTypes.HumiditySensor,
|
|
16
24
|
serialNumber,
|
|
17
|
-
manufacturer
|
|
18
|
-
model
|
|
19
|
-
firmwareRevision
|
|
20
|
-
hardwareRevision
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
relativeHumidityMeasurement: {
|
|
24
|
-
measuredValue: 5500, // 55% (in hundredths of a percent)
|
|
25
|
-
minMeasuredValue: 0,
|
|
26
|
-
maxMeasuredValue: 10000,
|
|
27
|
-
},
|
|
28
|
-
},
|
|
25
|
+
manufacturer,
|
|
26
|
+
model,
|
|
27
|
+
firmwareRevision,
|
|
28
|
+
hardwareRevision,
|
|
29
|
+
clusters,
|
|
30
|
+
context: { deviceId: opts?.deviceId, ...(opts?.context ?? {}) },
|
|
29
31
|
})
|
|
30
32
|
|
|
31
33
|
this.logInfo('initialized.')
|
|
@@ -7,23 +7,27 @@ import type { API, Logger } from 'homebridge'
|
|
|
7
7
|
import { BaseMatterAccessory } from './BaseMatterAccessory.js'
|
|
8
8
|
|
|
9
9
|
export class LeakSensorAccessory extends BaseMatterAccessory {
|
|
10
|
-
constructor(api: API, log: Logger) {
|
|
11
|
-
const serialNumber = 'SENSOR-007'
|
|
10
|
+
constructor(api: API, log: Logger, opts?: Partial<import('./BaseMatterAccessory').BaseMatterAccessoryConfig & { deviceId?: string }>) {
|
|
11
|
+
const serialNumber = opts?.serialNumber ?? 'SENSOR-007'
|
|
12
|
+
const displayName = opts?.displayName ?? 'Leak Sensor'
|
|
13
|
+
const manufacturer = opts?.manufacturer ?? 'Homebridge Matter'
|
|
14
|
+
const model = opts?.model ?? 'HB-MATTER-SENSOR-LEAK'
|
|
15
|
+
const firmwareRevision = opts?.firmwareRevision ?? '2.0.0'
|
|
16
|
+
const hardwareRevision = opts?.hardwareRevision ?? '1.0.0'
|
|
17
|
+
|
|
18
|
+
const clusters = opts?.clusters ?? { booleanState: { stateValue: false } }
|
|
19
|
+
|
|
12
20
|
super(api, log, {
|
|
13
|
-
uuid: api.matter.uuid.generate(serialNumber),
|
|
14
|
-
displayName
|
|
21
|
+
uuid: opts?.uuid ?? api.matter.uuid.generate(serialNumber),
|
|
22
|
+
displayName,
|
|
15
23
|
deviceType: api.matter.deviceTypes.LeakSensor,
|
|
16
24
|
serialNumber,
|
|
17
|
-
manufacturer
|
|
18
|
-
model
|
|
19
|
-
firmwareRevision
|
|
20
|
-
hardwareRevision
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
booleanState: {
|
|
24
|
-
stateValue: false, // false = dry, true = leak
|
|
25
|
-
},
|
|
26
|
-
},
|
|
25
|
+
manufacturer,
|
|
26
|
+
model,
|
|
27
|
+
firmwareRevision,
|
|
28
|
+
hardwareRevision,
|
|
29
|
+
clusters,
|
|
30
|
+
context: { deviceId: opts?.deviceId, ...(opts?.context ?? {}) },
|
|
27
31
|
})
|
|
28
32
|
|
|
29
33
|
this.logInfo('initialized.')
|
|
@@ -7,25 +7,27 @@ import type { API, Logger } from 'homebridge'
|
|
|
7
7
|
import { BaseMatterAccessory } from './BaseMatterAccessory.js'
|
|
8
8
|
|
|
9
9
|
export class LightSensorAccessory extends BaseMatterAccessory {
|
|
10
|
-
constructor(api: API, log: Logger) {
|
|
11
|
-
const serialNumber = 'SENSOR-002'
|
|
10
|
+
constructor(api: API, log: Logger, opts?: Partial<import('./BaseMatterAccessory').BaseMatterAccessoryConfig & { deviceId?: string }>) {
|
|
11
|
+
const serialNumber = opts?.serialNumber ?? 'SENSOR-002'
|
|
12
|
+
const displayName = opts?.displayName ?? 'Light Sensor'
|
|
13
|
+
const manufacturer = opts?.manufacturer ?? 'Homebridge Matter'
|
|
14
|
+
const model = opts?.model ?? 'HB-MATTER-SENSOR-LIGHT'
|
|
15
|
+
const firmwareRevision = opts?.firmwareRevision ?? '2.0.0'
|
|
16
|
+
const hardwareRevision = opts?.hardwareRevision ?? '1.0.0'
|
|
17
|
+
|
|
18
|
+
const clusters = opts?.clusters ?? { illuminanceMeasurement: { measuredValue: 5000, minMeasuredValue: 1, maxMeasuredValue: 65534 } }
|
|
19
|
+
|
|
12
20
|
super(api, log, {
|
|
13
|
-
uuid: api.matter.uuid.generate(serialNumber),
|
|
14
|
-
displayName
|
|
21
|
+
uuid: opts?.uuid ?? api.matter.uuid.generate(serialNumber),
|
|
22
|
+
displayName,
|
|
15
23
|
deviceType: api.matter.deviceTypes.LightSensor,
|
|
16
24
|
serialNumber,
|
|
17
|
-
manufacturer
|
|
18
|
-
model
|
|
19
|
-
firmwareRevision
|
|
20
|
-
hardwareRevision
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
illuminanceMeasurement: {
|
|
24
|
-
measuredValue: 5000,
|
|
25
|
-
minMeasuredValue: 1,
|
|
26
|
-
maxMeasuredValue: 65534,
|
|
27
|
-
},
|
|
28
|
-
},
|
|
25
|
+
manufacturer,
|
|
26
|
+
model,
|
|
27
|
+
firmwareRevision,
|
|
28
|
+
hardwareRevision,
|
|
29
|
+
clusters,
|
|
30
|
+
context: { deviceId: opts?.deviceId, ...(opts?.context ?? {}) },
|
|
29
31
|
})
|
|
30
32
|
|
|
31
33
|
this.logInfo('initialized.')
|
|
@@ -7,37 +7,33 @@ import type { API, Logger } from 'homebridge'
|
|
|
7
7
|
import { BaseMatterAccessory } from './BaseMatterAccessory.js'
|
|
8
8
|
|
|
9
9
|
export class OccupancySensorAccessory extends BaseMatterAccessory {
|
|
10
|
-
constructor(api: API, log: Logger) {
|
|
11
|
-
const serialNumber = 'SENSOR-003'
|
|
10
|
+
constructor(api: API, log: Logger, opts?: Partial<import('./BaseMatterAccessory').BaseMatterAccessoryConfig & { deviceId?: string }>) {
|
|
11
|
+
const serialNumber = opts?.serialNumber ?? 'SENSOR-003'
|
|
12
12
|
// Note: Matter.js API calls this "MotionSensor" but it's actually an Occupancy Sensor
|
|
13
13
|
const OccupancySensingServer = api.matter.deviceTypes.MotionSensor.requirements.OccupancySensingServer
|
|
14
14
|
const OccupancySensorWithPIR = api.matter.deviceTypes.MotionSensor.with(
|
|
15
15
|
OccupancySensingServer.with('PassiveInfrared'),
|
|
16
16
|
)
|
|
17
17
|
|
|
18
|
+
const clusters = opts?.clusters ?? {
|
|
19
|
+
occupancySensing: {
|
|
20
|
+
occupancy: { occupied: false },
|
|
21
|
+
occupancySensorType: 0,
|
|
22
|
+
occupancySensorTypeBitmap: { pir: true, ultrasonic: false, physicalContact: false },
|
|
23
|
+
},
|
|
24
|
+
}
|
|
25
|
+
|
|
18
26
|
super(api, log, {
|
|
19
|
-
uuid: api.matter.uuid.generate(serialNumber),
|
|
20
|
-
displayName: 'Occupancy Sensor',
|
|
27
|
+
uuid: opts?.uuid ?? api.matter.uuid.generate(serialNumber),
|
|
28
|
+
displayName: opts?.displayName ?? 'Occupancy Sensor',
|
|
21
29
|
deviceType: OccupancySensorWithPIR,
|
|
22
30
|
serialNumber,
|
|
23
|
-
manufacturer: 'Homebridge Matter',
|
|
24
|
-
model: 'HB-MATTER-SENSOR-OCCUPANCY',
|
|
25
|
-
firmwareRevision: '2.0.0',
|
|
26
|
-
hardwareRevision: '1.0.0',
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
occupancySensing: {
|
|
30
|
-
occupancy: {
|
|
31
|
-
occupied: false,
|
|
32
|
-
},
|
|
33
|
-
occupancySensorType: 0,
|
|
34
|
-
occupancySensorTypeBitmap: {
|
|
35
|
-
pir: true,
|
|
36
|
-
ultrasonic: false,
|
|
37
|
-
physicalContact: false,
|
|
38
|
-
},
|
|
39
|
-
},
|
|
40
|
-
},
|
|
31
|
+
manufacturer: opts?.manufacturer ?? 'Homebridge Matter',
|
|
32
|
+
model: opts?.model ?? 'HB-MATTER-SENSOR-OCCUPANCY',
|
|
33
|
+
firmwareRevision: opts?.firmwareRevision ?? '2.0.0',
|
|
34
|
+
hardwareRevision: opts?.hardwareRevision ?? '1.0.0',
|
|
35
|
+
clusters,
|
|
36
|
+
context: { deviceId: opts?.deviceId, ...(opts?.context ?? {}) },
|
|
41
37
|
})
|
|
42
38
|
|
|
43
39
|
this.logInfo('initialized.')
|
|
@@ -16,17 +16,29 @@ import { BaseMatterAccessory } from './BaseMatterAccessory.js'
|
|
|
16
16
|
* It extends BaseMatterAccessory to inherit common functionality.
|
|
17
17
|
*/
|
|
18
18
|
export class OnOffLightAccessory extends BaseMatterAccessory {
|
|
19
|
-
constructor(api: API, log: Logger) {
|
|
20
|
-
const serialNumber = 'LIGHT-001'
|
|
21
|
-
const displayName = 'On/Off Light'
|
|
22
|
-
const manufacturer = 'Homebridge Matter'
|
|
23
|
-
const model = 'HB-MATTER-LIGHT-ON-OFF'
|
|
24
|
-
const firmwareRevision = '2.0.0'
|
|
25
|
-
const hardwareRevision = '1.0.0'
|
|
19
|
+
constructor(api: API, log: Logger, opts?: Partial<import('./BaseMatterAccessory').BaseMatterAccessoryConfig & { deviceId?: string }>) {
|
|
20
|
+
const serialNumber = opts?.serialNumber ?? 'LIGHT-001'
|
|
21
|
+
const displayName = opts?.displayName ?? 'On/Off Light'
|
|
22
|
+
const manufacturer = opts?.manufacturer ?? 'Homebridge Matter'
|
|
23
|
+
const model = opts?.model ?? 'HB-MATTER-LIGHT-ON-OFF'
|
|
24
|
+
const firmwareRevision = opts?.firmwareRevision ?? '2.0.0'
|
|
25
|
+
const hardwareRevision = opts?.hardwareRevision ?? '1.0.0'
|
|
26
|
+
|
|
27
|
+
const clusters = opts?.clusters ?? { onOff: { onOff: true } }
|
|
28
|
+
const handlers = opts?.handlers ?? {
|
|
29
|
+
onOff: {
|
|
30
|
+
on: async () => {
|
|
31
|
+
log.debug(`${displayName} on handler invoked (default no-op).`)
|
|
32
|
+
},
|
|
33
|
+
off: async () => {
|
|
34
|
+
log.debug(`${displayName} off handler invoked (default no-op).`)
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
}
|
|
26
38
|
|
|
27
39
|
// Call parent constructor with device configuration
|
|
28
40
|
super(api, log, {
|
|
29
|
-
uuid: api.matter.uuid.generate(serialNumber),
|
|
41
|
+
uuid: opts?.uuid ?? api.matter.uuid.generate(serialNumber),
|
|
30
42
|
displayName,
|
|
31
43
|
deviceType: api.matter.deviceTypes.OnOffLight,
|
|
32
44
|
serialNumber,
|
|
@@ -34,21 +46,9 @@ export class OnOffLightAccessory extends BaseMatterAccessory {
|
|
|
34
46
|
model,
|
|
35
47
|
firmwareRevision,
|
|
36
48
|
hardwareRevision,
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
onOff: {
|
|
41
|
-
onOff: true, // initial state: light is on
|
|
42
|
-
},
|
|
43
|
-
},
|
|
44
|
-
|
|
45
|
-
// Command handlers
|
|
46
|
-
handlers: {
|
|
47
|
-
onOff: {
|
|
48
|
-
on: async () => this.handleOnCommand(),
|
|
49
|
-
off: async () => this.handleOffCommand(),
|
|
50
|
-
},
|
|
51
|
-
},
|
|
49
|
+
clusters,
|
|
50
|
+
handlers,
|
|
51
|
+
context: { deviceId: opts?.deviceId, ...(opts?.context ?? {}) },
|
|
52
52
|
})
|
|
53
53
|
|
|
54
54
|
this.logInfo('initialized.')
|
|
@@ -7,45 +7,39 @@ import type { API, Logger } from 'homebridge'
|
|
|
7
7
|
import { BaseMatterAccessory } from './BaseMatterAccessory.js'
|
|
8
8
|
|
|
9
9
|
export class OnOffOutletAccessory extends BaseMatterAccessory {
|
|
10
|
-
constructor(api: API, log: Logger) {
|
|
11
|
-
const serialNumber = 'OUTLET-001'
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
firmwareRevision: '2.0.0',
|
|
20
|
-
hardwareRevision: '1.0.0',
|
|
21
|
-
|
|
22
|
-
clusters: {
|
|
23
|
-
onOff: {
|
|
24
|
-
onOff: false,
|
|
10
|
+
constructor(api: API, log: Logger, opts?: Partial<import('./BaseMatterAccessory').BaseMatterAccessoryConfig & { deviceId?: string }>) {
|
|
11
|
+
const serialNumber = opts?.serialNumber ?? 'OUTLET-001'
|
|
12
|
+
const displayName = opts?.displayName ?? 'On/Off Outlet'
|
|
13
|
+
const clusters = opts?.clusters ?? { onOff: { onOff: false } }
|
|
14
|
+
const handlers = opts?.handlers ?? {
|
|
15
|
+
onOff: {
|
|
16
|
+
on: async () => {
|
|
17
|
+
// default no-op; platform may inject handlers via opts.handlers
|
|
18
|
+
log.debug(`${displayName} on handler invoked (default no-op).`)
|
|
25
19
|
},
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
handlers: {
|
|
29
|
-
onOff: {
|
|
30
|
-
on: async () => this.handleOn(),
|
|
31
|
-
off: async () => this.handleOff(),
|
|
20
|
+
off: async () => {
|
|
21
|
+
log.debug(`${displayName} off handler invoked (default no-op).`)
|
|
32
22
|
},
|
|
33
23
|
},
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
super(api, log, {
|
|
27
|
+
uuid: opts?.uuid ?? api.matter.uuid.generate(serialNumber),
|
|
28
|
+
displayName,
|
|
29
|
+
deviceType: api.matter.deviceTypes.OnOffOutlet,
|
|
30
|
+
serialNumber,
|
|
31
|
+
manufacturer: opts?.manufacturer ?? 'Homebridge Matter',
|
|
32
|
+
model: opts?.model ?? 'HB-MATTER-OUTLET-ON-OFF',
|
|
33
|
+
firmwareRevision: opts?.firmwareRevision ?? '2.0.0',
|
|
34
|
+
hardwareRevision: opts?.hardwareRevision ?? '1.0.0',
|
|
35
|
+
clusters,
|
|
36
|
+
handlers,
|
|
37
|
+
context: { deviceId: opts?.deviceId, ...(opts?.context ?? {}) },
|
|
34
38
|
})
|
|
35
39
|
|
|
36
40
|
this.logInfo('initialized.')
|
|
37
41
|
}
|
|
38
42
|
|
|
39
|
-
private async handleOn(): Promise<void> {
|
|
40
|
-
this.logInfo('turning on.')
|
|
41
|
-
// TODO: await myOutletAPI.turnOn()
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
private async handleOff(): Promise<void> {
|
|
45
|
-
this.logInfo('turning off.')
|
|
46
|
-
// TODO: await myOutletAPI.turnOff()
|
|
47
|
-
}
|
|
48
|
-
|
|
49
43
|
public updateOnOffState(isOn: boolean): void {
|
|
50
44
|
this.updateState(this.api.matter.clusterNames.OnOff, { onOff: isOn })
|
|
51
45
|
}
|
|
@@ -7,30 +7,29 @@ import type { API, Logger } from 'homebridge'
|
|
|
7
7
|
import { BaseMatterAccessory } from './BaseMatterAccessory.js'
|
|
8
8
|
|
|
9
9
|
export class OnOffSwitchAccessory extends BaseMatterAccessory {
|
|
10
|
-
constructor(api: API, log: Logger) {
|
|
11
|
-
const serialNumber = 'SWITCH-001'
|
|
10
|
+
constructor(api: API, log: Logger, opts?: Partial<import('./BaseMatterAccessory').BaseMatterAccessoryConfig & { deviceId?: string }>) {
|
|
11
|
+
const serialNumber = opts?.serialNumber ?? 'SWITCH-001'
|
|
12
|
+
const displayName = opts?.displayName ?? 'On/Off Switch'
|
|
13
|
+
const manufacturer = opts?.manufacturer ?? 'Homebridge Matter'
|
|
14
|
+
const model = opts?.model ?? 'HB-MATTER-SWITCH-ON-OFF'
|
|
15
|
+
const firmwareRevision = opts?.firmwareRevision ?? '2.0.0'
|
|
16
|
+
const hardwareRevision = opts?.hardwareRevision ?? '1.0.0'
|
|
17
|
+
|
|
18
|
+
const clusters = opts?.clusters ?? { onOff: { onOff: false } }
|
|
19
|
+
const handlers = opts?.handlers ?? { onOff: { on: async () => this.handleOn(), off: async () => this.handleOff() } }
|
|
20
|
+
|
|
12
21
|
super(api, log, {
|
|
13
|
-
uuid: api.matter.uuid.generate(serialNumber),
|
|
14
|
-
displayName
|
|
22
|
+
uuid: opts?.uuid ?? api.matter.uuid.generate(serialNumber),
|
|
23
|
+
displayName,
|
|
15
24
|
deviceType: api.matter.deviceTypes.OnOffSwitch,
|
|
16
25
|
serialNumber,
|
|
17
|
-
manufacturer
|
|
18
|
-
model
|
|
19
|
-
firmwareRevision
|
|
20
|
-
hardwareRevision
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
onOff: false,
|
|
25
|
-
},
|
|
26
|
-
},
|
|
27
|
-
|
|
28
|
-
handlers: {
|
|
29
|
-
onOff: {
|
|
30
|
-
on: async () => this.handleOn(),
|
|
31
|
-
off: async () => this.handleOff(),
|
|
32
|
-
},
|
|
33
|
-
},
|
|
26
|
+
manufacturer,
|
|
27
|
+
model,
|
|
28
|
+
firmwareRevision,
|
|
29
|
+
hardwareRevision,
|
|
30
|
+
clusters,
|
|
31
|
+
handlers,
|
|
32
|
+
context: { deviceId: opts?.deviceId, ...(opts?.context ?? {}) },
|
|
34
33
|
})
|
|
35
34
|
|
|
36
35
|
this.logInfo('initialized.')
|