This commit is contained in:
Michael Teeuw 2016-11-10 20:06:00 +01:00
commit 0bab32315c
4 changed files with 88 additions and 4 deletions

View File

@ -24,6 +24,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
- 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
- Ability to set date format in calendar module
- Possibility to use currentweather for the compliments
### Updated
- Modified translations for Frysk.

View File

@ -63,6 +63,44 @@ The following properties can be configured:
The `compliments` property contains an object with three arrays: <code>morning</code>, <code>afternoon</code> and<code>evening</code>. 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:
* <code>day_sunny</code>
* <code>day_cloudy</code>
* <code>cloudy</code>
* <code>cloudy_windy</code>
* <code>showers</code>
* <code>rain</code>
* <code>thunderstorm</code>
* <code>snow</code>
* <code>fog</code>
* <code>night_clear</code>
* <code>night_cloudy</code>
* <code>night_showers</code>
* <code>night_rain</code>
* <code>night_thunderstorm</code>
* <code>night_snow</code>
* <code>night_alt_cloudy_windy<code>
#### 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: {

View File

@ -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);
}
},
});

View File

@ -335,6 +335,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()