Skip to content

Commit

Permalink
monitor by service
Browse files Browse the repository at this point in the history
  • Loading branch information
NorthernMan54 committed Nov 6, 2024
1 parent cde7180 commit 2655285
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ export class HapClient extends EventEmitter {
this.instances[existingInstanceIndex].port = instance.port
this.instances[existingInstanceIndex].name = instance.name
this.debug(`[HapClient] Discovery :: [${this.instances[existingInstanceIndex].ipAddress}:${instance.port} `
+ `(${instance.username})] Instance Updated`)
+ `(${instance.username})] Instance Updated`)

Check failure on line 152 in src/index.ts

View workflow job for this annotation

GitHub Actions / lint / ESLint

Expected indentation of 10 spaces
this.emit('instance-discovered', instance)
}

Expand Down Expand Up @@ -241,9 +241,10 @@ export class HapClient extends EventEmitter {
return accessories
}

public async monitorCharacteristics() {
const services = await this.getAllServices()
return new HapMonitor(this.logger, this.debug.bind(this), this.pin, services)
public async monitorCharacteristics(services?: ServiceType[]) {
// If `services` is not provided, retrieve all services
services = services ?? await this.getAllServices();

Check failure on line 246 in src/index.ts

View workflow job for this annotation

GitHub Actions / lint / ESLint

Extra semicolon
return new HapMonitor(this.logger, this.debug.bind(this), this.pin, services);

Check failure on line 247 in src/index.ts

View workflow job for this annotation

GitHub Actions / lint / ESLint

Extra semicolon
}

public async getAllServices() {
Expand Down Expand Up @@ -451,10 +452,10 @@ export class HapClient extends EventEmitter {
} catch (e: any) {
if (this.logger) {
this.logger.error(`[HapClient] [${service.instance.ipAddress}:${service.instance.port} (${service.instance.username})] `
+ `Failed to set value for ${service.serviceName}.`)
+ `Failed to set value for ${service.serviceName}.`)

Check failure on line 455 in src/index.ts

View workflow job for this annotation

GitHub Actions / lint / ESLint

Expected indentation of 8 spaces
if ([401, 470].includes(e.response?.status)) {
this.logger.warn(`[HapClient] [${service.instance.ipAddress}:${service.instance.port} (${service.instance.username})] `
+ `Make sure Homebridge pin for this instance is set to ${this.pin}.`)
+ `Make sure Homebridge pin for this instance is set to ${this.pin}.`)

Check failure on line 458 in src/index.ts

View workflow job for this annotation

GitHub Actions / lint / ESLint

Expected indentation of 10 spaces
throw new Error(`Failed to control accessory. Make sure the Homebridge pin for ${service.instance.ipAddress}:${service.instance.port} `
+ `is set to ${this.pin}.`)
} else {
Expand Down

0 comments on commit 2655285

Please sign in to comment.