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.11 to 1.0.0-beta.12

91

dist/devices/airqualitysensor.js

@@ -56,46 +56,53 @@ import { interval } from 'rxjs';

async parseStatus() {
const provider = this.device.provider;
const status = this.deviceStatus[0];
if (provider === 'airnow' && !status) {
this.errorLog('AirNow air quality Configuration Error - Invalid ZipCode for %s.', provider);
this.AirQualitySensor.StatusFault = this.hap.Characteristic.StatusFault.GENERAL_FAULT;
}
else if (provider === 'airnow' && typeof status.AQI === 'undefined') {
this.errorLog('AirNow air quality Observation Error - %s for %s.', striptags(JSON.stringify(this.deviceStatus)), provider);
this.AirQualitySensor.StatusFault = this.hap.Characteristic.StatusFault.GENERAL_FAULT;
}
else if (provider === 'airnow' || provider === 'aqicn') {
const pollutants = provider === 'airnow' ? ['O3', 'PM2.5', 'PM10'] : ['o3', 'no2', 'so2', 'pm25', 'pm10', 'co'];
pollutants.forEach((pollutant) => {
const param = provider === 'airnow' ? this.deviceStatus.find((p) => p.ParameterName === pollutant) : this.deviceStatus.iaqi[pollutant]?.v;
const aqi = provider === 'airnow' ? Number.parseFloat(param.AQI.toString()) : Number.parseFloat(param);
if (aqi !== undefined) {
switch (pollutant.toLowerCase()) {
case 'o3':
this.AirQualitySensor.OzoneDensity = aqi;
break;
case 'pm2.5':
this.AirQualitySensor.PM2_5Density = aqi;
break;
case 'pm10':
this.AirQualitySensor.PM10Density = aqi;
break;
case 'no2':
this.AirQualitySensor.NitrogenDioxideDensity = aqi;
break;
case 'so2':
this.AirQualitySensor.SulphurDioxideDensity = aqi;
break;
case 'co':
this.AirQualitySensor.CarbonMonoxideLevel = aqi;
break;
try {
const provider = this.device.provider;
const status = this.deviceStatus[0];
if (provider === 'airnow' && !status) {
this.errorLog('AirNow air quality Configuration Error - Invalid ZipCode for %s.', provider);
this.AirQualitySensor.StatusFault = this.hap.Characteristic.StatusFault.GENERAL_FAULT;
}
else if (provider === 'airnow' && typeof status.AQI === 'undefined') {
this.errorLog('AirNow air quality Observation Error - %s for %s.', striptags(JSON.stringify(this.deviceStatus)), provider);
this.AirQualitySensor.StatusFault = this.hap.Characteristic.StatusFault.GENERAL_FAULT;
}
else if (provider === 'airnow' || provider === 'aqicn') {
const pollutants = provider === 'airnow' ? ['O3', 'PM2.5', 'PM10'] : ['o3', 'no2', 'so2', 'pm25', 'pm10', 'co'];
pollutants.forEach((pollutant) => {
const param = provider === 'airnow' ? this.deviceStatus.find((p) => p.ParameterName === pollutant) : this.deviceStatus.iaqi[pollutant]?.v;
const aqi = provider === 'airnow' ? Number.parseFloat(param.AQI.toString()) : Number.parseFloat(param);
if (aqi !== undefined) {
switch (pollutant.toLowerCase()) {
case 'o3':
this.AirQualitySensor.OzoneDensity = aqi;
break;
case 'pm2.5':
this.AirQualitySensor.PM2_5Density = aqi;
break;
case 'pm10':
this.AirQualitySensor.PM10Density = aqi;
break;
case 'no2':
this.AirQualitySensor.NitrogenDioxideDensity = aqi;
break;
case 'so2':
this.AirQualitySensor.SulphurDioxideDensity = aqi;
break;
case 'co':
this.AirQualitySensor.CarbonMonoxideLevel = aqi;
break;
}
this.AirQualitySensor.AirQuality = HomeKitAQI(Math.max(0, aqi));
}
this.AirQualitySensor.AirQuality = HomeKitAQI(Math.max(0, aqi));
}
});
this.infoLog(`${provider} air quality AQI is: ${this.AirQualitySensor.AirQuality}`);
this.AirQualitySensor.StatusFault = this.hap.Characteristic.StatusFault.NO_FAULT;
});
this.infoLog(`${provider} air quality AQI is: ${this.AirQualitySensor.AirQuality}`);
this.AirQualitySensor.StatusFault = this.hap.Characteristic.StatusFault.NO_FAULT;
}
else {
await this.errorLog('Unknown air quality provider: %s.', provider);
}
}
else {
await this.errorLog('Unknown air quality provider: %s.', provider);
catch (e) {
await this.errorLog(`failed to parse status, Error Message: ${JSON.stringify(e.message)}`);
await this.debugLog(`Error: ${JSON.stringify(e)}`);
await this.apiError(e);
}

@@ -102,0 +109,0 @@ }

@@ -136,3 +136,3 @@ import { readFileSync } from 'node:fs';

}
await this.infoLog(`Discovered ${device.city}`);
await this.debugLog(`Discovered ${device.city}`);
this.createAirQualitySensor(device);

@@ -139,0 +139,0 @@ }

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

"type": "module",
"version": "1.0.0-beta.11",
"version": "1.0.0-beta.12",
"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

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