mirror of
https://github.com/MichMich/MagicMirror.git
synced 2025-06-27 19:53:36 +00:00
Use new method in ukmetofficedatahub provider
This commit is contained in:
parent
f49312ed13
commit
c132206543
@ -150,11 +150,9 @@ WeatherProvider.register("ukmetofficedatahub", {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Determine the sunrise/sunset times - (still) not supplied in UK Met Office data
|
// Determine the sunrise/sunset times - (still) not supplied in UK Met Office data
|
||||||
// Passes {longitude, latitude, height} to calcAstroData
|
// Passes {longitude, latitude} to SunCalc, could pass height to, but
|
||||||
// Could just pass lat/long from this.config, but returned data from MO also contains elevation
|
// SunCalc.getTimes doesnt take that into account
|
||||||
let times = this.calcAstroData(currentWeatherData.features[0].geometry.coordinates);
|
currentWeather.updateSunTime(this.config.lat, this.config.lon);
|
||||||
currentWeather.sunrise = times[0];
|
|
||||||
currentWeather.sunset = times[1];
|
|
||||||
|
|
||||||
return currentWeather;
|
return currentWeather;
|
||||||
},
|
},
|
||||||
@ -223,7 +221,6 @@ WeatherProvider.register("ukmetofficedatahub", {
|
|||||||
|
|
||||||
// Pass on full details so they can be used in custom templates
|
// Pass on full details so they can be used in custom templates
|
||||||
// Note the units of the supplied data when using this (see top of file)
|
// Note the units of the supplied data when using this (see top of file)
|
||||||
|
|
||||||
forecastWeather.rawData = forecastDataDays[day];
|
forecastWeather.rawData = forecastDataDays[day];
|
||||||
|
|
||||||
dailyForecasts.push(forecastWeather);
|
dailyForecasts.push(forecastWeather);
|
||||||
@ -238,18 +235,6 @@ WeatherProvider.register("ukmetofficedatahub", {
|
|||||||
this.fetchedLocationName = name;
|
this.fetchedLocationName = name;
|
||||||
},
|
},
|
||||||
|
|
||||||
// Calculate sunrise/sunset times
|
|
||||||
calcAstroData(location) {
|
|
||||||
const sunTimes = [];
|
|
||||||
|
|
||||||
// Careful to pass values to SunCalc in correct order (latitude, longitude, elevation)
|
|
||||||
let times = SunCalc.getTimes(new Date(), location[1], location[0], location[2]);
|
|
||||||
sunTimes.push(moment(times.sunrise, "X"));
|
|
||||||
sunTimes.push(moment(times.sunset, "X"));
|
|
||||||
|
|
||||||
return sunTimes;
|
|
||||||
},
|
|
||||||
|
|
||||||
// Convert temperatures to Fahrenheit (from degrees C), if required
|
// Convert temperatures to Fahrenheit (from degrees C), if required
|
||||||
convertTemp(tempInC) {
|
convertTemp(tempInC) {
|
||||||
return this.config.tempUnits === "imperial" ? (tempInC * 9) / 5 + 32 : tempInC;
|
return this.config.tempUnits === "imperial" ? (tempInC * 9) / 5 + 32 : tempInC;
|
||||||
|
@ -89,7 +89,6 @@ WeatherProvider.register("weatherbit", {
|
|||||||
currentWeather.windSpeed = parseFloat(currentWeatherData.data[0].wind_spd);
|
currentWeather.windSpeed = parseFloat(currentWeatherData.data[0].wind_spd);
|
||||||
currentWeather.windDirection = currentWeatherData.data[0].wind_dir;
|
currentWeather.windDirection = currentWeatherData.data[0].wind_dir;
|
||||||
currentWeather.weatherType = this.convertWeatherType(currentWeatherData.data[0].weather.icon);
|
currentWeather.weatherType = this.convertWeatherType(currentWeatherData.data[0].weather.icon);
|
||||||
Log.log("Wx Icon: " + currentWeatherData.data[0].weather.icon);
|
|
||||||
currentWeather.sunrise = moment(currentWeatherData.data[0].sunrise, "HH:mm").add(tzOffset, "m");
|
currentWeather.sunrise = moment(currentWeatherData.data[0].sunrise, "HH:mm").add(tzOffset, "m");
|
||||||
currentWeather.sunset = moment(currentWeatherData.data[0].sunset, "HH:mm").add(tzOffset, "m");
|
currentWeather.sunset = moment(currentWeatherData.data[0].sunset, "HH:mm").add(tzOffset, "m");
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user