mirror of
https://github.com/netbymatt/ws4kp.git
synced 2026-04-18 17:49:31 -07:00
local forecast silent refresh
This commit is contained in:
@@ -14,19 +14,21 @@ class LocalForecast extends WeatherDisplay {
|
||||
this.timing.baseDelay = 5000;
|
||||
}
|
||||
|
||||
async getData(_weatherParameters, refresh) {
|
||||
if (!super.getData(_weatherParameters, refresh)) return;
|
||||
const weatherParameters = _weatherParameters ?? this.weatherParameters;
|
||||
async getData(weatherParameters, refresh) {
|
||||
if (!super.getData(weatherParameters, refresh)) return;
|
||||
|
||||
// get raw data
|
||||
const rawData = await this.getRawData(weatherParameters);
|
||||
// check for data
|
||||
if (!rawData) {
|
||||
const rawData = await this.getRawData(this.weatherParameters);
|
||||
// check for data, or if there's old data available
|
||||
if (!rawData && !this.data) {
|
||||
// fail for no old or new data
|
||||
this.setStatus(STATUS.failed);
|
||||
return;
|
||||
}
|
||||
// store the data
|
||||
this.data = rawData || this.data;
|
||||
// parse raw data
|
||||
const conditions = parse(rawData);
|
||||
const conditions = parse(this.data);
|
||||
|
||||
// read each text
|
||||
this.screenTexts = conditions.map((condition) => {
|
||||
@@ -70,7 +72,6 @@ class LocalForecast extends WeatherDisplay {
|
||||
} catch (error) {
|
||||
console.error(`GetWeatherForecast failed: ${weatherParameters.forecast}`);
|
||||
console.error(error.status, error.responseJSON);
|
||||
this.setStatus(STATUS.failed);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user