homebridge-air
Advanced tools
Comparing version 1.0.0-beta.5 to 1.0.0-beta.6
@@ -116,15 +116,28 @@ import { interval } from 'rxjs'; | ||
if (url) { | ||
const { body, statusCode } = await request(url); | ||
const response = await body.json(); | ||
await this.debugWarnLog(`statusCode: ${JSON.stringify(statusCode)}`); | ||
await this.debugLog(`response: ${JSON.stringify(response)}`); | ||
if (statusCode !== 200) { | ||
this.errorLog(`${this.device.provider === 'airnow' ? 'AirNow' : 'World Air Quality Index'} air quality Network or Unknown Error from %s.`, this.device.provider); | ||
this.AirQualitySensor.StatusFault = this.hap.Characteristic.StatusFault.GENERAL_FAULT; | ||
await this.debugLog(`Error: ${JSON.stringify(response)}`); | ||
await this.apiError(response); | ||
try { | ||
const { body, statusCode } = await request(url); | ||
let response; | ||
try { | ||
response = await body.json(); | ||
} | ||
catch (jsonError) { | ||
this.errorLog(`Failed to parse JSON response: ${jsonError.message}`); | ||
this.errorLog(`Raw response body: ${await body.text()}`); | ||
throw jsonError; | ||
} | ||
await this.debugWarnLog(`statusCode: ${JSON.stringify(statusCode)}`); | ||
await this.debugLog(`response: ${JSON.stringify(response)}`); | ||
if (statusCode !== 200) { | ||
this.errorLog(`${this.device.provider === 'airnow' ? 'AirNow' : 'World Air Quality Index'} air quality Network or Unknown Error from %s.`, this.device.provider); | ||
this.AirQualitySensor.StatusFault = this.hap.Characteristic.StatusFault.GENERAL_FAULT; | ||
await this.debugLog(`Error: ${JSON.stringify(response)}`); | ||
await this.apiError(response); | ||
} | ||
else { | ||
this.deviceStatus = this.device.provider === 'aqicn' ? response.data : response; | ||
await this.parseStatus(); | ||
} | ||
} | ||
else { | ||
this.deviceStatus = this.device.provider === 'aqicn' ? response.data : response; | ||
await this.parseStatus(); | ||
catch (error) { | ||
this.errorLog(`Request failed: ${error.message}`); | ||
} | ||
@@ -131,0 +144,0 @@ } |
@@ -5,3 +5,3 @@ { | ||
"type": "module", | ||
"version": "1.0.0-beta.5", | ||
"version": "1.0.0-beta.6", | ||
"description": "The AirNow plugin allows you to monitor the current AirQuality for your Zip Code from HomeKit and Siri.", | ||
@@ -8,0 +8,0 @@ "author": { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
332066
3017