mirror of
https://github.com/MichMich/MagicMirror.git
synced 2025-06-28 20:22:53 +00:00
Add new Event CURRENTWEATHER_TYPE
- send it from the weather and currentweather module - use it in the compliments module directly instead of the data
This commit is contained in:
parent
1fd506f25d
commit
e0d43a4c1e
@ -182,34 +182,14 @@ Module.register("compliments", {
|
|||||||
},
|
},
|
||||||
|
|
||||||
// From data currentweather set weather type
|
// From data currentweather set weather type
|
||||||
setCurrentWeatherType: function (data) {
|
setCurrentWeatherType: function (type) {
|
||||||
var weatherIconTable = {
|
this.currentWeatherType = type;
|
||||||
"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.
|
// Override notification handler.
|
||||||
notificationReceived: function (notification, payload, sender) {
|
notificationReceived: function (notification, payload, sender) {
|
||||||
if (notification === "CURRENTWEATHER_DATA") {
|
if (notification === "CURRENTWEATHER_TYPE") {
|
||||||
this.setCurrentWeatherType(payload.data);
|
this.setCurrentWeatherType(payload.type);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -47,24 +47,24 @@ Module.register("currentweather", {
|
|||||||
roundTemp: false,
|
roundTemp: false,
|
||||||
|
|
||||||
iconTable: {
|
iconTable: {
|
||||||
"01d": "wi-day-sunny",
|
"01d": "day-sunny",
|
||||||
"02d": "wi-day-cloudy",
|
"02d": "day-cloudy",
|
||||||
"03d": "wi-cloudy",
|
"03d": "cloudy",
|
||||||
"04d": "wi-cloudy-windy",
|
"04d": "cloudy-windy",
|
||||||
"09d": "wi-showers",
|
"09d": "showers",
|
||||||
"10d": "wi-rain",
|
"10d": "rain",
|
||||||
"11d": "wi-thunderstorm",
|
"11d": "thunderstorm",
|
||||||
"13d": "wi-snow",
|
"13d": "snow",
|
||||||
"50d": "wi-fog",
|
"50d": "fog",
|
||||||
"01n": "wi-night-clear",
|
"01n": "night-clear",
|
||||||
"02n": "wi-night-cloudy",
|
"02n": "night-cloudy",
|
||||||
"03n": "wi-night-cloudy",
|
"03n": "night-cloudy",
|
||||||
"04n": "wi-night-cloudy",
|
"04n": "night-cloudy",
|
||||||
"09n": "wi-night-showers",
|
"09n": "night-showers",
|
||||||
"10n": "wi-night-rain",
|
"10n": "night-rain",
|
||||||
"11n": "wi-night-thunderstorm",
|
"11n": "night-thunderstorm",
|
||||||
"13n": "wi-night-snow",
|
"13n": "night-snow",
|
||||||
"50n": "wi-night-alt-cloudy-windy"
|
"50n": "night-alt-cloudy-windy"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -219,7 +219,7 @@ Module.register("currentweather", {
|
|||||||
|
|
||||||
if (this.config.hideTemp === false) {
|
if (this.config.hideTemp === false) {
|
||||||
var weatherIcon = document.createElement("span");
|
var weatherIcon = document.createElement("span");
|
||||||
weatherIcon.className = "wi weathericon " + this.weatherType;
|
weatherIcon.className = "wi weathericon wi-" + this.weatherType;
|
||||||
large.appendChild(weatherIcon);
|
large.appendChild(weatherIcon);
|
||||||
|
|
||||||
var temperature = document.createElement("span");
|
var temperature = document.createElement("span");
|
||||||
@ -502,6 +502,7 @@ Module.register("currentweather", {
|
|||||||
this.loaded = true;
|
this.loaded = true;
|
||||||
this.updateDom(this.config.animationSpeed);
|
this.updateDom(this.config.animationSpeed);
|
||||||
this.sendNotification("CURRENTWEATHER_DATA", { data: data });
|
this.sendNotification("CURRENTWEATHER_DATA", { data: data });
|
||||||
|
this.sendNotification("CURRENTWEATHER_TYPE", { type: this.config.iconTable[data.weather[0].icon].replace("-", "_") });
|
||||||
},
|
},
|
||||||
|
|
||||||
/* scheduleUpdate()
|
/* scheduleUpdate()
|
||||||
|
@ -152,6 +152,7 @@ Module.register("weather", {
|
|||||||
// What to do when the weather provider has new information available?
|
// What to do when the weather provider has new information available?
|
||||||
updateAvailable: function () {
|
updateAvailable: function () {
|
||||||
Log.log("New weather information available.");
|
Log.log("New weather information available.");
|
||||||
|
this.sendNotification("CURRENTWEATHER_TYPE", { type: this.weatherProvider.currentWeather().weatherType.replace("-", "_") });
|
||||||
this.updateDom(0);
|
this.updateDom(0);
|
||||||
this.scheduleUpdate();
|
this.scheduleUpdate();
|
||||||
},
|
},
|
||||||
|
Loading…
x
Reference in New Issue
Block a user