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.11.0 to 1.12.0

55

index.js

@@ -108,2 +108,10 @@ "use strict";

if (this.type === "windspeed") {
this.getStateSun(function (error, value) {
if (!error && value != null) {
humidityService.setCharacteristic(Characteristic.CurrentRelativeHumidity, value);
}
}.bind(this));
}
var that = this;

@@ -244,2 +252,33 @@ setTimeout(function () {

getStateWindspeed: function (callback) {
// Only fetch new data once per minute
if (!this.cachedWeatherObj || this.pollingInterval > 0 || this.lastupdate + 60 < (new Date().getTime() / 1000 | 0)) {
var url = this.makeURL();
this.httpRequest(url, function (error, response, responseBody) {
if (error) {
this.log("HTTP get weather function failed: %s", error.message);
callback(error);
} else {
try {
this.setCacheObj(responseBody);
var value = this.returnWindspeedFromCache();
callback(null, value);
} catch (error2) {
this.log("Getting Windspeed failed: %s", error2, response, responseBody);
callback(error2);
}
}
}.bind(this));
} else {
try {
var value = this.returnWindspeedFromCache();
this.log("Returning cached data", value);
callback(null, value);
} catch (error) {
this.log("Getting Windspeed failed: %s", error);
callback(error);
}
}
},
/**

@@ -343,2 +382,11 @@ * Handles the response from HTTP-API and caches the data

returnWindspeedFromCache: function () {
var value;
if (this.cachedWeatherObj && this.cachedWeatherObj["wind"]) {
value = parseFloat(this.cachedWeatherObj["wind"]["speed"]);
this.log("Fetched windspeed value " + value + "% of type '" + this.type + "' for accessory " + this.name);
}
return value;
},
makeURL: function () {

@@ -435,2 +483,9 @@ var url = "http://api.openweathermap.org/data/2.5/";

services[services.length] = humidityService;
} else if (this.type === "windspeed") {
humidityService = new Service.HumiditySensor(this.name);
humidityService
.getCharacteristic(Characteristic.CurrentRelativeHumidity)
.on("get", this.getStateWindspeed.bind(this));
services[services.length] = humidityService;
} else {

@@ -437,0 +492,0 @@ if (this.showTemperature) {

2

package.json
{
"name": "homebridge-weather",
"version": "1.11.0",
"version": "1.12.0",
"description": "Homebridge plugin for displaying the weather from openweathermap.org",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -108,2 +108,24 @@ # homebridge-weather

## Wind-speed
To show wind-speed in `meter/sec` configure as follows:
```json
"accessories": [
{
"accessory":"Weather",
"apikey":"YOUR_KEY_HERE",
"locationByCoordinates":"lat=48.70798341&lon=9.17019367",
"name":"Wind",
"type":"windspeed"
}
]
```
To display in `miles/hour` additionally configure
```json
"unit": "imperial"
```
## Sunrise/noon/sunset

@@ -184,3 +206,3 @@

* `showTemperature` weather or not show the temperature (optional, setting to false only makes sense if `showHumidity` os set to true, defaults to true).
* `type` the type of the displayed value, either `min`, `max`, `current`, `clouds` or `sun` (optional, defaults to `current`)
* `type` the type of the displayed value, either `min`, `max`, `current`, `clouds`, `sun` or `windspeed` (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)

@@ -187,0 +209,0 @@ * `enableHistory` flag for enabling the FakeGato-service (see above) for temperature and humidity logging (optional, defaults to false, only works when polling is enabled)

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