mirror of
https://github.com/MichMich/MagicMirror.git
synced 2025-06-27 11:50:00 +00:00
run lint:prettier
This commit is contained in:
parent
212e60c12d
commit
4048d79fc5
@ -14,73 +14,68 @@
|
|||||||
WeatherProvider.register("weatherflow", {
|
WeatherProvider.register("weatherflow", {
|
||||||
// Set the name of the provider.
|
// Set the name of the provider.
|
||||||
// Not strictly required, but helps for debugging
|
// Not strictly required, but helps for debugging
|
||||||
providerName: "WeatherFlow",
|
providerName: "WeatherFlow",
|
||||||
|
|
||||||
// Set the default config properties that is specific to this provider
|
// Set the default config properties that is specific to this provider
|
||||||
defaults: {
|
defaults: {
|
||||||
apiBase: "https://swd.weatherflow.com/swd/rest/",
|
apiBase: "https://swd.weatherflow.com/swd/rest/",
|
||||||
token: "",
|
token: "",
|
||||||
stationid: "",
|
stationid: ""
|
||||||
},
|
},
|
||||||
|
|
||||||
units: {
|
units: {
|
||||||
imperial: "us",
|
imperial: "us",
|
||||||
metric: "si"
|
metric: "si"
|
||||||
},
|
},
|
||||||
|
|
||||||
|
fetchCurrentWeather() {
|
||||||
|
this.fetchData(this.getUrl())
|
||||||
|
.then((data) => {
|
||||||
|
const currentWeather = new WeatherObject(this.config.units, this.config.tempUnits, this.config.windUnits, this.config.useKmh);
|
||||||
|
currentWeather.date = moment();
|
||||||
|
|
||||||
fetchCurrentWeather() {
|
currentWeather.humidity = data.current_conditions.relative_humidity;
|
||||||
this.fetchData(this.getUrl())
|
currentWeather.temperature = data.current_conditions.air_temperature;
|
||||||
.then((data) => {
|
currentWeather.windSpeed = data.current_conditions.wind_avg;
|
||||||
const currentWeather = new WeatherObject(this.config.units, this.config.tempUnits, this.config.windUnits, this.config.useKmh);
|
currentWeather.windDirection = data.current_conditions.wind_direction;
|
||||||
currentWeather.date = moment();
|
currentWeather.weatherType = data.forecast.daily[0].icon;
|
||||||
|
(currentWeather.sunrise = moment(data.forecast.daily[0].sunrise)), "X";
|
||||||
currentWeather.humidity = data.current_conditions.relative_humidity;
|
currentWeather.sunset = moment(data.forecast.daily[0].sunset, "X");
|
||||||
currentWeather.temperature = data.current_conditions.air_temperature;
|
this.setCurrentWeather(currentWeather);
|
||||||
currentWeather.windSpeed = data.current_conditions.wind_avg;
|
})
|
||||||
currentWeather.windDirection = data.current_conditions.wind_direction;
|
.catch(function (request) {
|
||||||
currentWeather.weatherType = data.forecast.daily[0].icon;
|
|
||||||
currentWeather.sunrise = moment(data.forecast.daily[0].sunrise), "X";
|
|
||||||
currentWeather.sunset = moment(data.forecast.daily[0].sunset, "X");
|
|
||||||
this.setCurrentWeather(currentWeather);
|
|
||||||
|
|
||||||
})
|
|
||||||
.catch(function (request) {
|
|
||||||
Log.error("Could not load data ... ", request);
|
Log.error("Could not load data ... ", request);
|
||||||
})
|
})
|
||||||
.finally(() => this.updateAvailable());
|
.finally(() => this.updateAvailable());
|
||||||
},
|
},
|
||||||
|
|
||||||
fetchWeatherForecast() {
|
|
||||||
this.fetchData(this.getUrl())
|
|
||||||
.then((data) => {
|
|
||||||
const days = [];
|
|
||||||
|
|
||||||
for(const forecast of data.forecast.daily) {
|
fetchWeatherForecast() {
|
||||||
|
this.fetchData(this.getUrl())
|
||||||
|
.then((data) => {
|
||||||
|
const days = [];
|
||||||
|
|
||||||
const weather = new WeatherObject(this.config.units, this.config.tempUnits, this.config.windUnits, this.config.useKmh);
|
for (const forecast of data.forecast.daily) {
|
||||||
|
const weather = new WeatherObject(this.config.units, this.config.tempUnits, this.config.windUnits, this.config.useKmh);
|
||||||
|
|
||||||
weather.date = moment(forecast.day_start_local, "X");
|
weather.date = moment(forecast.day_start_local, "X");
|
||||||
weather.minTemperature = forecast.air_temp_low;
|
weather.minTemperature = forecast.air_temp_low;
|
||||||
weather.maxTemperature = forecast.air_temp_high;
|
weather.maxTemperature = forecast.air_temp_high;
|
||||||
weather.weatherType = forecast.icon;
|
weather.weatherType = forecast.icon;
|
||||||
weather.snow = 0;
|
weather.snow = 0;
|
||||||
|
|
||||||
|
days.push(weather);
|
||||||
|
}
|
||||||
|
|
||||||
days.push(weather);
|
this.setWeatherForecast(days);
|
||||||
}
|
})
|
||||||
|
.catch(function (request) {
|
||||||
|
Log.error("Could not load data ... ", request);
|
||||||
|
})
|
||||||
|
.finally(() => this.updateAvailable());
|
||||||
|
},
|
||||||
|
|
||||||
this.setWeatherForecast(days);
|
// Create a URL from the config and base URL.
|
||||||
|
getUrl() {
|
||||||
})
|
return this.config.apiBase + "better_forecast?station_id=" + this.config.stationid + "&token=" + this.config.token;
|
||||||
.catch(function (request) {
|
}
|
||||||
Log.error("Could not load data ... ", request);
|
});
|
||||||
})
|
|
||||||
.finally(() => this.updateAvailable());
|
|
||||||
},
|
|
||||||
|
|
||||||
// Create a URL from the config and base URL.
|
|
||||||
getUrl() {
|
|
||||||
return this.config.apiBase + "better_forecast?station_id=" + this.config.stationid + "&token=" + this.config.token
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user