mirror of
https://github.com/MichMich/MagicMirror.git
synced 2025-06-28 20:22:53 +00:00
Merge pull request #1202 from iampranavsethi/currentweather-module-updates
Currentweather module updates
This commit is contained in:
commit
b0cd053083
@ -15,6 +15,8 @@ This project adheres to [Semantic Versioning](http://semver.org/).
|
|||||||
- Automated unit tests utils, deprecated, translator, cloneObject(lockstrings)
|
- Automated unit tests utils, deprecated, translator, cloneObject(lockstrings)
|
||||||
- Automated integration tests translations
|
- Automated integration tests translations
|
||||||
- Add advanced filtering to the excludedEvents configuration of the default calendar module
|
- Add advanced filtering to the excludedEvents configuration of the default calendar module
|
||||||
|
- New currentweather module config option: `showFeelsLike`: Shows how it actually feels like. (wind chill or heat index)
|
||||||
|
- New currentweather module config option: `useKMPHwind`: adds an option to see wind speed in Kmph instead of just m/s or Beaufort.
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
- Add link to GitHub repository which contains the respective Dockerfile.
|
- Add link to GitHub repository which contains the respective Dockerfile.
|
||||||
|
BIN
modules/default/.DS_Store
vendored
BIN
modules/default/.DS_Store
vendored
Binary file not shown.
@ -43,7 +43,9 @@ The following properties can be configured:
|
|||||||
| `showWindDirectionAsArrow` | Show the wind direction as an arrow instead of abbreviation <br><br> **Possible values:** `true` or `false` <br> **Default value:** `false`
|
| `showWindDirectionAsArrow` | Show the wind direction as an arrow instead of abbreviation <br><br> **Possible values:** `true` or `false` <br> **Default value:** `false`
|
||||||
| `showHumidity` | Show the current humidity <br><br> **Possible values:** `true` or `false` <br> **Default value:** `false`
|
| `showHumidity` | Show the current humidity <br><br> **Possible values:** `true` or `false` <br> **Default value:** `false`
|
||||||
| `showIndoorTemperature` | If you have another module that emits the INDOOR_TEMPERATURE notification, the indoor temperature will be displayed <br> **Default value:** `false`
|
| `showIndoorTemperature` | If you have another module that emits the INDOOR_TEMPERATURE notification, the indoor temperature will be displayed <br> **Default value:** `false`
|
||||||
| `onlyTemp` | Show only current Temperature and weather icon without windspeed, sunset and sunrise time. <br><br> **Possible values:** `true` or `false` <br> **Default value:** `false`
|
| `onlyTemp` | Show only current Temperature and weather icon without windspeed, sunset, sunrise time and feels like. <br><br> **Possible values:** `true` or `false` <br> **Default value:** `false`
|
||||||
|
| `showFeelsLike` | Shows the Feels like temperature weather. <br><br> **Possible values:**`true` or `false`<br>**Default value:** `true`
|
||||||
|
| `useKMPHWind` | Uses KMPH as units for windspeed. <br><br> **Possible values:**`true` or `false`<br>**Default value:** `false`
|
||||||
| `useBeaufort` | Pick between using the Beaufort scale for wind speed or using the default units. <br><br> **Possible values:** `true` or `false` <br> **Default value:** `true`
|
| `useBeaufort` | Pick between using the Beaufort scale for wind speed or using the default units. <br><br> **Possible values:** `true` or `false` <br> **Default value:** `true`
|
||||||
| `lang` | The language of the days. <br><br> **Possible values:** `en`, `nl`, `ru`, etc ... <br> **Default value:** uses value of _config.language_
|
| `lang` | The language of the days. <br><br> **Possible values:** `en`, `nl`, `ru`, etc ... <br> **Default value:** uses value of _config.language_
|
||||||
| `decimalSymbol` | The decimal symbol to use.<br><br> **Possible values:** `.`, `,` or any other symbol.<br> **Default value:** `.`
|
| `decimalSymbol` | The decimal symbol to use.<br><br> **Possible values:** `.`, `,` or any other symbol.<br> **Default value:** `.`
|
||||||
|
@ -23,12 +23,14 @@ Module.register("currentweather",{
|
|||||||
showWindDirection: true,
|
showWindDirection: true,
|
||||||
showWindDirectionAsArrow: false,
|
showWindDirectionAsArrow: false,
|
||||||
useBeaufort: true,
|
useBeaufort: true,
|
||||||
|
useKMPHwind: false,
|
||||||
lang: config.language,
|
lang: config.language,
|
||||||
decimalSymbol: ".",
|
decimalSymbol: ".",
|
||||||
showHumidity: false,
|
showHumidity: false,
|
||||||
degreeLabel: false,
|
degreeLabel: false,
|
||||||
showIndoorTemperature: false,
|
showIndoorTemperature: false,
|
||||||
showIndoorHumidity: false,
|
showIndoorHumidity: false,
|
||||||
|
showFeelsLike: true,
|
||||||
|
|
||||||
initialLoadDelay: 0, // 0 seconds delay
|
initialLoadDelay: 0, // 0 seconds delay
|
||||||
retryDelay: 2500,
|
retryDelay: 2500,
|
||||||
@ -105,7 +107,7 @@ Module.register("currentweather",{
|
|||||||
this.indoorTemperature = null;
|
this.indoorTemperature = null;
|
||||||
this.indoorHumidity = null;
|
this.indoorHumidity = null;
|
||||||
this.weatherType = null;
|
this.weatherType = null;
|
||||||
|
this.feelsLike = null;
|
||||||
this.loaded = false;
|
this.loaded = false;
|
||||||
this.scheduleUpdate(this.config.initialLoadDelay);
|
this.scheduleUpdate(this.config.initialLoadDelay);
|
||||||
|
|
||||||
@ -242,6 +244,19 @@ Module.register("currentweather",{
|
|||||||
}
|
}
|
||||||
|
|
||||||
wrapper.appendChild(large);
|
wrapper.appendChild(large);
|
||||||
|
|
||||||
|
if (this.config.showFeelsLike && this.config.onlyTemp === false){
|
||||||
|
var small = document.createElement("div");
|
||||||
|
small.className = "normal medium";
|
||||||
|
|
||||||
|
var feelsLike = document.createElement("span");
|
||||||
|
feelsLike.className = "dimmed";
|
||||||
|
feelsLike.innerHTML = "Feels " + this.feelsLike + "°" + degreeLabel;
|
||||||
|
small.appendChild(feelsLike);
|
||||||
|
|
||||||
|
wrapper.appendChild(small);
|
||||||
|
}
|
||||||
|
|
||||||
return wrapper;
|
return wrapper;
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -365,13 +380,71 @@ Module.register("currentweather",{
|
|||||||
|
|
||||||
this.humidity = parseFloat(data.main.humidity);
|
this.humidity = parseFloat(data.main.humidity);
|
||||||
this.temperature = this.roundValue(data.main.temp);
|
this.temperature = this.roundValue(data.main.temp);
|
||||||
|
this.feelsLike = 0;
|
||||||
|
|
||||||
if (this.config.useBeaufort){
|
if (this.config.useBeaufort){
|
||||||
this.windSpeed = this.ms2Beaufort(this.roundValue(data.wind.speed));
|
this.windSpeed = this.ms2Beaufort(this.roundValue(data.wind.speed));
|
||||||
|
} else if (this.config.useKMPHwind) {
|
||||||
|
this.windSpeed = parseFloat((data.wind.speed * 60 * 60) / 1000).toFixed(0);
|
||||||
} else {
|
} else {
|
||||||
this.windSpeed = parseFloat(data.wind.speed).toFixed(0);
|
this.windSpeed = parseFloat(data.wind.speed).toFixed(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ONLY WORKS IF TEMP IN C //
|
||||||
|
var windInMph = parseFloat(data.wind.speed * 2.23694);
|
||||||
|
|
||||||
|
var tempInF = 0;
|
||||||
|
switch (this.config.units){
|
||||||
|
case "metric": tempInF = 1.8 * this.temperature + 32;
|
||||||
|
break;
|
||||||
|
case "imperial": tempInF = this.temperature;
|
||||||
|
break;
|
||||||
|
case "default":
|
||||||
|
var tc = this.temperature - 273.15;
|
||||||
|
tempInF = 1.8 * tc + 32;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (windInMph > 3 && tempInF < 50){
|
||||||
|
// windchill
|
||||||
|
var windchillinF = Math.round(35.74+0.6215*tempInF-35.75*Math.pow(windInMph,0.16)+0.4275*tempInF*Math.pow(windInMph,0.16));
|
||||||
|
var windChillInC = (windchillinF - 32) * (5/9);
|
||||||
|
// this.feelsLike = windChillInC.toFixed(0);
|
||||||
|
|
||||||
|
switch (this.config.units){
|
||||||
|
case "metric": this.feelsLike = windChillInC.toFixed(0);
|
||||||
|
break;
|
||||||
|
case "imperial": this.feelsLike = windChillInF.toFixed(0);
|
||||||
|
break;
|
||||||
|
case "default":
|
||||||
|
var tc = windChillInC - 273.15;
|
||||||
|
this.feelsLike = tc.toFixed(0);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
} else if (tempInF > 80 && this.humidity > 40){
|
||||||
|
// heat index
|
||||||
|
var Hindex = -42.379 + 2.04901523*tempInF + 10.14333127*this.humidity
|
||||||
|
- 0.22475541*tempInF*this.humidity - 6.83783*Math.pow(10,-3)*tempInF*tempInF
|
||||||
|
- 5.481717*Math.pow(10,-2)*this.humidity*this.humidity
|
||||||
|
+ 1.22874*Math.pow(10,-3)*tempInF*tempInF*this.humidity
|
||||||
|
+ 8.5282*Math.pow(10,-4)*tempInF*this.humidity*this.humidity
|
||||||
|
- 1.99*Math.pow(10,-6)*tempInF*tempInF*this.humidity*this.humidity;
|
||||||
|
|
||||||
|
switch (this.config.units){
|
||||||
|
case "metric": this.feelsLike = Hindex.toFixed(0);
|
||||||
|
break;
|
||||||
|
case "imperial": this.feelsLike = parseFloat(Hindex * 1.8 + 32).toFixed(0);
|
||||||
|
break;
|
||||||
|
case "default":
|
||||||
|
var tc = Hindex - 273.15;
|
||||||
|
this.feelsLike = tc.toFixed(0);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
this.feelsLike = parseFloat(this.temperature).toFixed(0);
|
||||||
|
}
|
||||||
|
|
||||||
this.windDirection = this.deg2Cardinal(data.wind.deg);
|
this.windDirection = this.deg2Cardinal(data.wind.deg);
|
||||||
this.windDeg = data.wind.deg;
|
this.windDeg = data.wind.deg;
|
||||||
this.weatherType = this.config.iconTable[data.weather[0].icon];
|
this.weatherType = this.config.iconTable[data.weather[0].icon];
|
||||||
@ -497,4 +570,5 @@ Module.register("currentweather",{
|
|||||||
var decimals = this.config.roundTemp ? 0 : 1;
|
var decimals = this.config.roundTemp ? 0 : 1;
|
||||||
return parseFloat(temperature).toFixed(decimals);
|
return parseFloat(temperature).toFixed(decimals);
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user