Skip to content

Commit b9dce31

Browse files
committed
Dependency for getting Matter API
1 parent a94ef83 commit b9dce31

2 files changed

Lines changed: 13 additions & 3 deletions

File tree

src/homebridge/platform.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,15 @@ export class HomebridgeEasyMQTT implements DynamicPlatformPlugin {
8181
const Characteristic = this.api.hap.Characteristic;
8282
const HapStatusError = this.api.hap.HapStatusError;
8383

84+
const getMatter = () => {
85+
86+
if (!this.api.matter) {
87+
throw new Error('Matter API is not available — this plugin requires a Matter-enabled Homebridge bridge.'); // TODO
88+
}
89+
90+
return this.api.matter;
91+
};
92+
8493
const history = new History(this.api, this.log);
8594

8695
for (const accessoryConfig of this.config.accessories) {
@@ -104,7 +113,7 @@ export class HomebridgeEasyMQTT implements DynamicPlatformPlugin {
104113
const uuid = this.api.hap.uuid.generate(id);
105114

106115
const platformAccessory = this.createPlatformAccessory(accessoryConfig.info.name, uuid);
107-
const dependency: AccessoryDependency = { Service, Characteristic, HapStatusError, platformAccessory, log: this.log, history: history };
116+
const dependency: AccessoryDependency = { Service, Characteristic, HapStatusError, getMatter, platformAccessory, log: this.log, history: history };
108117

109118
const accessory = createAccessory(dependency, accessoryConfig);
110119

@@ -120,7 +129,7 @@ export class HomebridgeEasyMQTT implements DynamicPlatformPlugin {
120129

121130
const uuid = this.api.hap.uuid.generate(groupName);
122131
const platformAccessory = this.createPlatformAccessory(groupName, uuid);
123-
const dependency: AccessoryDependency = { Service, Characteristic, HapStatusError, platformAccessory, log: this.log, history: history };
132+
const dependency: AccessoryDependency = { Service, Characteristic, HapStatusError, getMatter, platformAccessory, log: this.log, history: history };
124133

125134
const configs = groups.get(groupName)!;
126135

src/model/types.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { PlatformConfig as HBPlatformConfig, PlatformAccessory } from 'homebridge';
1+
import { PlatformConfig as HBPlatformConfig, MatterAPI, PlatformAccessory } from 'homebridge';
22

33
export type ServiceType = typeof import('homebridge').Service;
44
export type CharacteristicType = typeof import('homebridge').Characteristic;
@@ -15,6 +15,7 @@ export type AccessoryDependency = {
1515
Service: ServiceType,
1616
Characteristic: CharacteristicType,
1717
HapStatusError: HapStatusErrorType,
18+
getMatter: () => MatterAPI,
1819
platformAccessory: PlatformAccessory,
1920
log: Log,
2021
history: History,

0 commit comments

Comments
 (0)