diff --git a/config.schema.json b/config.schema.json index 09ef00e..35da78f 100644 --- a/config.schema.json +++ b/config.schema.json @@ -43,7 +43,7 @@ "description": "Minimum signal strength (0 - 1) to be considered present.", "minimum": 0, "maximum": 1, - "default": 0.7, + "default": 0.25, "required": false }, "pollTime": { diff --git a/package.json b/package.json index 9c1ae4b..d10b325 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "displayName": "Eero Presence", "name": "@apexskier/homebridge-eero-presence", - "version": "1.0.1", + "version": "1.1.0", "description": "Use your Eero mesh as an occupancy sensor", "license": "Apache-2.0", "repository": { diff --git a/src/platform.ts b/src/platform.ts index 0025eb1..2004115 100644 --- a/src/platform.ts +++ b/src/platform.ts @@ -196,14 +196,22 @@ export class EeroPresenceHomebridgePlatform implements DynamicPlatformPlugin { } async fetch(input: RequestInfo | URL, init?: RequestInit) { - const response = await fetch(input, { - ...init, - headers: { - ...init?.headers, - "content-type": "application/json", - cookie: `s=${this.config.userToken}`, - }, - }); + let response; + try { + response = await fetch(input, { + ...init, + headers: { + ...init?.headers, + "content-type": "application/json", + cookie: `s=${this.config.userToken}`, + }, + }); + } catch (error) { + this.log.error("failed to fetch"); + throw new this.api.hap.HapStatusError( + this.api.hap.HAPStatus.SERVICE_COMMUNICATION_FAILURE, + ); + } if (!response.ok) { throw new this.api.hap.HapStatusError( diff --git a/src/platformAccessory.ts b/src/platformAccessory.ts index d973f6e..b15fda2 100644 --- a/src/platformAccessory.ts +++ b/src/platformAccessory.ts @@ -136,14 +136,22 @@ export class EeroPresensePlatformAccessory { } async fetch(input: RequestInfo | URL, init?: RequestInit) { - const response = await fetch(input, { - ...init, - headers: { - ...init?.headers, - "content-type": "application/json", - cookie: `s=${this.accessory.context.config.userToken}`, - }, - }); + let response; + try { + response = await fetch(input, { + ...init, + headers: { + ...init?.headers, + "content-type": "application/json", + cookie: `s=${this.accessory.context.config.userToken}`, + }, + }); + } catch (error) { + this.platform.log.error("failed to fetch"); + throw new this.platform.api.hap.HapStatusError( + this.platform.api.hap.HAPStatus.SERVICE_COMMUNICATION_FAILURE, + ); + } if (!response.ok) { throw new this.platform.api.hap.HapStatusError(