Skip to content

Commit

Permalink
Added garage motion sensor to hub
Browse files Browse the repository at this point in the history
  • Loading branch information
KyleBoyer committed Jul 13, 2024
1 parent 145b471 commit 279a77f
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/hub.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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){
Expand Down

0 comments on commit 279a77f

Please sign in to comment.