diff --git a/CHANGELOG.md b/CHANGELOG.md
index 2f6e9022..87059da3 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -23,6 +23,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
- Added option to show rain amount in the weatherforecast default module
- Add module `updatenotification` to get an update whenever a new version is availabe. [See documentation](https://github.com/MichMich/MagicMirror/tree/develop/modules/default/updatenotification) for more information.
- Add the abilty to set timezone on the date display in the Clock Module
+- Possibility to use currentweather for the compliments
### Updated
- Modified translations for Frysk.
diff --git a/modules/default/compliments/README.md b/modules/default/compliments/README.md
index bf5b9538..911de4b0 100644
--- a/modules/default/compliments/README.md
+++ b/modules/default/compliments/README.md
@@ -63,6 +63,44 @@ The following properties can be configured:
The `compliments` property contains an object with three arrays: morning
, afternoon
andevening
. Based on the time of the day, the compliments will be picked out of one of these arrays. The arrays contain one or multiple compliments.
+
+If use the currentweather is possible use a actual weather for set compliments. The availables properties are:
+* day_sunny
+* day_cloudy
+* cloudy
+* cloudy_windy
+* showers
+* rain
+* thunderstorm
+* snow
+* fog
+* night_clear
+* night_cloudy
+* night_showers
+* night_rain
+* night_thunderstorm
+* night_snow
+* night_alt_cloudy_windy
+
+#### Example use with currentweather module
+````javascript
+config: {
+ compliments: {
+ day_sunny: [
+ 'Today is a sunny day',
+ 'It\'s a beautiful day'
+ ],
+ snow: [
+ 'Snowball battle!'
+ ],
+ rain: [
+ 'Don\'t forget your umbrella'
+ ]
+ }
+}
+````
+
+
#### Default value:
````javascript
config: {
diff --git a/modules/default/compliments/compliments.js b/modules/default/compliments/compliments.js
index 61f9ec5f..f05cd9c1 100644
--- a/modules/default/compliments/compliments.js
+++ b/modules/default/compliments/compliments.js
@@ -32,6 +32,9 @@ Module.register("compliments",{
fadeSpeed: 4000
},
+ // Set currentweather from module
+ currentWeatherType: "",
+
// Define required scripts.
getScripts: function() {
return ["moment.js"];
@@ -84,14 +87,21 @@ Module.register("compliments",{
*/
complimentArray: function() {
var hour = moment().hour();
+ var compliments = null;
if (hour >= 3 && hour < 12) {
- return this.config.compliments.morning;
+ compliments = this.config.compliments.morning;
} else if (hour >= 12 && hour < 17) {
- return this.config.compliments.afternoon;
+ compliments = this.config.compliments.afternoon;
} else {
- return this.config.compliments.evening;
+ compliments = this.config.compliments.evening;
}
+
+ if ( this.currentWeatherType in this.config.compliments) {
+ compliments.push.apply(compliments, this.config.compliments[this.currentWeatherType]);
+ }
+ return compliments;
+
},
/* complimentArray()
@@ -116,6 +126,40 @@ Module.register("compliments",{
wrapper.appendChild(compliment);
return wrapper;
- }
+ },
+
+
+ // From data currentweather set weather type
+ setCurrentWeatherType: function(data) {
+ var weatherIconTable = {
+ "01d": "day_sunny",
+ "02d": "day_cloudy",
+ "03d": "cloudy",
+ "04d": "cloudy_windy",
+ "09d": "showers",
+ "10d": "rain",
+ "11d": "thunderstorm",
+ "13d": "snow",
+ "50d": "fog",
+ "01n": "night_clear",
+ "02n": "night_cloudy",
+ "03n": "night_cloudy",
+ "04n": "night_cloudy",
+ "09n": "night_showers",
+ "10n": "night_rain",
+ "11n": "night_thunderstorm",
+ "13n": "night_snow",
+ "50n": "night_alt_cloudy_windy"
+ };
+ this.currentWeatherType = weatherIconTable[data.weather[0].icon];
+ },
+
+
+ // Override notification handler.
+ notificationReceived: function(notification, payload, sender) {
+ if (notification == "CURRENTWEATHER_DATA") {
+ this.setCurrentWeatherType(payload.data);
+ }
+ },
});
diff --git a/modules/default/currentweather/currentweather.js b/modules/default/currentweather/currentweather.js
index bc7ccbb7..b72b5943 100644
--- a/modules/default/currentweather/currentweather.js
+++ b/modules/default/currentweather/currentweather.js
@@ -337,6 +337,7 @@ Module.register("currentweather",{
this.show(this.config.animationSpeed, {lockString:this.identifier});
this.loaded = true;
this.updateDom(this.config.animationSpeed);
+ this.sendNotification("CURRENTWEATHER_DATA", {data: data});
},
/* scheduleUpdate()