Skip to content

Commit

Permalink
0.9.51 - regress part of AQI code to make things work
Browse files Browse the repository at this point in the history
  • Loading branch information
BKeyport committed Oct 1, 2023
1 parent f8c5015 commit f1f9bab
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 19 deletions.
42 changes: 24 additions & 18 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ function davis(log, config) {
this.pollingIntervalSeconds = parseInt(config["pollingIntervalSeconds"] || 300);
this.temperatureUnitOfMeasure = (config["temperatureUnitOfMeasure"] || "C").toUpperCase();
this._timeoutID = -1;
this._cachedData = { "temperature": 0, "humidity": 0, "pm2p5:": 0, "pm10": 0};
this._cachedData = { "temperature": 0, "humidity": 0, "PM2p5:": 0, "PM10": 0};
this.serial = config["serial"] || "NotSetByUser";
this.getData(this.url);
this.txid = config["txid"] || 1;
Expand All @@ -29,8 +29,8 @@ function davis(log, config) {
this.temperature = 0;
this.humidity = 0;
//Specific to Airlink
this.pm2p5 = 0;
this.pm10 = 0;
this.PM2p5 = 0;
this.PM10 = 0;

}

Expand Down Expand Up @@ -80,11 +80,11 @@ davis.prototype = {
},

getPM2p5: function (callback) {
callback(null, this._cachedData.pm2p5);
callback(null, this._cachedData.PM2p5);
},

getPM10: function (callback) {
callback(null, this._cachedData.pm10);
callback(null, this._cachedData.PM10);
},

getServices: function () {
Expand Down Expand Up @@ -112,15 +112,21 @@ davis.prototype = {

if (this.sensorType == 3) {
this.airQualityService = new Service.AirQualitySensor(this.name);

this.airQualityService
.getCharacteristic(Characteristic.AirQuality)
.on("get", this.getAirQuality.bind(this));
this.airQualityService

/* this.airQualityService
.getCharacteristic(Characteristic.PM2p5Density)
.on("get", this.getPM2p5.bind(this));
.on("get", this.getPM2p5.bind(this));
*/

this.airQualityService
.getCharacteristic(Characteristic.PM10Density)
.on("get", this.getPM10.bind(this));


services.push(this.airQualityService);
}

Expand Down Expand Up @@ -195,43 +201,43 @@ davis.prototype = {
if (this.sensorType == 3) {
this.temperature = weather[i].temp;
this.humidity = weather[i].hum;
this.pm10 = weather[i].pm_10p0;
this.pm2p5 = weather[i].pm_2p5;
this.PM10 = weather[i].pm_10p0;
this.PM2p5 = weather[i].pm_2p5;
}
break;

case 6:
if (this.sensorType == 3) {
this.temperature = weather[i].temp;
this.humidity = weather[i].hum;
this.pm10 = weather[i].pm_10;
this.pm2p5 = weather[i].pm_2p5;
this.log.debug("%s %s %s %s", this.temperature, this.humidity, this.pm10, this.pm2p5);
this.PM10 = weather[i].pm_10;
this.PM2p5 = weather[i].pm_2p5;
this.log.debug("%s %s %s %s", this.temperature, this.humidity, this.PM10, this.PM2p5);
}
break;

default:
break;
}
}
this.log.debug("%s %s %s %s", this.temperature, this.humidity, this.pm10, this.pm2p5);
this.log.debug("%s %s %s %s", this.temperature, this.humidity, this.PM10, this.PM2p5);

if (this.sensorType == 3) {
this._cachedData = {
"temperature": this.temperatureUnitOfMeasure == "F" ? this.convertFromFahrenheitToCelsius(this.temperature) : this.temperature,
"humidity": Math.round(this.humidity),
"pm2p5": this.pm2p5,
"pm10": this.pm10,
"airQuality": computeAqiFromPm(this.pm2p5, this.pm10),
"PM2p5": this.PM2p5,
"PM10": this.PM10,
"airQuality": computeAqiFromPm(this.PM2p5, this.PM10),
}
} else {
this._cachedData = {
"temperature": this.temperatureUnitOfMeasure == "F" ? this.convertFromFahrenheitToCelsius(this.temperature) : this.temperature,
"humidity": Math.round(this.humidity),
}
};
this.log.debug("%s %s %s %s", this.temperature, this.humidity, this.pm2p5, this.pm10);
this.log.debug("%s %s %s %s", this._cachedData.temperature, this._cachedData.humidity, this.pm2p5, this.pm10);
this.log.debug("%s %s %s %s", this.temperature, this.humidity, this.PM2p5, this.PM10);
this.log.debug("%s %s %s %s", this._cachedData.temperature, this._cachedData.humidity, this.PM2p5, this.PM10);
queue();
}.bind(this));
},
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "homebridge-davis",
"version": "0.9.50",
"version": "0.9.51",
"description": "Homebridge plugin that allows you to integrate your Davis WeatherLink Live station API.",
"main": "index.js",
"homepage": "https://github.com/BKeyport/homebridge-davis",
Expand Down

0 comments on commit f1f9bab

Please sign in to comment.