Better stability for weather
parent
a02e6d79c4
commit
058beeae94
|
|
@ -579,38 +579,35 @@ function getWeather(){
|
||||||
|
|
||||||
try {
|
try {
|
||||||
weatherJson = storage.readJSON('weather.json');
|
weatherJson = storage.readJSON('weather.json');
|
||||||
|
var weather = weatherJson.weather;
|
||||||
|
|
||||||
|
// Temperature
|
||||||
|
weather.temp = locale.temp(weather.temp-273.15);
|
||||||
|
|
||||||
|
// Humidity
|
||||||
|
weather.hum = weather.hum + "%";
|
||||||
|
|
||||||
|
// Wind
|
||||||
|
const wind = locale.speed(weather.wind).match(/^(\D*\d*)(.*)$/);
|
||||||
|
var speedFactor = settings.speed == "kph" ? 1.0 : 1.0 / 1.60934;
|
||||||
|
weather.wind = Math.round(wind[1] * speedFactor);
|
||||||
|
|
||||||
|
return weather
|
||||||
|
|
||||||
} catch(ex) {
|
} catch(ex) {
|
||||||
// Return default
|
// Return default
|
||||||
}
|
}
|
||||||
|
|
||||||
if(weatherJson === undefined){
|
return {
|
||||||
return {
|
temp: " ? ",
|
||||||
temp: "-",
|
hum: " ? ",
|
||||||
hum: "-",
|
txt: " ? ",
|
||||||
txt: "-",
|
wind: " ? ",
|
||||||
wind: "-",
|
wdir: " ? ",
|
||||||
wdir: "-",
|
wrose: " ? "
|
||||||
wrose: "-"
|
};
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
var weather = weatherJson.weather;
|
|
||||||
|
|
||||||
// Temperature
|
|
||||||
weather.temp = locale.temp(weather.temp-273.15);
|
|
||||||
|
|
||||||
// Humidity
|
|
||||||
weather.hum = weather.hum + "%";
|
|
||||||
|
|
||||||
// Wind
|
|
||||||
const wind = locale.speed(weather.wind).match(/^(\D*\d*)(.*)$/);
|
|
||||||
var speedFactor = settings.speed == "kph" ? 1.0 : 1.0 / 1.60934;
|
|
||||||
weather.wind = Math.round(wind[1] * speedFactor);
|
|
||||||
|
|
||||||
return weather
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Handle alarm
|
* Handle alarm
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue