mirror of
https://github.com/MichMich/MagicMirror.git
synced 2025-06-26 03:52:28 +00:00
Thanks to: @Developer-Incoming, @eltociear, @geraki, @khassel, @KristjanESPERANTO, @MagMar94, @mixasgr, @n8many, @OWL4C, @rejas, @savvadam, @sdetweil. > ⚠️ This release needs nodejs version `v22.14.0 or higher` ### Added - Add CSS support to the digital clock hour/minute/second through the use of the classes `clock-hour-digital`, `clock-minute-digital`, and `clock-second-digital`. - Add Arabic (#3719) and Esperanto translation. - Mark option `secondsColor` as deprecated in clock module. - Add Greek translation to Alerts module. - [newsfeed] Add specific ignoreOlderThan value (override) per feed (#3360) - [weather] Added option Humidity to hourly View - [weather] Added option to hide hourly entries that are Zero, hiding the entire column if empty. - [updatenotification] Added option to iterate over modules directory instead using modules defined in `config.js` (#3739) ### Changed - [core] starting clientonly now checks for needed env var `WAYLAND_DISPLAY` or `DISPLAY` and starts electron with needed parameters (if both are set wayland is used) (#3677) - [core] Optimize systeminformation calls and output (#3689) - [core] Add issue templates for feature requests and bug reports (#3695) - [core] Adapt `start:x11:dev` script - [weather/yr] The Yr weather provider now enforces a minimum `updateInterval` of 600 000 ms (10 minutes) to comply with the terms of service. If a lower value is set, it will be automatically increased to this minimum. - [weather/weatherflow] Fixed icons and added hourly support as well as UV, precipitation, and location name support. - [workflow] Run `sudo apt-get update` before installing packages to avoid install errors - [workflow] Exclude issues with label `ready (coming with next release)` from stale job ### Removed ### Updated - [core] Update requirements and dependencies including electron to v35 and formatting (#3593, #3693, #3717) - [core] Update prettier, ESLint and simplify config - Update Greek translation ### Fixed - [calendar] Fix clipping events being broadcast (#3678) - [tests] Fix Electron tests by running them under new github image ubuntu-24.04, replace xserver with labwc, running under xserver and labwc depending on env variable WAYLAND_DISPLAY is set (#3676) - [calendar] Fix arrayed symbols, #3267, again, add testcase, add testcase for #3678 - [weather] Fix wrong weatherCondition name in openmeteo provider which lead to n/a icon (#3691) - [core] Fix wrong port in log message when starting server only (#3696) - [calendar] Fix NewYork event processed on system in Central timezone shows wrong time #3701 - [weather/yr] The Yr weather provider is now able to recover from bad API responses instead of freezing (#3296) - [compliments] Fix evening events being shown during the day (#3727) - [weather] Fixed minor spacing issues when using UV Index in Hourly - [workflow] Fix command to run spellcheck --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: Michael Teeuw <michael@xonaymedia.nl> Co-authored-by: Kristjan ESPERANTO <35647502+KristjanESPERANTO@users.noreply.github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Karsten Hassel <hassel@gmx.de> Co-authored-by: Ross Younger <crazyscot@gmail.com> Co-authored-by: Bugsounet - Cédric <github@bugsounet.fr> Co-authored-by: jkriegshauser <joshuakr@nvidia.com> Co-authored-by: illimarkangur <116028111+illimarkangur@users.noreply.github.com> Co-authored-by: sam detweiler <sdetweil@gmail.com> Co-authored-by: vppencilsharpener <tim.pray@gmail.com> Co-authored-by: Paranoid93 <6515818+Paranoid93@users.noreply.github.com> Co-authored-by: Brian O'Connor <btoconnor@users.noreply.github.com> Co-authored-by: WallysWellies <59727507+WallysWellies@users.noreply.github.com> Co-authored-by: Jason Stieber <jrstieber@gmail.com> Co-authored-by: jargordon <50050429+jargordon@users.noreply.github.com> Co-authored-by: Daniel <32464403+dkallen78@users.noreply.github.com> Co-authored-by: Ryan Williams <65094007+ryan-d-williams@users.noreply.github.com> Co-authored-by: Panagiotis Skias <panagiotis.skias@gmail.com> Co-authored-by: Marc Landis <dirk.rettschlag@gmail.com> Co-authored-by: HeikoGr <20295490+HeikoGr@users.noreply.github.com> Co-authored-by: Pedro Lamas <pedrolamas@gmail.com> Co-authored-by: veeck <gitkraken@veeck.de> Co-authored-by: Magnus <34011212+MagMar94@users.noreply.github.com> Co-authored-by: Ikko Eltociear Ashimine <eltociear@gmail.com> Co-authored-by: DevIncomin <56730075+Developer-Incoming@users.noreply.github.com> Co-authored-by: Nathan <n8nyoung@gmail.com> Co-authored-by: mixasgr <mixasgr@users.noreply.github.com> Co-authored-by: Savvas Adamtziloglou <savvas-gr@greeklug.gr> Co-authored-by: Konstantinos <geraki@gmail.com> Co-authored-by: OWL4C <124401812+OWL4C@users.noreply.github.com>
151 lines
5.3 KiB
JavaScript
151 lines
5.3 KiB
JavaScript
/* global WeatherProvider, WeatherObject, WeatherUtils */
|
|
|
|
/*
|
|
* This class is a provider for Weatherflow.
|
|
* Note that the Weatherflow API does not provide snowfall.
|
|
*/
|
|
WeatherProvider.register("weatherflow", {
|
|
|
|
/*
|
|
* Set the name of the provider.
|
|
* Not strictly required, but helps for debugging
|
|
*/
|
|
providerName: "WeatherFlow",
|
|
|
|
// Set the default config properties that is specific to this provider
|
|
defaults: {
|
|
apiBase: "https://swd.weatherflow.com/swd/rest/",
|
|
token: "",
|
|
stationid: ""
|
|
},
|
|
|
|
fetchCurrentWeather () {
|
|
this.fetchData(this.getUrl())
|
|
.then((data) => {
|
|
const currentWeather = new WeatherObject();
|
|
currentWeather.date = moment();
|
|
|
|
// Other available values: air_density, brightness, delta_t, dew_point,
|
|
// pressure_trend (i.e. rising/falling), sea_level_pressure, wind gust, and more.
|
|
|
|
currentWeather.humidity = data.current_conditions.relative_humidity;
|
|
currentWeather.temperature = data.current_conditions.air_temperature;
|
|
currentWeather.feelsLikeTemp = data.current_conditions.feels_like;
|
|
currentWeather.windSpeed = WeatherUtils.convertWindToMs(data.current_conditions.wind_avg);
|
|
currentWeather.windFromDirection = data.current_conditions.wind_direction;
|
|
currentWeather.weatherType = this.convertWeatherType(data.current_conditions.icon);
|
|
currentWeather.uv_index = data.current_conditions.uv;
|
|
currentWeather.sunrise = moment.unix(data.forecast.daily[0].sunrise);
|
|
currentWeather.sunset = moment.unix(data.forecast.daily[0].sunset);
|
|
this.setCurrentWeather(currentWeather);
|
|
this.fetchedLocationName = data.location_name;
|
|
})
|
|
.catch(function (request) {
|
|
Log.error("Could not load data ... ", request);
|
|
})
|
|
.finally(() => this.updateAvailable());
|
|
},
|
|
|
|
fetchWeatherForecast () {
|
|
this.fetchData(this.getUrl())
|
|
.then((data) => {
|
|
const days = [];
|
|
|
|
for (const forecast of data.forecast.daily) {
|
|
const weather = new WeatherObject();
|
|
|
|
weather.date = moment.unix(forecast.day_start_local);
|
|
weather.minTemperature = forecast.air_temp_low;
|
|
weather.maxTemperature = forecast.air_temp_high;
|
|
weather.precipitationProbability = forecast.precip_probability;
|
|
weather.weatherType = this.convertWeatherType(forecast.icon);
|
|
|
|
// Must manually build UV and Precipitation from hourly
|
|
weather.precipitationAmount = 0.0; // This will sum up rain and snow
|
|
weather.precipitationUnits = "mm";
|
|
weather.uv_index = 0;
|
|
|
|
for (const hour of data.forecast.hourly) {
|
|
const hour_time = moment.unix(hour.time);
|
|
if (hour_time.day() === weather.date.day()) { // Iterate though until day is reached
|
|
// Get data from today
|
|
weather.uv_index = Math.max(weather.uv_index, hour.uv);
|
|
weather.precipitationAmount += (hour.precip ?? 0);
|
|
} else if (hour_time.diff(weather.date) >= 86400) {
|
|
break; // No more data to be found
|
|
}
|
|
}
|
|
days.push(weather);
|
|
}
|
|
this.setWeatherForecast(days);
|
|
this.fetchedLocationName = data.location_name;
|
|
})
|
|
.catch(function (request) {
|
|
Log.error("Could not load data ... ", request);
|
|
})
|
|
.finally(() => this.updateAvailable());
|
|
},
|
|
|
|
fetchWeatherHourly () {
|
|
this.fetchData(this.getUrl())
|
|
.then((data) => {
|
|
const hours = [];
|
|
for (const hour of data.forecast.hourly) {
|
|
const weather = new WeatherObject();
|
|
|
|
weather.date = moment.unix(hour.time);
|
|
weather.temperature = hour.air_temperature;
|
|
weather.feelsLikeTemp = hour.feels_like;
|
|
weather.humidity = hour.relative_humidity;
|
|
weather.windSpeed = hour.wind_avg;
|
|
weather.windFromDirection = hour.wind_direction;
|
|
weather.weatherType = this.convertWeatherType(hour.icon);
|
|
weather.precipitationProbability = hour.precip_probability;
|
|
weather.precipitationAmount = hour.precip; // NOTE: precipitation type is available
|
|
weather.precipitationUnits = "mm"; // Hardcoded via request, TODO: Add conversion
|
|
weather.uv_index = hour.uv;
|
|
|
|
hours.push(weather);
|
|
if (hours.length >= 48) break; // 10 days of hours are available, best to trim down.
|
|
}
|
|
this.setWeatherHourly(hours);
|
|
this.fetchedLocationName = data.location_name;
|
|
})
|
|
.catch(function (request) {
|
|
Log.error("Could not load data ... ", request);
|
|
})
|
|
.finally(() => this.updateAvailable());
|
|
},
|
|
|
|
convertWeatherType (weatherType) {
|
|
const weatherTypes = {
|
|
"clear-day": "day-sunny",
|
|
"clear-night": "night-clear",
|
|
cloudy: "cloudy",
|
|
foggy: "fog",
|
|
"partly-cloudy-day": "day-cloudy",
|
|
"partly-cloudy-night": "night-alt-cloudy",
|
|
"possibly-rainy-day": "day-rain",
|
|
"possibly-rainy-night": "night-alt-rain",
|
|
"possibly-sleet-day": "day-sleet",
|
|
"possibly-sleet-night": "night-alt-sleet",
|
|
"possibly-snow-day": "day-snow",
|
|
"possibly-snow-night": "night-alt-snow",
|
|
"possibly-thunderstorm-day": "day-thunderstorm",
|
|
"possibly-thunderstorm-night": "night-alt-thunderstorm",
|
|
rainy: "rain",
|
|
sleet: "sleet",
|
|
snow: "snow",
|
|
thunderstorm: "thunderstorm",
|
|
windy: "strong-wind"
|
|
};
|
|
|
|
return weatherTypes.hasOwnProperty(weatherType) ? weatherTypes[weatherType] : null;
|
|
},
|
|
|
|
// Create a URL from the config and base URL.
|
|
getUrl () {
|
|
return `${this.config.apiBase}better_forecast?station_id=${this.config.stationid}&units_temp=c&units_wind=kph&units_pressure=mb&units_precip=mm&units_distance=km&token=${this.config.token}`;
|
|
}
|
|
});
|