From d93f5d77854697ff8504723f10d8309fb0a35179 Mon Sep 17 00:00:00 2001 From: Pranav Sethi <96.pranav@gmail.com> Date: Sat, 3 Mar 2018 04:21:24 -0500 Subject: [PATCH 1/9] Added Feels Like and Windspeed in KMPH --- .../default/currentweather/currentweather.js | 72 ++++++++++++++++++- 1 file changed, 71 insertions(+), 1 deletion(-) diff --git a/modules/default/currentweather/currentweather.js b/modules/default/currentweather/currentweather.js index 8cd3a292..a2295bd0 100644 --- a/modules/default/currentweather/currentweather.js +++ b/modules/default/currentweather/currentweather.js @@ -23,12 +23,14 @@ Module.register("currentweather",{ showWindDirection: true, showWindDirectionAsArrow: false, useBeaufort: true, + useKMPHwind: false, lang: config.language, decimalSymbol: ".", showHumidity: false, degreeLabel: false, showIndoorTemperature: false, showIndoorHumidity: false, + showFeelsLike: true, initialLoadDelay: 0, // 0 seconds delay retryDelay: 2500, @@ -105,7 +107,7 @@ Module.register("currentweather",{ this.indoorTemperature = null; this.indoorHumidity = null; this.weatherType = null; - + this.feelsLike = null; this.loaded = false; this.scheduleUpdate(this.config.initialLoadDelay); @@ -242,6 +244,19 @@ Module.register("currentweather",{ } 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; }, @@ -365,13 +380,67 @@ Module.register("currentweather",{ this.humidity = parseFloat(data.main.humidity); this.temperature = this.roundValue(data.main.temp); + this.feelsLike = 0; if (this.config.useBeaufort){ 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 { 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; + + // this.feelsLike = Hindex.toFixed(0); + + 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.windDeg = data.wind.deg; this.weatherType = this.config.iconTable[data.weather[0].icon]; @@ -497,4 +566,5 @@ Module.register("currentweather",{ var decimals = this.config.roundTemp ? 0 : 1; return parseFloat(temperature).toFixed(decimals); } + }); From a6f08a09d5179e047a4d754c5182149ae79c748a Mon Sep 17 00:00:00 2001 From: Pranav Sethi <96.pranav@gmail.com> Date: Sat, 3 Mar 2018 04:52:22 -0500 Subject: [PATCH 2/9] Added Feels Like and Windspeed in KMPH --- .../default/currentweather/currentweather.js | 39 ++++++++++++------- 1 file changed, 24 insertions(+), 15 deletions(-) diff --git a/modules/default/currentweather/currentweather.js b/modules/default/currentweather/currentweather.js index a2295bd0..ce97e80f 100644 --- a/modules/default/currentweather/currentweather.js +++ b/modules/default/currentweather/currentweather.js @@ -395,11 +395,14 @@ Module.register("currentweather",{ 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; + 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){ @@ -409,11 +412,14 @@ Module.register("currentweather",{ // 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; + 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){ @@ -428,11 +434,14 @@ Module.register("currentweather",{ // this.feelsLike = Hindex.toFixed(0); 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; + 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 { From 43d5311e5ec6740248568fc420e84415ed21c4a2 Mon Sep 17 00:00:00 2001 From: Pranav Sethi <96.pranav@gmail.com> Date: Sat, 3 Mar 2018 05:00:26 -0500 Subject: [PATCH 3/9] Fixed Trailling Spaces --- .../default/currentweather/currentweather.js | 27 ++++++++----------- 1 file changed, 11 insertions(+), 16 deletions(-) diff --git a/modules/default/currentweather/currentweather.js b/modules/default/currentweather/currentweather.js index ce97e80f..25e437ba 100644 --- a/modules/default/currentweather/currentweather.js +++ b/modules/default/currentweather/currentweather.js @@ -395,13 +395,13 @@ Module.register("currentweather",{ var tempInF = 0; switch (this.config.units){ - case "metric": tempInF = 1.8 * this.temperature + 32; + case "metric": tempInF = 1.8 * this.temperature + 32; break; - case "imperial": tempInF = this.temperature; + case "imperial": tempInF = this.temperature; break; case "default": var tc = this.temperature - 273.15; - tempInF = 1.8 * tc + 32; + tempInF = 1.8 * tc + 32; break; } @@ -412,13 +412,13 @@ Module.register("currentweather",{ // this.feelsLike = windChillInC.toFixed(0); switch (this.config.units){ - case "metric": this.feelsLike = windChillInC.toFixed(0); + case "metric": this.feelsLike = windChillInC.toFixed(0); break; - case "imperial": this.feelsLike = windChillInF.toFixed(0); + case "imperial": this.feelsLike = windChillInF.toFixed(0); break; - case "default": + case "default": var tc = windChillInC - 273.15; - this.feelsLike = tc.toFixed(0); + this.feelsLike = tc.toFixed(0); break; } @@ -430,25 +430,20 @@ Module.register("currentweather",{ + 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; - // this.feelsLike = Hindex.toFixed(0); - switch (this.config.units){ - case "metric": this.feelsLike = Hindex.toFixed(0); + case "metric": this.feelsLike = Hindex.toFixed(0); break; - case "imperial": this.feelsLike = parseFloat(Hindex * 1.8 + 32).toFixed(0); + case "imperial": this.feelsLike = parseFloat(Hindex * 1.8 + 32).toFixed(0); break; - case "default": + case "default": var tc = Hindex - 273.15; - this.feelsLike = tc.toFixed(0); + this.feelsLike = tc.toFixed(0); break; } - } else { this.feelsLike = parseFloat(this.temperature).toFixed(0); } - - this.windDirection = this.deg2Cardinal(data.wind.deg); this.windDeg = data.wind.deg; From 62eb4f20daf40c86f6775e16fcca05aaff91bff2 Mon Sep 17 00:00:00 2001 From: Pranav Sethi <96.pranav@gmail.com> Date: Sat, 3 Mar 2018 05:08:12 -0500 Subject: [PATCH 4/9] Fixed Trailling Spaces to Pass checks --- modules/default/currentweather/currentweather.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/modules/default/currentweather/currentweather.js b/modules/default/currentweather/currentweather.js index 25e437ba..c29d587b 100644 --- a/modules/default/currentweather/currentweather.js +++ b/modules/default/currentweather/currentweather.js @@ -399,7 +399,7 @@ Module.register("currentweather",{ break; case "imperial": tempInF = this.temperature; break; - case "default": + case "default": var tc = this.temperature - 273.15; tempInF = 1.8 * tc + 32; break; @@ -424,11 +424,11 @@ Module.register("currentweather",{ } else if (tempInF > 80 && this.humidity > 40){ // heat index - var Hindex = -42.379 + 2.04901523*tempInF + 10.14333127*this.humidity + 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.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; // this.feelsLike = Hindex.toFixed(0); switch (this.config.units){ From 7285ada9dd96d5193cbe41f9b5a2219a276a0583 Mon Sep 17 00:00:00 2001 From: Pranav Sethi <96.pranav@gmail.com> Date: Mon, 12 Mar 2018 05:06:16 -0400 Subject: [PATCH 5/9] Added feels like and kmph wind for currentweather module --- CHANGELOG.md | 8 ++++++++ modules/default/currentweather/README.md | 4 +++- modules/default/currentweather/currentweather.js | 2 +- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index eec9207c..34ee824f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,14 @@ All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](http://semver.org/). +## [2.4.0] - Unreleased + +### Added + + - Add two new configuration options for currentweather module. + - `showFeelsLike`: Shows how it actually feels like (wind chill or heat index) + - `useKMPHwind`: adds an option to see wind speed in Kmph instead of just m/s or Beaufort + ## [2.3.0] - Unreleased ### Added diff --git a/modules/default/currentweather/README.md b/modules/default/currentweather/README.md index 304eba1e..7c56ca62 100644 --- a/modules/default/currentweather/README.md +++ b/modules/default/currentweather/README.md @@ -43,7 +43,9 @@ The following properties can be configured: | `showWindDirectionAsArrow` | Show the wind direction as an arrow instead of abbreviation

**Possible values:** `true` or `false`
**Default value:** `false` | `showHumidity` | Show the current humidity

**Possible values:** `true` or `false`
**Default value:** `false` | `showIndoorTemperature` | If you have another module that emits the INDOOR_TEMPERATURE notification, the indoor temperature will be displayed
**Default value:** `false` -| `onlyTemp` | Show only current Temperature and weather icon without windspeed, sunset and sunrise time.

**Possible values:** `true` or `false`
**Default value:** `false` +| `onlyTemp` | Show only current Temperature and weather icon without windspeed, sunset, sunrise time and feels like.

**Possible values:** `true` or `false`
**Default value:** `false` +| `showFeelsLike` | Shows the Feels like temperature weather.

**Possible Values:**`true` or `false`
**Default Values: `true`** +| `useKMPHWind` | Uses KMPH as units for windspeed.

**Possible Values:**`true` or `false`
**Default Values: `false`** | `useBeaufort` | Pick between using the Beaufort scale for wind speed or using the default units.

**Possible values:** `true` or `false`
**Default value:** `true` | `lang` | The language of the days.

**Possible values:** `en`, `nl`, `ru`, etc ...
**Default value:** uses value of _config.language_ | `decimalSymbol` | The decimal symbol to use.

**Possible values:** `.`, `,` or any other symbol.
**Default value:** `.` diff --git a/modules/default/currentweather/currentweather.js b/modules/default/currentweather/currentweather.js index c29d587b..442e8632 100644 --- a/modules/default/currentweather/currentweather.js +++ b/modules/default/currentweather/currentweather.js @@ -430,7 +430,7 @@ Module.register("currentweather",{ + 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; - // this.feelsLike = Hindex.toFixed(0); + switch (this.config.units){ case "metric": this.feelsLike = Hindex.toFixed(0); break; From f767531d894c2e18fb8313063b7c870a0f7594bf Mon Sep 17 00:00:00 2001 From: Pranav Sethi <96.pranav@gmail.com> Date: Mon, 12 Mar 2018 05:25:01 -0400 Subject: [PATCH 6/9] Fixed Trailling Spaces --- CHANGELOG.md | 6 +++--- modules/default/.DS_Store | Bin 6148 -> 8196 bytes 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 34ee824f..e08bb80b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,9 +6,9 @@ This project adheres to [Semantic Versioning](http://semver.org/). ### Added - - Add two new configuration options for currentweather module. - - `showFeelsLike`: Shows how it actually feels like (wind chill or heat index) - - `useKMPHwind`: adds an option to see wind speed in Kmph instead of just m/s or Beaufort +- Add two new configuration options for currentweather module. +- `showFeelsLike`: Shows how it actually feels like. (wind chill or heat index) +- `useKMPHwind`: adds an option to see wind speed in Kmph instead of just m/s or Beaufort. ## [2.3.0] - Unreleased diff --git a/modules/default/.DS_Store b/modules/default/.DS_Store index 5e5e9ca382cac8ba039d40dd770397d75765dc65..75cd2cdb5f28094833b4a53ba410f6004e739d41 100644 GIT binary patch literal 8196 zcmeHMTWi!n82zRfO}5x>MQ8;d0wVfQq_xGRh_I}!P!JTi*at6dwn^RCG+B~tgRU!! z;H%GCU%lYpP+$B7`ai^HJ#*=j&Dw%cTEQ8ZIg`nEGTC!xlKpmxh*g@-4ACSJ8K@kK zBWV6m_<3IY%77Xf1v2o7k|jS}ulZrEFIEp|1+)TM0j+>mKr8TXD1di1FUB74eR)>5 zS^=%Vf2ja}K3J$6%L+RZ#iIj_NCALD7#0P6^8hsh?NT#9<~cfOIXpkDYT zil7>_u3`gn(2FwpK9B#Hiyub3Pa)dP-bgl)iyT2rNL$oEya#kCpoHQa>qU+=3RV;M z9jW*fXoFYhpC-rs@i*LB8aLGM7+-4*-;0y!>2GXcaA^40alhZk+*|PiCrm40GjL*YovJ)x z7^Y#a7AIS+xzeR6Yqm7gp0Zk{()5%yH+#9=HjRmMGgp_^wjMueJ#9aGjSq;z)Dx1% zyw zu(`pmxI&zNk}$sevTXhS?;55%T7e@`U{KCF$@Blky?_5dl6%vWY6Y|chob-+TBt5m zFxT!k$NaQB*S1jCP`ya03ZfkP#aTzcWwfmvIEy0WyRIL<0>3SppW@ J9M3a{835-~6)^w+ From 15bc5431b60929ad491c9b294ac4edc237434a36 Mon Sep 17 00:00:00 2001 From: Pranav Sethi <96.pranav@gmail.com> Date: Mon, 12 Mar 2018 05:25:33 -0400 Subject: [PATCH 7/9] Fixed Trailling Spaces --- modules/default/.DS_Store | Bin 8196 -> 0 bytes 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 modules/default/.DS_Store diff --git a/modules/default/.DS_Store b/modules/default/.DS_Store deleted file mode 100644 index 75cd2cdb5f28094833b4a53ba410f6004e739d41..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 8196 zcmeHMTWi!n82zRfO}5x>MQ8;d0wVfQq_xGRh_I}!P!JTi*at6dwn^RCG+B~tgRU!! z;H%GCU%lYpP+$B7`ai^HJ#*=j&Dw%cTEQ8ZIg`nEGTC!xlKpmxh*g@-4ACSJ8K@kK zBWV6m_<3IY%77Xf1v2o7k|jS}ulZrEFIEp|1+)TM0j+>mKr8TXD1di1FUB74eR)>5 zS^=%Vf2ja}K3J$6%L+RZ#iIj_NCALD7#0P6^8hsh?NT#9<~cfOIXpkDYT zil7>_u3`gn(2FwpK9B#Hiyub3Pa)dP-bgl)iyT2rNL$oEya#kCpoHQa>qU+=3RV;M z9jW*fXoFYhpC-rs@i*LB8aLGM7+-4*-;0y!>2GXcaA^40alhZk+*|PiCrm40GjL*YovJ)x z7^Y#a7AIS+xzeR6Yqm7gp0Zk{()5%yH+#9=HjRmMGgp_^wjMueJ#9aGjSq;z)Dx1% zyw zu(`pmxI&zNk}$sevTXhS?;55%T7e@`U{KCF$@Blky?_5dl6%vWY6Y|chob-+TBt5m zFxT!k$NaQB*S1jCP Date: Mon, 12 Mar 2018 22:22:45 -0400 Subject: [PATCH 8/9] Fixed typos in README.md for currentweather. --- modules/default/currentweather/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/default/currentweather/README.md b/modules/default/currentweather/README.md index 7c56ca62..030b04bf 100644 --- a/modules/default/currentweather/README.md +++ b/modules/default/currentweather/README.md @@ -44,8 +44,8 @@ The following properties can be configured: | `showHumidity` | Show the current humidity

**Possible values:** `true` or `false`
**Default value:** `false` | `showIndoorTemperature` | If you have another module that emits the INDOOR_TEMPERATURE notification, the indoor temperature will be displayed
**Default value:** `false` | `onlyTemp` | Show only current Temperature and weather icon without windspeed, sunset, sunrise time and feels like.

**Possible values:** `true` or `false`
**Default value:** `false` -| `showFeelsLike` | Shows the Feels like temperature weather.

**Possible Values:**`true` or `false`
**Default Values: `true`** -| `useKMPHWind` | Uses KMPH as units for windspeed.

**Possible Values:**`true` or `false`
**Default Values: `false`** +| `showFeelsLike` | Shows the Feels like temperature weather.

**Possible values:**`true` or `false`
**Default value:** `true` +| `useKMPHWind` | Uses KMPH as units for windspeed.

**Possible values:**`true` or `false`
**Default value:** `false` | `useBeaufort` | Pick between using the Beaufort scale for wind speed or using the default units.

**Possible values:** `true` or `false`
**Default value:** `true` | `lang` | The language of the days.

**Possible values:** `en`, `nl`, `ru`, etc ...
**Default value:** uses value of _config.language_ | `decimalSymbol` | The decimal symbol to use.

**Possible values:** `.`, `,` or any other symbol.
**Default value:** `.` From efb08fb1e10b97b5795baf23a1f58662b10e5b9d Mon Sep 17 00:00:00 2001 From: Michael Teeuw Date: Sun, 25 Mar 2018 14:51:18 +0200 Subject: [PATCH 9/9] Update CHANGELOG.md --- CHANGELOG.md | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e08bb80b..92cd15bc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,14 +2,6 @@ All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](http://semver.org/). -## [2.4.0] - Unreleased - -### Added - -- Add two new configuration options for currentweather module. -- `showFeelsLike`: Shows how it actually feels like. (wind chill or heat index) -- `useKMPHwind`: adds an option to see wind speed in Kmph instead of just m/s or Beaufort. - ## [2.3.0] - Unreleased ### Added @@ -22,6 +14,8 @@ This project adheres to [Semantic Versioning](http://semver.org/). - Changed 'compliments.js' - update DOM if remote compliments are loaded instead of waiting one updateInterval to show custom compliments - Automated unit tests utils, deprecated, translator, cloneObject(lockstrings) - Automated integration tests translations +- 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 - Add link to GitHub repository which contains the respective Dockerfile.