New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

homebridge-weather

Package Overview
Dependencies
Maintainers
1
Versions
41
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

homebridge-weather - npm Package Compare versions

Comparing version 1.3.6 to 1.4.0

3

config.example.json

@@ -14,3 +14,4 @@ {

"locationByCoordinates": "lat=48.70798341&lon=9.17019367",
"name":"Current"
"name":"Current",
"pollingInterval":"10"
},

@@ -17,0 +18,0 @@ {

@@ -27,2 +27,7 @@ "use strict";

}
if (config["pollingInterval"] != null) {
this.pollingInterval = parseInt(config["pollingInterval"]) * 1000 * 60;
} else {
this.pollingInterval = 0;
}

@@ -32,2 +37,10 @@ this.type = config["type"] || "current";

this.lastupdate = 0;
// start periodical polling in background with setTimeout
if (this.pollingInterval > 0) {
var that = this;
setTimeout(function () {
that.backgroundPolling();
}, this.pollingInterval);
}
}

@@ -37,5 +50,24 @@

{
backgroundPolling: function () {
this.log.info("Polling data in background");
this.getStateTemp(function (error, temperature) {
if (!error && temperature != null) {
temperatureService.setCharacteristic(Characteristic.CurrentTemperature, temperature);
}
}.bind(this));
this.getStateHum(function (error, humidity) {
if (!error && humidity != null) {
humidityService.setCharacteristic(Characteristic.CurrentRelativeHumidity, humidity);
}
}.bind(this));
var that = this;
setTimeout(function () {
that.backgroundPolling();
}, this.pollingInterval);
},
getStateTemp: function (callback) {
// Only fetch new data once per 30 mins
if (this.lastupdate + (60 * 30) < (Date.now() / 1000 | 0)) {
if (this.lastupdate + (60 * 30) < (Date.now() / 1000 | 0) || this.pollingInterval > 0) {
var url = this.makeURL();

@@ -56,3 +88,2 @@ this.httpRequest(url, function (error, response, responseBody) {

this.log("Returning cached data", temperature);
// temperatureService.setCharacteristic(Characteristic.CurrentTemperature, temperature);
callback(null, temperature);

@@ -64,3 +95,3 @@ }

// Only fetch new data once per 30 mins
if (this.lastupdate + (60 * 30) < (Date.now() / 1000 | 0)) {
if (this.lastupdate + (60 * 30) < (Date.now() / 1000 | 0) || this.pollingInterval > 0) {
var url = this.makeURL();

@@ -67,0 +98,0 @@ this.httpRequest(url, function (error, response, responseBody) {

{
"name": "homebridge-weather",
"version": "1.3.6",
"version": "1.4.0",
"description": "A homebridge temperature sensor for displaying the weather at your current location.",

@@ -29,4 +29,4 @@ "main": "index.js",

"dependencies": {
"request": "^2.65.0"
"request": "^2.83.0"
}
}

@@ -73,6 +73,18 @@ # homebridge-weather

**You can add multiple accessories if you want to display additional information like min/max or the temperature of different locations. Just make sure that the field `name` is unique**
## Polling
By default, no polling-interval is specified. That means, the temperature is only updated when the Home-App is opened.
There might be scenarios though, where you would want to periodically update the temperature e.g. as source for trigger-rules.
OpenWeatherMap has a generous amount of [free calls](http://openweathermap.org/price#weather) per API-key: you can poll the temperature up to 60 times a minute.
Beware that **just because you can doesn't mean you should**
I'd also suggest that you add a polling-interval only for the `type` *current*, since *min* and *max* are forecasts and probably won't change throughout the day.
## Config file
Take a look at the <a href="config.example.json">example config.json</a>

@@ -91,2 +103,3 @@

* `showHumidity` weather or not show the humidity (optional, only works for current weather not forecast).
* `type` the type of the displayed value, either "min", "max" or "current" (optional, defaults to "current")
* `type` the type of the displayed value, either "min", "max" or "current" (optional, defaults to "current")
* `pollingInterval` the time (in minutes) for periodically updating the temperature (optional, defaults to 0 which means polling only happens when opening the Home-App)
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