mirror of
https://github.com/MichMich/MagicMirror.git
synced 2025-06-27 11:50:00 +00:00
Make a sane default for weatherEndpoint based on the type
This commit is contained in:
parent
6cbd267384
commit
0683734d5a
@ -83,7 +83,6 @@ var config = {
|
|||||||
config: {
|
config: {
|
||||||
weatherProvider: "openweathermap",
|
weatherProvider: "openweathermap",
|
||||||
type: "forecast",
|
type: "forecast",
|
||||||
weatherEndpoint: "/forecast",
|
|
||||||
location: "New York",
|
location: "New York",
|
||||||
locationID: "5128581", //ID from http://bulk.openweathermap.org/sample/city.list.json.gz; unzip the gz file and find your city
|
locationID: "5128581", //ID from http://bulk.openweathermap.org/sample/city.list.json.gz; unzip the gz file and find your city
|
||||||
apiKey: "YOUR_OPENWEATHER_API_KEY"
|
apiKey: "YOUR_OPENWEATHER_API_KEY"
|
||||||
|
@ -18,7 +18,7 @@ WeatherProvider.register("openweathermap", {
|
|||||||
defaults: {
|
defaults: {
|
||||||
apiVersion: "2.5",
|
apiVersion: "2.5",
|
||||||
apiBase: "https://api.openweathermap.org/data/",
|
apiBase: "https://api.openweathermap.org/data/",
|
||||||
weatherEndpoint: "/weather",
|
weatherEndpoint: "",
|
||||||
locationID: false,
|
locationID: false,
|
||||||
location: false,
|
location: false,
|
||||||
lat: 0,
|
lat: 0,
|
||||||
@ -96,8 +96,21 @@ WeatherProvider.register("openweathermap", {
|
|||||||
*/
|
*/
|
||||||
setConfig(config) {
|
setConfig(config) {
|
||||||
this.config = config;
|
this.config = config;
|
||||||
if (this.config.type === "hourly") {
|
if (!this.config.weatherEndpoint) {
|
||||||
|
switch (this.config.type) {
|
||||||
|
case "hourly":
|
||||||
this.config.weatherEndpoint = "/onecall";
|
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");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user