Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

homebridge-air

Package Overview
Dependencies
Maintainers
0
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

homebridge-air - npm Package Compare versions

Comparing version 1.0.0-beta.8 to 1.0.0-beta.9

19

dist/devices/airqualitysensor.js
import { interval } from 'rxjs';
import { skipWhile } from 'rxjs/operators';
import striptags from 'striptags';
import { request } from 'undici';
// import { request } from 'undici'
import { AirNowUrl, AqicnUrl, HomeKitAQI } from '../settings.js';

@@ -117,8 +117,9 @@ import { deviceBase } from './device.js';

try {
const { body, statusCode } = await request(url);
let response;
const response = await fetch(url);
const statusCode = response.status;
let responseBody;
let rawBody = '';
try {
rawBody = await body.text(); // Read the raw response body as text
response = JSON.parse(rawBody); // Parse the raw response body as JSON
rawBody = await response.text(); // Read the raw response body as text
responseBody = JSON.parse(rawBody); // Parse the raw response body as JSON
}

@@ -131,11 +132,11 @@ catch (jsonError) {

await this.debugWarnLog(`statusCode: ${JSON.stringify(statusCode)}`);
await this.debugLog(`response: ${JSON.stringify(response)}`);
await this.debugLog(`response: ${JSON.stringify(responseBody)}`);
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);
await this.debugLog(`Error: ${JSON.stringify(responseBody)}`);
await this.apiError(responseBody);
}
else {
this.deviceStatus = this.device.provider === 'aqicn' ? response.data : response;
this.deviceStatus = this.device.provider === 'aqicn' ? responseBody.data : responseBody;
await this.parseStatus();

@@ -142,0 +143,0 @@ }

@@ -98,5 +98,14 @@ import { readFileSync } from 'node:fs';

}
if (!deviceConfig.zipCode) {
await this.errorLog('Missing your Zip Code');
if (deviceConfig.zipCode || deviceConfig.city) {
if (!deviceConfig.zipCode || !deviceConfig.city) {
const missing = !deviceConfig.zipCode ? 'Zip Code' : 'City';
await this.errorLog(`Missing your ${missing}`);
}
}
if (deviceConfig.latitude || deviceConfig.longitude) {
if (!deviceConfig.latitude || !deviceConfig.longitude) {
const missing = !deviceConfig.latitude ? 'Latitude' : 'Longitude';
await this.errorLog(`Missing your ${missing}`);
}
}
}

@@ -114,6 +123,10 @@ }

try {
for (const device of this.config.devices) {
device.city = device.city ?? 'Unknown';
device.zipCode = device.zipCode ?? '00000' ?? await this.infoLog(`Discovered ${device.city}`);
this.createAirQualitySensor(device);
if (this.config.devices) {
for (const device of this.config.devices) {
device.city = device.city ?? 'Unknown';
device.zipCode = device.zipCode ?? '00000';
device.provider = device.provider ?? 'Unknown';
await this.infoLog(`Discovered ${device.city}`);
this.createAirQualitySensor(device);
}
}

@@ -127,3 +140,3 @@ }

// generate a unique id for the accessory
const uuidString = (device.latitude && device.longitude) ? (device.latitude + device.longitude + device.apiKey) : (device.zipCode + device.apiKey);
const uuidString = (device.latitude && device.longitude) ? (device.latitude + device.longitude) : (device.zipCode + device.city);
const uuid = this.api.hap.uuid.generate(uuidString);

@@ -154,3 +167,3 @@ // see if an accessory with the same uuid has already been registered and restored from

}
else if (!device.delete) {
else if (!device.delete && !existingAccessory) {
// create a new accessory

@@ -157,0 +170,0 @@ const accessory = new this.api.platformAccessory(device.city, uuid);

@@ -5,3 +5,3 @@ {

"type": "module",
"version": "1.0.0-beta.8",
"version": "1.0.0-beta.9",
"description": "The AirNow plugin allows you to monitor the current AirQuality for your Zip Code from HomeKit and Siri.",

@@ -25,3 +25,3 @@ "author": {

"type": "git",
"url": "https://github.com/donavanbecker/homebridge-air.git"
"url": "git+https://github.com/donavanbecker/homebridge-air.git"
},

@@ -62,3 +62,2 @@ "bugs": {

"dependencies": {
"@apiverve/zipcodes": "^1.1.4",
"@homebridge/plugin-ui-utils": "^1.0.3",

@@ -70,3 +69,3 @@ "rxjs": "^7.8.1",

"devDependencies": {
"@antfu/eslint-config": "^3.6.2",
"@antfu/eslint-config": "^3.7.1",
"@types/aes-js": "^3.1.4",

@@ -81,3 +80,3 @@ "@types/debug": "^4.1.12",

"@vitest/coverage-v8": "^2.1.1",
"eslint": "^9.10.0",
"eslint": "^9.11.0",
"eslint-plugin-format": "^0.1.2",

@@ -87,4 +86,4 @@ "homebridge": "^1.8.4",

"jest": "^29.7.0",
"nodemon": "^3.1.4",
"npm-check-updates": "^17.1.1",
"nodemon": "^3.1.7",
"npm-check-updates": "^17.1.3",
"shx": "^0.3.4",

@@ -91,0 +90,0 @@ "ts-node": "^10.9.2",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc