mirror of
https://github.com/MichMich/MagicMirror.git
synced 2025-06-27 11:50:00 +00:00
compliments: Add feature use current weather.
Possibility the use the actual type of currentweather to show the compliments.
This commit is contained in:
parent
df00a1e0a3
commit
70d6d4246d
@ -23,6 +23,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
|
|||||||
- Added option to show rain amount in the weatherforecast default module
|
- 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 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
|
- Add the abilty to set timezone on the date display in the Clock Module
|
||||||
|
- Possibility to use currentweather for the compliments
|
||||||
|
|
||||||
### Updated
|
### Updated
|
||||||
- Modified translations for Frysk.
|
- Modified translations for Frysk.
|
||||||
|
@ -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.
|
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:
|
#### Default value:
|
||||||
````javascript
|
````javascript
|
||||||
config: {
|
config: {
|
||||||
|
@ -32,6 +32,9 @@ Module.register("compliments",{
|
|||||||
fadeSpeed: 4000
|
fadeSpeed: 4000
|
||||||
},
|
},
|
||||||
|
|
||||||
|
// Set currentweather from module
|
||||||
|
currentWeatherType: "",
|
||||||
|
|
||||||
// Define required scripts.
|
// Define required scripts.
|
||||||
getScripts: function() {
|
getScripts: function() {
|
||||||
return ["moment.js"];
|
return ["moment.js"];
|
||||||
@ -84,14 +87,21 @@ Module.register("compliments",{
|
|||||||
*/
|
*/
|
||||||
complimentArray: function() {
|
complimentArray: function() {
|
||||||
var hour = moment().hour();
|
var hour = moment().hour();
|
||||||
|
var compliments = null;
|
||||||
|
|
||||||
if (hour >= 3 && hour < 12) {
|
if (hour >= 3 && hour < 12) {
|
||||||
return this.config.compliments.morning;
|
compliments = this.config.compliments.morning;
|
||||||
} else if (hour >= 12 && hour < 17) {
|
} else if (hour >= 12 && hour < 17) {
|
||||||
return this.config.compliments.afternoon;
|
compliments = this.config.compliments.afternoon;
|
||||||
} else {
|
} 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()
|
/* complimentArray()
|
||||||
@ -116,6 +126,40 @@ Module.register("compliments",{
|
|||||||
wrapper.appendChild(compliment);
|
wrapper.appendChild(compliment);
|
||||||
|
|
||||||
return wrapper;
|
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);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
});
|
});
|
||||||
|
@ -337,6 +337,7 @@ Module.register("currentweather",{
|
|||||||
this.show(this.config.animationSpeed, {lockString:this.identifier});
|
this.show(this.config.animationSpeed, {lockString:this.identifier});
|
||||||
this.loaded = true;
|
this.loaded = true;
|
||||||
this.updateDom(this.config.animationSpeed);
|
this.updateDom(this.config.animationSpeed);
|
||||||
|
this.sendNotification("CURRENTWEATHER_DATA", {data: data});
|
||||||
},
|
},
|
||||||
|
|
||||||
/* scheduleUpdate()
|
/* scheduleUpdate()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user