Skip to content

Commit

Permalink
lint
Browse files Browse the repository at this point in the history
  • Loading branch information
apexskier committed Nov 15, 2023
1 parent d8fd77b commit e384fce
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 26 deletions.
26 changes: 13 additions & 13 deletions src/platform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export class EeroPresenceHomebridgePlatform implements DynamicPlatformPlugin {
constructor(
public readonly log: Logger,
public readonly config: PlatformConfig,
public readonly api: API
public readonly api: API,
) {
this.log.debug("Finished initializing platform:", this.config);

Expand Down Expand Up @@ -100,14 +100,14 @@ export class EeroPresenceHomebridgePlatform implements DynamicPlatformPlugin {
// see if an accessory with the same uuid has already been registered and restored from
// the cached devices we stored in the `configureAccessory` method above
const existingAccessory = this.accessories.find(
(accessory) => accessory.UUID === uuid
(accessory) => accessory.UUID === uuid,
);
if (existingAccessory) {
// the accessory already exists
this.log.info(
"Restoring existing accessory from cache:",
existingAccessory.displayName,
eero.serial
eero.serial,
);

new EeroPresensePlatformAccessory(this, existingAccessory);
Expand All @@ -117,7 +117,7 @@ export class EeroPresenceHomebridgePlatform implements DynamicPlatformPlugin {
// create a new accessory
const accessory = new this.api.platformAccessory(
eero.location,
uuid
uuid,
) as PlatformAccessory<AccessoryContext>;
accessory.context.eero = eero;
accessory.context.config = config;
Expand Down Expand Up @@ -162,22 +162,22 @@ export class EeroPresenceHomebridgePlatform implements DynamicPlatformPlugin {
(device) =>
(device.device_type === "watch" || device.device_type === "phone") &&
device.connection_type === "wireless" &&
device.connected
device.connected,
)
.filter(({ connectivity: { score } }) => score > 0.7);
const connectedEeros = new Set(
connectedDevices.map(({ source: { serial_number } }) =>
this.api.hap.uuid.generate(serial_number)
)
this.api.hap.uuid.generate(serial_number),
),
);
this.log.info(
"connected devices:",
connectedDevices
.map(
({ display_name, source: { location } }) =>
`${location}: ${display_name}`
`${location}: ${display_name}`,
)
.join(", ")
.join(", "),
);
this.accessories.forEach((accessory) => {
accessory
Expand All @@ -186,7 +186,7 @@ export class EeroPresenceHomebridgePlatform implements DynamicPlatformPlugin {
this.Characteristic.OccupancyDetected,
connectedEeros.has(accessory.UUID)
? this.Characteristic.OccupancyDetected.OCCUPANCY_DETECTED
: this.Characteristic.OccupancyDetected.OCCUPANCY_NOT_DETECTED
: this.Characteristic.OccupancyDetected.OCCUPANCY_NOT_DETECTED,
);
});
}
Expand All @@ -203,19 +203,19 @@ export class EeroPresenceHomebridgePlatform implements DynamicPlatformPlugin {

if (!response.ok) {
throw new this.api.hap.HapStatusError(
this.api.hap.HAPStatus.SERVICE_COMMUNICATION_FAILURE
this.api.hap.HAPStatus.SERVICE_COMMUNICATION_FAILURE,
);
}

if (response.status === 401) {
throw new this.api.hap.HapStatusError(
this.api.hap.HAPStatus.INSUFFICIENT_AUTHORIZATION
this.api.hap.HAPStatus.INSUFFICIENT_AUTHORIZATION,
);
}

if (response.status !== 200) {
throw new this.api.hap.HapStatusError(
this.api.hap.HAPStatus.SERVICE_COMMUNICATION_FAILURE
this.api.hap.HAPStatus.SERVICE_COMMUNICATION_FAILURE,
);
}

Expand Down
26 changes: 13 additions & 13 deletions src/platformAccessory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,19 @@ export class EeroPresensePlatformAccessory {

constructor(
private readonly platform: EeroPresenceHomebridgePlatform,
private readonly accessory: PlatformAccessory<AccessoryContext>
private readonly accessory: PlatformAccessory<AccessoryContext>,
) {
// set accessory information
const accessoryCharacteristics = this.accessory
.getService(this.platform.Service.AccessoryInformation)!
.setCharacteristic(this.platform.Characteristic.Manufacturer, "Eero")
.setCharacteristic(
this.platform.Characteristic.Model,
this.accessory.context.eero.model
this.accessory.context.eero.model,
);
accessoryCharacteristics.setCharacteristic(
this.platform.Characteristic.SerialNumber,
this.accessory.context.eero.serial
this.accessory.context.eero.serial,
);

this.sensorService =
Expand All @@ -57,7 +57,7 @@ export class EeroPresensePlatformAccessory {
data: { led_on },
} = await (
await this.fetch(
`https://api-user.e2ro.com/${this.accessory.context.eero.url}`
`https://api-user.e2ro.com/${this.accessory.context.eero.url}`,
)
).json();

Expand All @@ -67,7 +67,7 @@ export class EeroPresensePlatformAccessory {
this.platform.log.debug(
"setting on",
value,
this.accessory.displayName
this.accessory.displayName,
);
await this.fetch(
`https://api-user.e2ro.com${this.accessory.context.eero.resources.led_action}`,
Expand All @@ -76,7 +76,7 @@ export class EeroPresensePlatformAccessory {
body: JSON.stringify({
led_on: value,
}),
}
},
);
});

Expand All @@ -85,13 +85,13 @@ export class EeroPresensePlatformAccessory {
.onGet(async () => {
this.platform.log.debug(
"getting brightness",
this.accessory.displayName
this.accessory.displayName,
);
const {
data: { led_brightness },
} = await (
await this.fetch(
`https://api-user.e2ro.com/${this.accessory.context.eero.url}`
`https://api-user.e2ro.com/${this.accessory.context.eero.url}`,
)
).json();

Expand All @@ -101,7 +101,7 @@ export class EeroPresensePlatformAccessory {
this.platform.log.debug(
"setting brightness",
value,
this.accessory.displayName
this.accessory.displayName,
);
await this.fetch(
`https://api-user.e2ro.com${this.accessory.context.eero.resources.led_action}`,
Expand All @@ -111,7 +111,7 @@ export class EeroPresensePlatformAccessory {
led_on: !!value,
led_brightness: value,
}),
}
},
);
});
}
Expand All @@ -128,19 +128,19 @@ export class EeroPresensePlatformAccessory {

if (!response.ok) {
throw new this.platform.api.hap.HapStatusError(
this.platform.api.hap.HAPStatus.SERVICE_COMMUNICATION_FAILURE
this.platform.api.hap.HAPStatus.SERVICE_COMMUNICATION_FAILURE,
);
}

if (response.status === 401) {
throw new this.platform.api.hap.HapStatusError(
this.platform.api.hap.HAPStatus.INSUFFICIENT_AUTHORIZATION
this.platform.api.hap.HAPStatus.INSUFFICIENT_AUTHORIZATION,
);
}

if (response.status !== 200) {
throw new this.platform.api.hap.HapStatusError(
this.platform.api.hap.HAPStatus.SERVICE_COMMUNICATION_FAILURE
this.platform.api.hap.HAPStatus.SERVICE_COMMUNICATION_FAILURE,
);
}

Expand Down

0 comments on commit e384fce

Please sign in to comment.