Socket
Socket
Sign inDemoInstall

homebridge-airvisual-2

Package Overview
Dependencies
9
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 2.0.0 to 2.1.0

52

index.js

@@ -34,3 +34,3 @@ /* eslint-disable object-curly-newline */

this.ppb = config.ppb_units;
this.interval = (config.interval || 60) * 60 * 1000;
this.interval = (config.interval || 30) * 60 * 1000;

@@ -241,13 +241,13 @@ if (!this.key) {

} else {
const pm10 = this.inferPM10(conditions.aqi);
if (pm10) {
conditions.pm10 = pm10;
this.log('Inferred PM10 density is: %sµg/m3', conditions.pm10);
this.sensorService
.getCharacteristic(Characteristic.PM10Density)
.setValue(conditions.pm10);
} else {
this.sensorService
.removeCharacteristic(Characteristic.PM10Density);
}
// const pm10 = this.inferPM10(conditions.aqi);
// if (pm10) {
// conditions.pm10 = pm10;
// this.log('Inferred PM10 density is: %sµg/m3', conditions.pm10);
// this.sensorService
// .getCharacteristic(Characteristic.PM10Density)
// .setValue(conditions.pm10);
// } else {
this.sensorService
.removeCharacteristic(Characteristic.PM10Density);
// }
}

@@ -400,16 +400,16 @@

inferPM10(aqi) { // μg/m3
if (!aqi) return null;
const table = [
[ 0, 50, 0, 55],
[ 50, 100, 55, 155],
[100, 150, 155, 255],
[150, 200, 255, 355],
[200, 300, 355, 425],
[300, 400, 425, 505],
[400, 500, 505, 605],
];
const [aqiLow, aqiHigh, pmLow, pmHigh] = table.find(([l, h]) => aqi >= l && aqi < h);
return pmLow + (((aqi - aqiLow) * (pmHigh - pmLow)) / (aqiHigh - aqiLow));
}
// inferPM10(aqi) { // μg/m3
// if (!aqi) return null;
// const table = [
// [ 0, 50, 0, 55],
// [ 50, 100, 55, 155],
// [100, 150, 155, 255],
// [150, 200, 255, 355],
// [200, 300, 355, 425],
// [300, 400, 425, 505],
// [400, 500, 505, 605],
// ];
// const [aqiLow, aqiHigh, pmLow, pmHigh] = table.find(([l, h]) => aqi >= l && aqi < h);
// return pmLow + (((aqi - aqiLow) * (pmHigh - pmLow)) / (aqiHigh - aqiLow));
// }

@@ -416,0 +416,0 @@ convertMilligramToPPM(pollutant, milligram, temperature, pressure) {

{
"name": "homebridge-airvisual-2",
"version": "2.0.0",
"version": "2.1.0",
"description": "Homebridge plugin for AirVisual API",

@@ -24,3 +24,3 @@ "main": "index.js",

"engines": {
"node": ">=11",
"node": ">=10.18",
"homebridge": ">=0.2.0"

@@ -27,0 +27,0 @@ },

@@ -1,5 +0,11 @@

# homebridge-airvisual
# homebridge-airvisual-2
Homebridge plugin for the AirVisual API which allows access to outdoor air quality, humidity, and temperature.
It differs from `homebridge-airvisual` in the following ways:
* Data is fetched and stored on a fixed interval instead of making HTTP requests on demand.
* Added logic to infer PM2.5 density based on AQI (free API plan only)
* Updated to modern ES syntax (requires node 10.18 or newer)
## Installation

@@ -30,3 +36,3 @@

"ppb_units": ["no2", "o3", "so2"],
"interval": 60,
"interval": 30,
}

@@ -89,5 +95,6 @@ ],

* The free tier of the API does not provide particle densities, however this plugin will infer the PM2.5 and PM10 densities based on the AQI according to [this table](https://en.wikipedia.org/wiki/Air_quality_index#Computing_the_AQI).
* The free tier of the API does not provide particle densities, however this plugin will infer the PM2.5 density based on the AQI according to [this table](https://en.wikipedia.org/wiki/Air_quality_index#Computing_the_AQI).
Note that according to API documentation, a city's AQI is based on the "main pollutant" which may or may not be PM2.5. Upgrade your API plan to get correct pollutant data.
* By default the API is queried once per hour. A 10 minute interval would result in ~5000 requests per month, while the free tier includes 10.000 requests per month.
* By default the API is queried once every 30 minutes, which is half of AirVisual's station update frequency of once per hour.

@@ -94,0 +101,0 @@ * AQI categories are mapped to HomeKit categories as follows. Note that HomeKit will show visual cues on the dashboard for categories "Inferior" and "Poor".

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc