From 279a77f81b7dbf16f5196fa8db20968de35e704d Mon Sep 17 00:00:00 2001 From: kyleboyer Date: Sat, 13 Jul 2024 08:15:52 -0500 Subject: [PATCH] Added garage motion sensor to hub --- src/hub.ts | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/hub.ts b/src/hub.ts index f5b1ef1..f8d28eb 100644 --- a/src/hub.ts +++ b/src/hub.ts @@ -6,6 +6,7 @@ import { BlaQHomebridgePluginPlatform } from './platform.js'; import { BlaQGarageDoorAccessory } from './accessory/garage-door.js'; import { BlaQGarageLightAccessory } from './accessory/garage-light.js'; import { BlaQGarageLockAccessory } from './accessory/garage-lock.js'; +import { BlaQGarageMotionSensorAccessory } from './accessory/garage-motion-sensor.js'; interface BlaQPingEvent { title: string; @@ -127,10 +128,25 @@ export class BlaQHub { })); } + private initGarageMotionSensorAccessory({ model, serialNumber }: ModelAndSerialNumber){ + const accessorySuffix = 'motion-sensor'; + const nonMainAccessoryMACAddress = this.configDevice.mac && `${this.configDevice.mac}-${accessorySuffix}`; + const nonMainAccessorySerialNumber = `${serialNumber}-${accessorySuffix}`; + const {platform, accessory} = this.initAccessoryCallback( + { ...this.configDevice, mac: nonMainAccessoryMACAddress }, + model, + nonMainAccessorySerialNumber, + ); + this.accessories.push(new BlaQGarageMotionSensorAccessory({ + platform, accessory, model, serialNumber, apiBaseURL: this.getAPIBaseURL(), + })); + } + private initAccessories({ model, serialNumber }: ModelAndSerialNumber){ this.initGarageDoorAccessory({ model, serialNumber }); this.initGarageLightAccessory({ model, serialNumber }); this.initGarageLockAccessory({ model, serialNumber }); + this.initGarageMotionSensorAccessory({ model, serialNumber }); } private handlePingUpdate(msg: PingMessageEvent){