diff --git a/app/src/views/Settings.vue b/app/src/views/Settings.vue index cd8cddd..5d8fe9c 100644 --- a/app/src/views/Settings.vue +++ b/app/src/views/Settings.vue @@ -81,24 +81,26 @@ - - + + > @@ -167,7 +169,18 @@ deviceMode: [ {text: 'Active', value: 'active'}, {text: 'Passive', value: 'passive'} - ] + ], + + // @see https://openweathermap.org/current#multi + weatherLang: [ + {text: 'Deutsch', value: 'de'}, + {text: 'English', value: 'en'} + ], + weatherUnit: [ + {text: 'Metrisch', value: 'metric'}, + {text: 'Imperial', value: ''} + ], + }), created () { this.$vuetify.icons.values.tv = {component: () => import(/* webpackChunkName: "icons" */'!vue-svg-loader!@material-icons/svg/svg/tv/baseline.svg')} diff --git a/src/app.cpp b/src/app.cpp index b578886..3b763de 100644 --- a/src/app.cpp +++ b/src/app.cpp @@ -117,7 +117,10 @@ void setupSettingsGet() root["playlist"]["timer"] = NVS.getInt("playlist.timer"); - root["api"]["owm"] = NVS.getString("api.owm"); + root["weather"]["api"] = NVS.getString("weather.api"); + root["weather"]["location"] = NVS.getInt("weather.loc"); + root["weather"]["lang"] = NVS.getString("weather.lang"); + root["weather"]["unit"] = NVS.getString("weather.unit"); root["cloud"]["mode"] = NVS.getString("cloud.mode"); root["cloud"]["url"] = NVS.getString("cloud.url"); @@ -147,7 +150,10 @@ void setupSettingsPost() NVS.setInt("playlist.timer", doc["playlist"]["timer"].as()); - NVS.setString("api.owm", doc["api"]["owm"]); + NVS.setString("weather.api", doc["weather"]["api"]); + NVS.setInt("weather.loc", doc["weather"]["location"].as()); + NVS.setString("weather.lang", doc["weather"]["lang"]); + NVS.setString("weather.unit", doc["weather"]["unit"]); NVS.setString("cloud.mode", doc["cloud"]["mode"]); NVS.setString("cloud.url", doc["cloud"]["url"]); diff --git a/src/faceWeather.cpp b/src/faceWeather.cpp index 9ad5e29..ca2b45f 100644 --- a/src/faceWeather.cpp +++ b/src/faceWeather.cpp @@ -4,6 +4,7 @@ #include "faceWeatherIcons.h" #include "display.h" #include "download.h" +#include "settings.h" #include // current day #include // current day @@ -147,25 +148,27 @@ void render_forecast() bool downloadWeatherData() { String url; - // http://api.openweathermap.org/data/2.5/weather?id=2766824&APPID=883b3c87223430d6f3a399645f8ba12b&lang=de&cnt=3&units=metric - // http://api.openweathermap.org/data/2.5/forecast?id=2766824&APPID=883b3c87223430d6f3a399645f8ba12b&lang=de // https://openweathermap.org/current url = "http://api.openweathermap.org/data/2.5/weather?"; - url += "APPID=883b3c87223430d6f3a399645f8ba12b"; // api key - url += "&id=2766824"; // location - url += "&lang=de&units=metric"; // settings + url += "APPID=" + NVS.getString("weather.api"); + url += "&id="; + url.concat((unsigned long)NVS.getInt("weather.loc")); + url += "&lang=" + NVS.getString("weather.lang"); + url += "&units=" + NVS.getString("weather.unit"); if (!downloadFile(url, faceWeatherCurrent)) { return false; } // https://openweathermap.org/forecast5 - // http://api.openweathermap.org/data/2.5/forecast/daily?id=2766824&APPID=883b3c87223430d6f3a399645f8ba12b&lang=de&cnt=3 url = "http://api.openweathermap.org/data/2.5/forecast/daily?"; - url += "APPID=883b3c87223430d6f3a399645f8ba12b"; // api key - url += "&id=2766824"; // location - url += "&lang=de&cnt=4&units=metric"; // settings + url += "APPID=" + NVS.getString("weather.api"); + url += "&id="; + url.concat((unsigned long)NVS.getInt("weather.loc")); + url += "&lang=" + NVS.getString("weather.lang"); + url += "&units=" + NVS.getString("weather.unit"); + url += "&cnt=4"; if (!downloadFile(url, faceWeatherForecast)) { return false;