Release 2.26.0 (#3319)

## [2.26.0] - 01-01-2024

Thanks to: @bnitkin, @bugsounet, @dependabot, @jkriegshauser,
@kaennchenstruggle, @KristjanESPERANTO and @Ybbet.

Special thanks to @khassel, @rejas and @sdetweil for taking over most
(if not all) of the work on this release as project collaborators. This
version would not be there without their effort. Thank you guys! You are
awesome!

This release also marks the latest release by Michael Teeuw. For more
info, please read the following post: [A New Chapter for MagicMirror:
The Community Takes the
Lead](https://forum.magicmirror.builders/topic/18329/a-new-chapter-for-magicmirror-the-community-takes-the-lead).

### Added

- Added update notification updater (for 3rd party modules)
- Added node 21 to the test matrix
- Added transform object to calendar:customEvents
- Added ESLint rules for jest (including jest/expect-expect and
jest/no-done-callback)

### Removed

- Removed Codecov workflow (not working anymore, other workflow
required) (#3107)
- Removed titleReplace from calendar, replaced + extended by
customEvents (backward compatibility included) (#3249)
- Removed failing unit test (#3254)
- Removed some unused variables

### Updated

- Update electron to v27 and update other dependencies as well as github
actions
- Update newsfeed: Use `html-to-text` instead of regex for transform
description
- Review ESLint config (#3269)
- Updated dependencies
- Clock module: optionally display current moon phase in addition to
rise/set times
- electron is now per default started without gpu, if needed it must be
enabled with new env var `ELECTRON_ENABLE_GPU=1` on startup (#3226)
- Replace prettier by stylistic in ESLint config to lint JavaScript (and
disable some rules for `config/config.js*` files)
- Update node-ical to v0.17.1 and fix tests

### Fixed

- Avoid fade out/in on updateDom when many calendars are used
- Fix the option eventClass on customEvents.
- Fix yr API version in locationforecast and sunrise call (#3227)
- Fix cloneObject() function to respect RegExp (#3237)
- Fix newsfeed module for feeds using "a10:updated" tag (#3238)
- Fix issue template (#3167)
- Fix #3256 filter out bad results from rrule.between
- Fix calendar events sometimes not respecting deleted events (#3250)
- Fix electron loadurl locally on Windows when address "0.0.0.0" (#2550)
- Fix updatanotification (update_helper.js): catch error if reponse is
not an JSON format (check PM2)
- Fix missing typeof in calendar module
- Fix style issues after prettier update
- Fix calendar test (#3291) by moving "Exdate check" from e2e to
electron to run on a Thursday
- Fix calendar config params `fetchInterval` and `excludedEvents` were
never used from single calendar config (#3297)
- Fix MM_PORT variable not used in electron and allow full path for
MM_CONFIG_FILE variable (#3302)

---------

Signed-off-by: naveen <172697+naveensrinivasan@users.noreply.github.com>
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: Karsten Hassel <hassel@gmx.de>
Co-authored-by: Malte Hallström <46646495+SkySails@users.noreply.github.com>
Co-authored-by: Veeck <github@veeck.de>
Co-authored-by: veeck <michael@veeck.de>
Co-authored-by: dWoolridge <dwoolridge@charter.net>
Co-authored-by: Johan <jojjepersson@yahoo.se>
Co-authored-by: Dario Mratovich <dario_mratovich@hotmail.com>
Co-authored-by: Dario Mratovich <dario.mratovich@outlook.com>
Co-authored-by: Magnus <34011212+MagMar94@users.noreply.github.com>
Co-authored-by: Naveen <172697+naveensrinivasan@users.noreply.github.com>
Co-authored-by: buxxi <buxxi@omfilm.net>
Co-authored-by: Thomas Hirschberger <47733292+Tom-Hirschberger@users.noreply.github.com>
Co-authored-by: Kristjan ESPERANTO <35647502+KristjanESPERANTO@users.noreply.github.com>
Co-authored-by: Andrés Vanegas Jiménez <142350+angeldeejay@users.noreply.github.com>
Co-authored-by: Dave Child <dave@addedbytes.com>
Co-authored-by: grenagit <46225780+grenagit@users.noreply.github.com>
Co-authored-by: Grena <grena@grenabox.fr>
Co-authored-by: Magnus Marthinsen <magmar@online.no>
Co-authored-by: Patrick <psieg@users.noreply.github.com>
Co-authored-by: Piotr Rajnisz <56397164+rajniszp@users.noreply.github.com>
Co-authored-by: Suthep Yonphimai <tomzt@users.noreply.github.com>
Co-authored-by: CarJem Generations (Carter Wallace) <cwallacecs@gmail.com>
Co-authored-by: Nicholas Fogal <nfogal.misc@gmail.com>
Co-authored-by: JakeBinney <126349119+JakeBinney@users.noreply.github.com>
Co-authored-by: OWL4C <124401812+OWL4C@users.noreply.github.com>
Co-authored-by: Oscar Björkman <17575446+oscarb@users.noreply.github.com>
Co-authored-by: Ismar Slomic <ismar@slomic.no>
Co-authored-by: Jørgen Veum-Wahlberg <jorgen.wahlberg@amedia.no>
Co-authored-by: Eddie Hung <6740044+eddiehung@users.noreply.github.com>
Co-authored-by: Bugsounet - Cédric <github@bugsounet.fr>
Co-authored-by: bugsounet <bugsounet@bugsounet.fr>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Knapoc <Knapoc@users.noreply.github.com>
Co-authored-by: sam detweiler <sdetweil@gmail.com>
Co-authored-by: veeck <michael.veeck@nebenan.de>
Co-authored-by: Paranoid93 <6515818+Paranoid93@users.noreply.github.com>
Co-authored-by: NolanKingdon <27908974+NolanKingdon@users.noreply.github.com>
Co-authored-by: J. Kenzal Hunter <kenzal.hunter@gmail.com>
Co-authored-by: Teddy <teddy.payet@gmail.com>
Co-authored-by: TeddyStarinvest <teddy.payet@starinvest.com>
Co-authored-by: martingron <61826403+martingron@users.noreply.github.com>
Co-authored-by: dgoth <132394363+dgoth@users.noreply.github.com>
Co-authored-by: kaennchenstruggle <54073894+kaennchenstruggle@users.noreply.github.com>
Co-authored-by: jkriegshauser <jkriegshauser@gmail.com>
Co-authored-by: Ben Nitkin <ben@nitkin.net>
This commit is contained in:
Michael Teeuw
2024-01-01 15:38:08 +01:00
committed by GitHub
parent 343e7de7bd
commit 8c0e7db494
110 changed files with 3433 additions and 2915 deletions

View File

@@ -18,11 +18,13 @@ WeatherProvider.register("yr", {
defaults: {
useCorsProxy: true,
apiBase: "https://api.met.no/weatherapi",
forecastApiVersion: "2.0",
sunriseApiVersion: "3.0",
altitude: 0,
currentForecastHours: 1 //1, 6 or 12
},
start() {
start () {
if (typeof Storage === "undefined") {
//local storage unavailable
Log.error("The Yr weather provider requires local storage.");
@@ -31,7 +33,7 @@ WeatherProvider.register("yr", {
Log.info(`Weather provider: ${this.providerName} started.`);
},
fetchCurrentWeather() {
fetchCurrentWeather () {
this.getCurrentWeather()
.then((currentWeather) => {
this.setCurrentWeather(currentWeather);
@@ -43,9 +45,8 @@ WeatherProvider.register("yr", {
});
},
async getCurrentWeather() {
const getRequests = [this.getWeatherData(), this.getStellarData()];
const [weatherData, stellarData] = await Promise.all(getRequests);
async getCurrentWeather () {
const [weatherData, stellarData] = await Promise.all([this.getWeatherData(), this.getStellarData()]);
if (!stellarData) {
Log.warn("No stellar data available.");
}
@@ -72,7 +73,7 @@ WeatherProvider.register("yr", {
return this.getWeatherDataFrom(forecast, stellarData, weatherData.properties.meta.units);
},
getWeatherData() {
getWeatherData () {
return new Promise((resolve, reject) => {
// If a user has several Yr-modules, for instance one current and one forecast, the API calls must be synchronized across classes.
// This is to avoid multiple similar calls to the API.
@@ -98,7 +99,7 @@ WeatherProvider.register("yr", {
});
},
getWeatherDataFromYrOrCache(resolve, reject) {
getWeatherDataFromYrOrCache (resolve, reject) {
localStorage.setItem("yrIsFetchingWeatherData", "true");
let weatherData = this.getWeatherDataFromCache();
@@ -130,16 +131,16 @@ WeatherProvider.register("yr", {
}
},
weatherDataIsValid(weatherData) {
weatherDataIsValid (weatherData) {
return (
weatherData &&
weatherData.timeout &&
0 < moment(weatherData.timeout).diff(moment()) &&
(!weatherData.geometry || !weatherData.geometry.coordinates || !weatherData.geometry.coordinates.length < 2 || (weatherData.geometry.coordinates[0] === this.config.lat && weatherData.geometry.coordinates[1] === this.config.lon))
weatherData
&& weatherData.timeout
&& 0 < moment(weatherData.timeout).diff(moment())
&& (!weatherData.geometry || !weatherData.geometry.coordinates || !weatherData.geometry.coordinates.length < 2 || (weatherData.geometry.coordinates[0] === this.config.lat && weatherData.geometry.coordinates[1] === this.config.lon))
);
},
getWeatherDataFromCache() {
getWeatherDataFromCache () {
const weatherData = localStorage.getItem("weatherData");
if (weatherData) {
return JSON.parse(weatherData);
@@ -148,7 +149,7 @@ WeatherProvider.register("yr", {
}
},
getWeatherDataFromYr(currentDataFetchedAt) {
getWeatherDataFromYr (currentDataFetchedAt) {
const requestHeaders = [{ name: "Accept", value: "application/json" }];
if (currentDataFetchedAt) {
requestHeaders.push({ name: "If-Modified-Since", value: currentDataFetchedAt });
@@ -170,7 +171,7 @@ WeatherProvider.register("yr", {
});
},
getForecastUrl() {
getConfigOptions () {
if (!this.config.lat) {
Log.error("Latitude not provided.");
throw new Error("Latitude not provided.");
@@ -183,6 +184,11 @@ WeatherProvider.register("yr", {
let lat = this.config.lat.toString();
let lon = this.config.lon.toString();
const altitude = this.config.altitude ?? 0;
return { lat, lon, altitude };
},
getForecastUrl () {
let { lat, lon, altitude } = this.getConfigOptions();
if (lat.includes(".") && lat.split(".")[1].length > 4) {
Log.warn("Latitude is too specific for weather data. Do not use more than four decimals. Trimming to maximum length.");
@@ -195,19 +201,14 @@ WeatherProvider.register("yr", {
lon = `${lonParts[0]}.${lonParts[1].substring(0, 4)}`;
}
return `${this.config.apiBase}/locationforecast/2.0/complete?&altitude=${altitude}&lat=${lat}&lon=${lon}`;
return `${this.config.apiBase}/locationforecast/${this.config.forecastApiVersion}/complete?&altitude=${altitude}&lat=${lat}&lon=${lon}`;
},
cacheWeatherData(weatherData) {
cacheWeatherData (weatherData) {
localStorage.setItem("weatherData", JSON.stringify(weatherData));
},
getAuthenticationString() {
if (!this.config.authenticationEmail) throw new Error("Authentication email not provided.");
return `${this.config.applicaitionName} ${this.config.authenticationEmail}`;
},
getStellarData() {
getStellarData () {
// If a user has several Yr-modules, for instance one current and one forecast, the API calls must be synchronized across classes.
// This is to avoid multiple similar calls to the API.
return new Promise((resolve, reject) => {
@@ -233,7 +234,7 @@ WeatherProvider.register("yr", {
});
},
getStellarDataFromYrOrCache(resolve, reject) {
getStellarDataFromYrOrCache (resolve, reject) {
localStorage.setItem("yrIsFetchingStellarData", "true");
let stellarData = this.getStellarDataFromCache();
@@ -291,7 +292,7 @@ WeatherProvider.register("yr", {
}
},
getStellarDataFromCache() {
getStellarDataFromCache () {
const stellarData = localStorage.getItem("stellarData");
if (stellarData) {
return JSON.parse(stellarData);
@@ -300,9 +301,9 @@ WeatherProvider.register("yr", {
}
},
getStellarDataFromYr(date, days = 1) {
getStellarDataFromYr (date, days = 1) {
const requestHeaders = [{ name: "Accept", value: "application/json" }];
return this.fetchData(this.getStellarDatatUrl(date, days), "json", requestHeaders)
return this.fetchData(this.getStellarDataUrl(date, days), "json", requestHeaders)
.then((data) => {
Log.debug("Got stellar data from yr.");
return data;
@@ -313,19 +314,8 @@ WeatherProvider.register("yr", {
});
},
getStellarDatatUrl(date, days) {
if (!this.config.lat) {
Log.error("Latitude not provided.");
throw new Error("Latitude not provided.");
}
if (!this.config.lon) {
Log.error("Longitude not provided.");
throw new Error("Longitude not provided.");
}
let lat = this.config.lat.toString();
let lon = this.config.lon.toString();
const altitude = this.config.altitude ?? 0;
getStellarDataUrl (date, days) {
let { lat, lon, altitude } = this.getConfigOptions();
if (lat.includes(".") && lat.split(".")[1].length > 4) {
Log.warn("Latitude is too specific for stellar data. Do not use more than four decimals. Trimming to maximum length.");
@@ -352,14 +342,14 @@ WeatherProvider.register("yr", {
if (hours.length < 2) {
hours = `0${hours}`;
}
return `${this.config.apiBase}/sunrise/2.3/sun?lat=${lat}&lon=${lon}&date=${date}&offset=${utcOffsetPrefix}${hours}%3A${minutes}`;
return `${this.config.apiBase}/sunrise/${this.config.sunriseApiVersion}/sun?lat=${lat}&lon=${lon}&date=${date}&offset=${utcOffsetPrefix}${hours}%3A${minutes}`;
},
cacheStellarData(data) {
cacheStellarData (data) {
localStorage.setItem("stellarData", JSON.stringify(data));
},
getWeatherDataFrom(forecast, stellarData, units) {
getWeatherDataFrom (forecast, stellarData, units) {
const weather = new WeatherObject();
weather.date = moment(forecast.time);
@@ -380,7 +370,7 @@ WeatherProvider.register("yr", {
return weather;
},
convertWeatherType(weatherType, weatherTime) {
convertWeatherType (weatherType, weatherTime) {
const weatherHour = moment(weatherTime).format("HH");
const weatherTypes = {
@@ -472,16 +462,7 @@ WeatherProvider.register("yr", {
return weatherTypes.hasOwnProperty(weatherType) ? weatherTypes[weatherType] : null;
},
getStellarTimesFrom(stellarData, date) {
for (const time of stellarData.location.time) {
if (time.date === date) {
return time;
}
}
return undefined;
},
getForecastForXHoursFrom(weather) {
getForecastForXHoursFrom (weather) {
if (this.config.currentForecastHours === 1) {
if (weather.next_1_hours) {
return weather.next_1_hours;
@@ -509,7 +490,7 @@ WeatherProvider.register("yr", {
}
},
fetchWeatherHourly() {
fetchWeatherHourly () {
this.getWeatherForecast("hourly")
.then((forecast) => {
this.setWeatherHourly(forecast);
@@ -521,9 +502,8 @@ WeatherProvider.register("yr", {
});
},
async getWeatherForecast(type) {
const getRequests = [this.getWeatherData(), this.getStellarData()];
const [weatherData, stellarData] = await Promise.all(getRequests);
async getWeatherForecast (type) {
const [weatherData, stellarData] = await Promise.all([this.getWeatherData(), this.getStellarData()]);
if (!weatherData.properties.timeseries || !weatherData.properties.timeseries[0]) {
Log.error("No weather data available.");
return;
@@ -548,7 +528,7 @@ WeatherProvider.register("yr", {
return series;
},
getHourlyForecastFrom(weatherData) {
getHourlyForecastFrom (weatherData) {
const series = [];
for (const forecast of weatherData.properties.timeseries) {
@@ -563,7 +543,7 @@ WeatherProvider.register("yr", {
return series;
},
getDailyForecastFrom(weatherData) {
getDailyForecastFrom (weatherData) {
const series = [];
const days = weatherData.properties.timeseries.reduce(function (days, forecast) {
@@ -573,7 +553,7 @@ WeatherProvider.register("yr", {
return days;
}, Object.create(null));
Object.keys(days).forEach(function (time, index) {
Object.keys(days).forEach(function (time) {
let minTemperature = undefined;
let maxTemperature = undefined;
@@ -613,7 +593,7 @@ WeatherProvider.register("yr", {
return series;
},
fetchWeatherForecast() {
fetchWeatherForecast () {
this.getWeatherForecast("daily")
.then((forecast) => {
this.setWeatherForecast(forecast);