Skip to content

Commit

Permalink
Logging tweaks/consistency
Browse files Browse the repository at this point in the history
  • Loading branch information
KyleBoyer committed Jul 24, 2024
1 parent 862496c commit 526447c
Show file tree
Hide file tree
Showing 8 changed files with 12 additions and 14 deletions.
5 changes: 5 additions & 0 deletions src/accessory/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ export class BaseBlaQAccessory implements BaseBlaQAccessoryInterface {
}: BaseBlaQAccessoryConstructorParams){
this.platform = platform;
this.logger = this.platform.logger;
this.logger.debug(`Initializing ${this.getSelfClassName()}...`);
this.accessory = accessory;
this.friendlyName = friendlyName;
this.serialNumber = serialNumber;
Expand All @@ -66,6 +67,10 @@ export class BaseBlaQAccessory implements BaseBlaQAccessoryInterface {
.onGet(this.getFirmwareVersion.bind(this));
}

protected getSelfClassName() {
return Object.getPrototypeOf(this).constructor.name;
}

protected getOrAddService(service: WithUUID<typeof Service> | Service): Service{
return this.accessory.getService(service as WithUUID<typeof Service>) ||
this.accessory.addService(service as Service);
Expand Down
3 changes: 1 addition & 2 deletions src/accessory/garage-door.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ export class BlaQGarageDoorAccessory extends BaseBlaQAccessory {

constructor(args: BaseBlaQAccessoryConstructorParams) {
super(args);
this.logger.debug('Initializing BlaQGarageDoorAccessory...');
this.garageDoorService = this.getOrAddService(this.platform.service.GarageDoorOpener);

// Set the service name. This is what is displayed as the name on the Home
Expand Down Expand Up @@ -67,7 +66,7 @@ export class BlaQGarageDoorAccessory extends BaseBlaQAccessory {
this.garageDoorService.getCharacteristic(this.platform.characteristic.LockTargetState)
.onSet(this.updateLockState.bind(this));

this.logger.debug('Initialized BlaQGarageDoorAccessory!');
this.logger.debug(`Initialized ${this.getSelfClassName()}!`);
}

private async updateLockState(lockState: CharacteristicValue){
Expand Down
3 changes: 1 addition & 2 deletions src/accessory/garage-learn-mode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ export class BlaQGarageLearnModeAccessory extends BaseBlaQAccessory {

constructor(args: BaseBlaQAccessoryConstructorParams) {
super(args);
this.logger.debug('Initializing BlaQGarageLearnModeAccessory...');
this.switchService = this.getOrAddService(this.platform.service.Switch);

// Set the service name. This is what is displayed as the name on the Home
Expand All @@ -30,7 +29,7 @@ export class BlaQGarageLearnModeAccessory extends BaseBlaQAccessory {
this.switchService.getCharacteristic(this.platform.characteristic.On)
.onGet(this.getIsOn.bind(this))
.onSet(this.changeIsOn.bind(this));
this.logger.debug('Initialized BlaQGarageLearnModeAccessory!');
this.logger.debug(`Initialized ${this.getSelfClassName()}!`);
}

getIsOn(): CharacteristicValue {
Expand Down
3 changes: 1 addition & 2 deletions src/accessory/garage-light.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ export class BlaQGarageLightAccessory extends BaseBlaQAccessory {

constructor(args: BaseBlaQAccessoryConstructorParams) {
super(args);
this.logger.debug('Initializing BlaQGarageLightAccessory...');
this.lightbulbService = this.getOrAddService(this.platform.service.Lightbulb);

// Set the service name. This is what is displayed as the name on the Home
Expand All @@ -35,7 +34,7 @@ export class BlaQGarageLightAccessory extends BaseBlaQAccessory {
.onGet(this.getPowerState.bind(this))
.onSet(this.changePowerState.bind(this));

this.logger.debug('Initialized BlaQGarageLightAccessory!');
this.logger.debug(`Initialized ${this.getSelfClassName()}!`);
}

getPowerState(): CharacteristicValue {
Expand Down
3 changes: 1 addition & 2 deletions src/accessory/garage-lock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ export class BlaQGarageLockAccessory extends BaseBlaQAccessory {

constructor(args: BaseBlaQAccessoryConstructorParams) {
super(args);
this.logger.debug('Initializing BlaQGarageLockAccessory...');
this.lockService = this.getOrAddService(this.platform.service.LockMechanism);

// Set the service name. This is what is displayed as the name on the Home
Expand All @@ -36,7 +35,7 @@ export class BlaQGarageLockAccessory extends BaseBlaQAccessory {

this.lockService.getCharacteristic(this.platform.characteristic.LockTargetState)
.onSet(this.changeLockState.bind(this));
this.logger.debug('Initialized BlaQGarageLockAccessory!');
this.logger.debug(`Initialized ${this.getSelfClassName()}!`);
}

getLockState(): CharacteristicValue {
Expand Down
3 changes: 1 addition & 2 deletions src/accessory/garage-motion-sensor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ export class BlaQGarageMotionSensorAccessory extends BaseBlaQAccessory {

constructor(args: BaseBlaQAccessoryConstructorParams) {
super(args);
this.logger.debug('Initializing BlaQGarageMotionSensorAccessory...');
this.motionSensorService = this.getOrAddService(this.platform.service.MotionSensor);

// Set the service name. This is what is displayed as the name on the Home
Expand All @@ -30,7 +29,7 @@ export class BlaQGarageMotionSensorAccessory extends BaseBlaQAccessory {
this.motionSensorService.getCharacteristic(this.platform.characteristic.MotionDetected)
.onGet(this.getMotionDetected.bind(this));

this.logger.debug('Initialized BlaQGarageMotionSensorAccessory!');
this.logger.debug(`Initialized ${this.getSelfClassName()}!`);
}

getMotionDetected(): CharacteristicValue {
Expand Down
3 changes: 1 addition & 2 deletions src/accessory/garage-obstruction-sensor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ export class BlaQGarageObstructionSensorAccessory extends BaseBlaQAccessory {

constructor(args: BaseBlaQAccessoryConstructorParams) {
super(args);
this.logger.debug('Initializing BlaQGarageObstructionSensorAccessory...');
this.occupancySensorService = this.getOrAddService(this.platform.service.OccupancySensor);

// Set the service name. This is what is displayed as the name on the Home
Expand All @@ -32,7 +31,7 @@ export class BlaQGarageObstructionSensorAccessory extends BaseBlaQAccessory {
this.occupancySensorService.getCharacteristic(this.platform.characteristic.OccupancyDetected)
.onGet(this.getObstructionDetected.bind(this));

this.logger.debug('Initialized BlaQGarageObstructionSensorAccessory!');
this.logger.debug(`Initialized ${this.getSelfClassName()}!`);
}

getObstructionDetected(): CharacteristicValue {
Expand Down
3 changes: 1 addition & 2 deletions src/accessory/garage-pre-close-warning.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ export class BlaQGaragePreCloseWarningAccessory extends BaseBlaQAccessory {

constructor(args: BaseBlaQAccessoryConstructorParams) {
super(args);
this.logger.debug('Initializing BlaQGaragePreCloseWarningAccessory...');
this.outletService = this.getOrAddService(this.platform.service.Outlet);

// Set the service name. This is what is displayed as the name on the Home
Expand All @@ -30,7 +29,7 @@ export class BlaQGaragePreCloseWarningAccessory extends BaseBlaQAccessory {
this.outletService.getCharacteristic(this.platform.characteristic.On)
.onGet(this.getIsOn.bind(this))
.onSet(this.changeIsOn.bind(this));
this.logger.debug('Initialized BlaQGaragePreCloseWarningAccessory!');
this.logger.debug(`Initialized ${this.getSelfClassName()}!`);
}

getIsOn(): CharacteristicValue {
Expand Down

0 comments on commit 526447c

Please sign in to comment.