mirror of
https://github.com/MichMich/MagicMirror.git
synced 2025-06-28 04:02:12 +00:00
feat(weather/smhi): support custom location names
This commit is contained in:
parent
48756e8774
commit
0a1067ec7d
@ -17,7 +17,8 @@ WeatherProvider.register("smhi", {
|
|||||||
defaults: {
|
defaults: {
|
||||||
lat: 0,
|
lat: 0,
|
||||||
lon: 0,
|
lon: 0,
|
||||||
precipitationValue: "pmedian"
|
precipitationValue: "pmedian",
|
||||||
|
location: false,
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -29,7 +30,7 @@ WeatherProvider.register("smhi", {
|
|||||||
let closest = this.getClosestToCurrentTime(data.timeSeries);
|
let closest = this.getClosestToCurrentTime(data.timeSeries);
|
||||||
let coordinates = this.resolveCoordinates(data);
|
let coordinates = this.resolveCoordinates(data);
|
||||||
let weatherObject = this.convertWeatherDataToObject(closest, coordinates);
|
let weatherObject = this.convertWeatherDataToObject(closest, coordinates);
|
||||||
this.setFetchedLocation(`(${coordinates.lat},${coordinates.lon})`);
|
this.setFetchedLocation(this.config.location || `(${coordinates.lat},${coordinates.lon})`);
|
||||||
this.setCurrentWeather(weatherObject);
|
this.setCurrentWeather(weatherObject);
|
||||||
})
|
})
|
||||||
.catch((error) => Log.error("Could not load data: " + error.message))
|
.catch((error) => Log.error("Could not load data: " + error.message))
|
||||||
@ -43,8 +44,8 @@ WeatherProvider.register("smhi", {
|
|||||||
this.fetchData(this.getURL())
|
this.fetchData(this.getURL())
|
||||||
.then((data) => {
|
.then((data) => {
|
||||||
let coordinates = this.resolveCoordinates(data);
|
let coordinates = this.resolveCoordinates(data);
|
||||||
const weatherObjects = this.convertWeatherDataGroupedBy(data.timeSeries, coordinates);
|
let weatherObjects = this.convertWeatherDataGroupedBy(data.timeSeries, coordinates);
|
||||||
this.setFetchedLocation(`(${coordinates.lat},${coordinates.lon})`);
|
this.setFetchedLocation(this.config.location || `(${coordinates.lat},${coordinates.lon})`);
|
||||||
this.setWeatherForecast(weatherObjects);
|
this.setWeatherForecast(weatherObjects);
|
||||||
})
|
})
|
||||||
.catch((error) => Log.error("Could not load data: " + error.message))
|
.catch((error) => Log.error("Could not load data: " + error.message))
|
||||||
@ -59,7 +60,7 @@ WeatherProvider.register("smhi", {
|
|||||||
.then((data) => {
|
.then((data) => {
|
||||||
let coordinates = this.resolveCoordinates(data);
|
let coordinates = this.resolveCoordinates(data);
|
||||||
let weatherObjects = this.convertWeatherDataGroupedBy(data.timeSeries, coordinates, "hour");
|
let weatherObjects = this.convertWeatherDataGroupedBy(data.timeSeries, coordinates, "hour");
|
||||||
this.setFetchedLocation(`(${coordinates.lat},${coordinates.lon})`);
|
this.setFetchedLocation(this.config.location || `(${coordinates.lat},${coordinates.lon})`);
|
||||||
this.setWeatherHourly(weatherObjects);
|
this.setWeatherHourly(weatherObjects);
|
||||||
})
|
})
|
||||||
.catch((error) => Log.error("Could not load data: " + error.message))
|
.catch((error) => Log.error("Could not load data: " + error.message))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user