use device settings for weather face

pull/1/head
Thomas Ballmann 4 years ago
parent 0286f90f29
commit 2f4c343d88

@ -81,24 +81,26 @@
<v-card-text> <v-card-text>
<v-text-field <v-text-field
label="i8n:OpenWeatherMap" label="i8n:OpenWeatherMap"
v-model="settings.api.owm" v-model="settings.weather.api"
placeholder="###" placeholder="###"
></v-text-field> ></v-text-field>
<v-text-field <v-text-field
label="i8n:Location" label="i8n:Location"
v-model="settings.owm" v-model="settings.weather.location"
placeholder="" placeholder=""
></v-text-field> ></v-text-field>
<v-text-field <v-select
:items="weatherLang"
v-model="settings.weather.lang"
label="i8n:Lang" label="i8n:Lang"
v-model="settings.owm"
placeholder="" placeholder=""
></v-text-field> ></v-select>
<v-text-field <v-select
:items="weatherUnit"
v-model="settings.weather.unit"
label="i8n:Units" label="i8n:Units"
v-model="settings.owm"
placeholder="" placeholder=""
></v-text-field> ></v-select>
</v-card-text> </v-card-text>
</v-tab-item> </v-tab-item>
<v-tab-item> <v-tab-item>
@ -167,7 +169,18 @@
deviceMode: [ deviceMode: [
{text: 'Active', value: 'active'}, {text: 'Active', value: 'active'},
{text: 'Passive', value: 'passive'} {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 () { created () {
this.$vuetify.icons.values.tv = {component: () => import(/* webpackChunkName: "icons" */'!vue-svg-loader!@material-icons/svg/svg/tv/baseline.svg')} this.$vuetify.icons.values.tv = {component: () => import(/* webpackChunkName: "icons" */'!vue-svg-loader!@material-icons/svg/svg/tv/baseline.svg')}

@ -117,7 +117,10 @@ void setupSettingsGet()
root["playlist"]["timer"] = NVS.getInt("playlist.timer"); 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"]["mode"] = NVS.getString("cloud.mode");
root["cloud"]["url"] = NVS.getString("cloud.url"); root["cloud"]["url"] = NVS.getString("cloud.url");
@ -147,7 +150,10 @@ void setupSettingsPost()
NVS.setInt("playlist.timer", doc["playlist"]["timer"].as<unsigned int>()); NVS.setInt("playlist.timer", doc["playlist"]["timer"].as<unsigned int>());
NVS.setString("api.owm", doc["api"]["owm"]); NVS.setString("weather.api", doc["weather"]["api"]);
NVS.setInt("weather.loc", doc["weather"]["location"].as<unsigned int>());
NVS.setString("weather.lang", doc["weather"]["lang"]);
NVS.setString("weather.unit", doc["weather"]["unit"]);
NVS.setString("cloud.mode", doc["cloud"]["mode"]); NVS.setString("cloud.mode", doc["cloud"]["mode"]);
NVS.setString("cloud.url", doc["cloud"]["url"]); NVS.setString("cloud.url", doc["cloud"]["url"]);

@ -4,6 +4,7 @@
#include "faceWeatherIcons.h" #include "faceWeatherIcons.h"
#include "display.h" #include "display.h"
#include "download.h" #include "download.h"
#include "settings.h"
#include <Fonts/FreeSansBold24pt7b.h> // current day #include <Fonts/FreeSansBold24pt7b.h> // current day
#include <Fonts/FreeSansBold18pt7b.h> // current day #include <Fonts/FreeSansBold18pt7b.h> // current day
@ -147,25 +148,27 @@ void render_forecast()
bool downloadWeatherData() bool downloadWeatherData()
{ {
String url; 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 // https://openweathermap.org/current
url = "http://api.openweathermap.org/data/2.5/weather?"; url = "http://api.openweathermap.org/data/2.5/weather?";
url += "APPID=883b3c87223430d6f3a399645f8ba12b"; // api key url += "APPID=" + NVS.getString("weather.api");
url += "&id=2766824"; // location url += "&id=";
url += "&lang=de&units=metric"; // settings url.concat((unsigned long)NVS.getInt("weather.loc"));
url += "&lang=" + NVS.getString("weather.lang");
url += "&units=" + NVS.getString("weather.unit");
if (!downloadFile(url, faceWeatherCurrent)) if (!downloadFile(url, faceWeatherCurrent))
{ {
return false; return false;
} }
// https://openweathermap.org/forecast5 // 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 = "http://api.openweathermap.org/data/2.5/forecast/daily?";
url += "APPID=883b3c87223430d6f3a399645f8ba12b"; // api key url += "APPID=" + NVS.getString("weather.api");
url += "&id=2766824"; // location url += "&id=";
url += "&lang=de&cnt=4&units=metric"; // settings 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)) if (!downloadFile(url, faceWeatherForecast))
{ {
return false; return false;

Loading…
Cancel
Save