Skip to content

Commit

Permalink
Show as one device in HK
Browse files Browse the repository at this point in the history
  • Loading branch information
KyleBoyer committed Jul 15, 2024
1 parent f7fc576 commit 884a876
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 9 deletions.
30 changes: 30 additions & 0 deletions config.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,36 @@
}
}
}
},
"enableSeparateObstructionSensor": {
"title": "Enable publishing a separate \"occupancy\" obstruction sensor for the garage",
"type": "boolean",
"default": true
},
"enableMotionSensor": {
"title": "Enable publishing a motion sensor",
"type": "boolean",
"default": true
},
"enablePreCloseWarning": {
"title": "Publish an \"outlet\" accessory to trigger the ple-close warning",
"type": "boolean",
"default": true
},
"enableLockRemotes": {
"title": "Enable lock control over the remotes",
"type": "boolean",
"default": true
},
"enableLight": {
"title": "Enable controlling the garage light",
"type": "boolean",
"default": true
},
"enableLearnMode": {
"title": "Enable controlling the garage learn/pairing mode",
"type": "boolean",
"default": true
}
}
}
Expand Down
33 changes: 25 additions & 8 deletions src/hub.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { AutoReconnectingEventSource, LogMessageEvent, PingMessageEvent, StateUpdateMessageEvent } from './utils/eventsource.js';
import { Logger, PlatformAccessory } from 'homebridge';
import { Logger, PlatformAccessory, PlatformConfig } from 'homebridge';
import { ConfigDevice } from './types.js';
import { BaseBlaQAccessory } from './accessory/base.js';
import { BlaQHomebridgePluginPlatform } from './platform.js';
Expand Down Expand Up @@ -38,7 +38,12 @@ export class BlaQHub {
private initialized = false;
private accessories: BaseBlaQAccessory[] = [];

constructor(private readonly configDevice: ConfigDevice, initAccessoryCallback: BlaQInitAccessoryCallback, logger: Logger) {
constructor(
private readonly pluginConfig: PlatformConfig,
private readonly configDevice: ConfigDevice,
initAccessoryCallback: BlaQInitAccessoryCallback,
logger: Logger,
) {
logger.debug('Initializing BlaQHub...');
this.host = configDevice.host;
this.port = configDevice.port;
Expand Down Expand Up @@ -185,12 +190,24 @@ export class BlaQHub {

private initAccessories({ model, serialNumber }: ModelAndSerialNumber){
this.initGarageDoorAccessory({ model, serialNumber });
this.initGarageLightAccessory({ model, serialNumber });
this.initGarageLockAccessory({ model, serialNumber });
this.initGarageMotionSensorAccessory({ model, serialNumber });
this.initGaragePreCloseWarningAccessory({ model, serialNumber });
this.initGarageLearnModeAccessory({ model, serialNumber });
this.initGarageObstructionSensorAccessory({ model, serialNumber });
if(this.pluginConfig.enableLight) {
this.initGarageLightAccessory({ model, serialNumber });
}
if(this.pluginConfig.enableLockRemotes){
this.initGarageLockAccessory({ model, serialNumber });
}
if(this.pluginConfig.enableMotionSensor){
this.initGarageMotionSensorAccessory({ model, serialNumber });
}
if(this.pluginConfig.enablePreCloseWarning){
this.initGaragePreCloseWarningAccessory({ model, serialNumber });
}
if(this.pluginConfig.enableLearnMode){
this.initGarageLearnModeAccessory({ model, serialNumber });
}
if(this.pluginConfig.enableSeparateObstructionSensor){
this.initGarageObstructionSensorAccessory({ model, serialNumber });
}
}

private handlePingUpdate(msg: PingMessageEvent){
Expand Down
2 changes: 1 addition & 1 deletion src/platform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export class BlaQHomebridgePluginPlatform implements DynamicPlatformPlugin {
possiblyRegisterNewDevice(device: ConfigDevice){
const deviceKey = this.getDeviceKey(device);
if(!this.hubs[deviceKey]) {
this.hubs[deviceKey] = new BlaQHub(device, this.registerDiscoveredDevice.bind(this), this.logger);
this.hubs[deviceKey] = new BlaQHub(this.config, device, this.registerDiscoveredDevice.bind(this), this.logger);
this.hubAccessories[deviceKey] = [];
}else{
const existingDiscoverer = this.hubs[deviceKey];
Expand Down

0 comments on commit 884a876

Please sign in to comment.