diff --git a/config.schema.json b/config.schema.json index 0be07af..a090787 100644 --- a/config.schema.json +++ b/config.schema.json @@ -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 } } } diff --git a/src/hub.ts b/src/hub.ts index df2f4af..5410e93 100644 --- a/src/hub.ts +++ b/src/hub.ts @@ -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'; @@ -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; @@ -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){ diff --git a/src/platform.ts b/src/platform.ts index e9a3657..08b46bb 100644 --- a/src/platform.ts +++ b/src/platform.ts @@ -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];