Skip to content

Commit

Permalink
Merge pull request #2433 from buxxi/deprecate-old-weather
Browse files Browse the repository at this point in the history
  • Loading branch information
MichMich authored Jan 24, 2021
2 parents 925113f + 0683734 commit c0ddc02
Show file tree
Hide file tree
Showing 9 changed files with 51 additions and 7 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ _This release is scheduled to be released on 2021-04-01._
- Added CodeCov badge to Readme.
- Added CURRENTWEATHER_TYPE notification to currentweather and weather module, use it in compliments module.
- Added `start:dev` command to the npm scripts for starting electron with devTools open.
- Added logging when using deprecated modules weatherforecast or currentweather.
- Portuguese translations for "MODULE_CONFIG_CHANGED" and PRECIP.

### Updated
Expand Down
12 changes: 8 additions & 4 deletions config/config.js.sample
Original file line number Diff line number Diff line change
Expand Up @@ -66,22 +66,26 @@ var config = {
position: "lower_third"
},
{
module: "currentweather",
module: "weather",
position: "top_right",
config: {
weatherProvider: "openweathermap",
type: "current",
location: "New York",
locationID: "5128581", //ID from http://bulk.openweathermap.org/sample/city.list.json.gz; unzip the gz file and find your city
appid: "YOUR_OPENWEATHER_API_KEY"
apiKey: "YOUR_OPENWEATHER_API_KEY"
}
},
{
module: "weatherforecast",
module: "weather",
position: "top_right",
header: "Weather Forecast",
config: {
weatherProvider: "openweathermap",
type: "forecast",
location: "New York",
locationID: "5128581", //ID from http://bulk.openweathermap.org/sample/city.list.json.gz; unzip the gz file and find your city
appid: "YOUR_OPENWEATHER_API_KEY"
apiKey: "YOUR_OPENWEATHER_API_KEY"
}
},
{
Expand Down
2 changes: 2 additions & 0 deletions modules/default/currentweather/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Module: Current Weather

> :warning: **This module is deprecated in favor of the [weather](https://docs.magicmirror.builders/modules/weather.html) module.**
The `currentweather` module is one of the default modules of the MagicMirror.
This module displays the current weather, including the windspeed, the sunset or sunrise time, the temperature and an icon to display the current conditions.

Expand Down
2 changes: 2 additions & 0 deletions modules/default/currentweather/currentweather.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
*
* By Michael Teeuw https://michaelteeuw.nl
* MIT Licensed.
*
* This module is deprecated. Any additional feature will no longer be merged.
*/
Module.register("currentweather", {
// Default module config.
Expand Down
9 changes: 9 additions & 0 deletions modules/default/currentweather/node_helper.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
const NodeHelper = require("node_helper");
const Log = require("../../../js/logger");

module.exports = NodeHelper.create({
// Override start method.
start: function () {
Log.warn(`The module '${this.name}' is deprecated in favor of the 'weather'-module, please refer to the documentation for a migration path`);
}
});
19 changes: 16 additions & 3 deletions modules/default/weather/providers/openweathermap.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ WeatherProvider.register("openweathermap", {
defaults: {
apiVersion: "2.5",
apiBase: "https://api.openweathermap.org/data/",
weatherEndpoint: "/weather",
weatherEndpoint: "",
locationID: false,
location: false,
lat: 0,
Expand Down Expand Up @@ -96,8 +96,21 @@ WeatherProvider.register("openweathermap", {
*/
setConfig(config) {
this.config = config;
if (this.config.type === "hourly") {
this.config.weatherEndpoint = "/onecall";
if (!this.config.weatherEndpoint) {
switch (this.config.type) {
case "hourly":
this.config.weatherEndpoint = "/onecall";
break;
case "daily":
case "forecast":
this.config.weatherEndpoint = "/forecast";
break;
case "current":
this.config.weatherEndpoint = "/weather";
break;
default:
Log.error("weatherEndpoint not configured and could not resolve it based on type");
}
}
},

Expand Down
2 changes: 2 additions & 0 deletions modules/default/weatherforecast/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Module: Weather Forecast

> :warning: **This module is deprecated in favor of the [weather](https://docs.magicmirror.builders/modules/weather.html) module.**
The `weatherforecast` module is one of the default modules of the MagicMirror.
This module displays the weather forecast for the coming week, including an an icon to display the current conditions, the minimum temperature and the maximum temperature.

Expand Down
9 changes: 9 additions & 0 deletions modules/default/weatherforecast/node_helper.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
const NodeHelper = require("node_helper");
const Log = require("../../../js/logger");

module.exports = NodeHelper.create({
// Override start method.
start: function () {
Log.warn(`The module '${this.name}' is deprecated in favor of the 'weather'-module, please refer to the documentation for a migration path`);
}
});
2 changes: 2 additions & 0 deletions modules/default/weatherforecast/weatherforecast.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
*
* By Michael Teeuw https://michaelteeuw.nl
* MIT Licensed.
*
* This module is deprecated. Any additional feature will no longer be merged.
*/
Module.register("weatherforecast", {
// Default module config.
Expand Down

0 comments on commit c0ddc02

Please sign in to comment.