@@ -48,8 +48,6 @@ export class HomebridgeEasyMQTT implements DynamicPlatformPlugin {
4848 api . isMatterEnabled ?.( ) === true ? 'Enabled' : 'Disabled' ,
4949 ) ;
5050
51- initEveCharacteristics ( api ) ;
52-
5351 this . api . on ( 'didFinishLaunching' , ( ) => {
5452 this . setup ( ) ;
5553 } ) ;
@@ -88,12 +86,6 @@ export class HomebridgeEasyMQTT implements DynamicPlatformPlugin {
8886
8987 const groups = new Map < string , BaseAccessoryConfig [ ] > ( ) ;
9088
91- const Service = this . api . hap . Service ;
92- const Characteristic = this . api . hap . Characteristic ;
93- const HapStatusError = this . api . hap . HapStatusError ;
94-
95- const history = new History ( this . api , this . log ) ;
96-
9789 for ( const accessoryConfig of this . config . accessories ) {
9890
9991 if ( ! assert ( this . log , PLATFORM_NAME , accessoryConfig , 'info' ) ||
@@ -107,6 +99,8 @@ export class HomebridgeEasyMQTT implements DynamicPlatformPlugin {
10799
108100 if ( accessoryConfig . info . protocol === Protocol . HomeKit ) {
109101
102+ initEveCharacteristics ( this . api ) ;
103+
110104 const groupName = accessoryConfig . info . group ;
111105 if ( groupName !== undefined ) {
112106
@@ -121,12 +115,17 @@ export class HomebridgeEasyMQTT implements DynamicPlatformPlugin {
121115 const uuid = this . api . hap . uuid . generate ( id ) ;
122116
123117 const homekitAccessory = this . createHomeKitAccessory ( accessoryConfig . info . name , uuid ) ;
118+
119+ const Service = this . api . hap . Service ;
120+ const Characteristic = this . api . hap . Characteristic ;
121+ const HapStatusError = this . api . hap . HapStatusError ;
122+
124123 const dependency : AccessoryDependency = {
125- protocol : Protocol . HomeKit ,
124+ protocol : accessoryConfig . info . protocol ,
126125 getHomeKit : ( ) => ( { Service, Characteristic, HapStatusError, accessory : homekitAccessory } ) ,
127126 getMatter : ( ) => undefined ,
128127 log : this . log ,
129- history : history ,
128+ history : History . instance ( this . api , this . log ) ,
130129 } ;
131130
132131 const accessory = createAccessory ( dependency , accessoryConfig ) ;
@@ -165,12 +164,17 @@ export class HomebridgeEasyMQTT implements DynamicPlatformPlugin {
165164
166165 const uuid = this . api . hap . uuid . generate ( groupName ) ;
167166 const homekitAccessory = this . createHomeKitAccessory ( groupName , uuid ) ;
167+
168+ const Service = this . api . hap . Service ;
169+ const Characteristic = this . api . hap . Characteristic ;
170+ const HapStatusError = this . api . hap . HapStatusError ;
171+
168172 const dependency : AccessoryDependency = {
169173 protocol : Protocol . HomeKit ,
170174 getHomeKit : ( ) => ( { Service, Characteristic, HapStatusError, accessory : homekitAccessory } ) ,
171175 getMatter : ( ) => undefined ,
172176 log : this . log ,
173- history : history ,
177+ history : History . instance ( this . api , this . log ) ,
174178 } ;
175179
176180 const configs = groups . get ( groupName ) ! ;
0 commit comments