mirror of
https://github.com/MichMich/MagicMirror.git
synced 2025-06-27 19:53:36 +00:00
## [2.27.0] - 2024-04-01 Thanks to: @bugsounet, @crazyscot, @illimarkangur, @jkriegshauser, @khassel, @KristjanESPERANTO, @Paranoid93, @rejas, @sdetweil and @vppencilsharpener. This release marks the first release without Michael Teeuw (@michmich). A very special thanks to him for creating MagicMirror and leading the project for so many years. 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 - Output of system information to the console for troubleshooting (#3328 and #3337), ignore errors under aarch64 (#3349) - [chore] Add `eslint-plugin-package-json` to lint the `package.json` files (#3368) - [weather] `showHumidity` config is now a string describing where to show this element. Supported values: "wind", "temp", "feelslike", "below", "none". (#3330) - electron-rebuild test suite for electron and 3rd party modules compatibility (#3392) - Create MM² icon and attach it to electron process (#3407) ### Updated - Update updatenotification (update_helper.js): Recode with pm2 library (#3332) - Removing lodash dependency by replacing merge by spread operator (#3339) - Use node prefix for build-in modules (#3340) - Rework logging colors (#3350) - Update pm2 to v5.3.1 with no allow-ghsas (#3364) - [chore] Update husky and let lint-staged fix ESLint issues - [chore] Update dependencies including electron to v29 (#3357) and node-ical - Update translations for estonian (#3371) - Update electron to v29 and update other dependencies - [calendar] fullDay events over several days now show the left days from the first day on and 'today' on the last day - Update layout of current weather indoor values ### Fixed - Correct apibase of weathergov weatherprovider to match documentation (#2926) - Worked around several issues in the RRULE library that were causing deleted calender events to still show, some initial and recurring events to not show, and some event times to be off an hour. (#3291) - Skip changelog requirement when running tests for dependency updates (#3320) - Display precipitation probability when it is 0% instead of blank/empty (#3345) - [newsfeed] Suppress unsightly animation cases when there are 0 or 1 active news items (#3336) - [newsfeed] Always compute the feed item URL using the same helper function (#3336) - Ignore all custom css files (#3359) - [newsfeed] Fix newsfeed stall issue introduced by #3336 (#3361) - Changed `log.debug` to `log.log` in `app.js` where logLevel is not set because config is not loaded at this time (#3353) - [calendar] deny fetch interval < 60000 and set 60000 in this case (prevent fetch loop failed) (#3382) - added message in case where config.js is missing the module.export line PR #3383 - Fixed an issue where recurring events could extend past their recurrence end date (#3393) - Don't display any `npm WARN <....>` on install (#3399) - Fixed move suncalc dependency to production from dev, as it is used by clock module - [compliments] Fix mirror not responding anymore when no compliments are to be shown (#3385) ### Deleted - Unneeded file headers (#3358) --------- 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>
166 lines
5.5 KiB
JavaScript
166 lines
5.5 KiB
JavaScript
/* global Class, performWebRequest, OverrideWrapper */
|
|
|
|
// This class is the blueprint for a weather provider.
|
|
const WeatherProvider = Class.extend({
|
|
// Weather Provider Properties
|
|
providerName: null,
|
|
defaults: {},
|
|
|
|
// The following properties have accessor methods.
|
|
// Try to not access them directly.
|
|
currentWeatherObject: null,
|
|
weatherForecastArray: null,
|
|
weatherHourlyArray: null,
|
|
fetchedLocationName: null,
|
|
|
|
// The following properties will be set automatically.
|
|
// You do not need to overwrite these properties.
|
|
config: null,
|
|
delegate: null,
|
|
providerIdentifier: null,
|
|
|
|
// Weather Provider Methods
|
|
// All the following methods can be overwritten, although most are good as they are.
|
|
|
|
// Called when a weather provider is initialized.
|
|
init (config) {
|
|
this.config = config;
|
|
Log.info(`Weather provider: ${this.providerName} initialized.`);
|
|
},
|
|
|
|
// Called to set the config, this config is the same as the weather module's config.
|
|
setConfig (config) {
|
|
this.config = config;
|
|
Log.info(`Weather provider: ${this.providerName} config set.`, this.config);
|
|
},
|
|
|
|
// Called when the weather provider is about to start.
|
|
start () {
|
|
Log.info(`Weather provider: ${this.providerName} started.`);
|
|
},
|
|
|
|
// This method should start the API request to fetch the current weather.
|
|
// This method should definitely be overwritten in the provider.
|
|
fetchCurrentWeather () {
|
|
Log.warn(`Weather provider: ${this.providerName} does not subclass the fetchCurrentWeather method.`);
|
|
},
|
|
|
|
// This method should start the API request to fetch the weather forecast.
|
|
// This method should definitely be overwritten in the provider.
|
|
fetchWeatherForecast () {
|
|
Log.warn(`Weather provider: ${this.providerName} does not subclass the fetchWeatherForecast method.`);
|
|
},
|
|
|
|
// This method should start the API request to fetch the weather hourly.
|
|
// This method should definitely be overwritten in the provider.
|
|
fetchWeatherHourly () {
|
|
Log.warn(`Weather provider: ${this.providerName} does not subclass the fetchWeatherHourly method.`);
|
|
},
|
|
|
|
// This returns a WeatherDay object for the current weather.
|
|
currentWeather () {
|
|
return this.currentWeatherObject;
|
|
},
|
|
|
|
// This returns an array of WeatherDay objects for the weather forecast.
|
|
weatherForecast () {
|
|
return this.weatherForecastArray;
|
|
},
|
|
|
|
// This returns an object containing WeatherDay object(s) depending on the type of call.
|
|
weatherHourly () {
|
|
return this.weatherHourlyArray;
|
|
},
|
|
|
|
// This returns the name of the fetched location or an empty string.
|
|
fetchedLocation () {
|
|
return this.fetchedLocationName || "";
|
|
},
|
|
|
|
// Set the currentWeather and notify the delegate that new information is available.
|
|
setCurrentWeather (currentWeatherObject) {
|
|
// We should check here if we are passing a WeatherDay
|
|
this.currentWeatherObject = currentWeatherObject;
|
|
},
|
|
|
|
// Set the weatherForecastArray and notify the delegate that new information is available.
|
|
setWeatherForecast (weatherForecastArray) {
|
|
// We should check here if we are passing a WeatherDay
|
|
this.weatherForecastArray = weatherForecastArray;
|
|
},
|
|
|
|
// Set the weatherHourlyArray and notify the delegate that new information is available.
|
|
setWeatherHourly (weatherHourlyArray) {
|
|
this.weatherHourlyArray = weatherHourlyArray;
|
|
},
|
|
|
|
// Set the fetched location name.
|
|
setFetchedLocation (name) {
|
|
this.fetchedLocationName = name;
|
|
},
|
|
|
|
// Notify the delegate that new weather is available.
|
|
updateAvailable () {
|
|
this.delegate.updateAvailable(this);
|
|
},
|
|
|
|
/**
|
|
* A convenience function to make requests.
|
|
* @param {string} url the url to fetch from
|
|
* @param {string} type what contenttype to expect in the response, can be "json" or "xml"
|
|
* @param {Array.<{name: string, value:string}>} requestHeaders the HTTP headers to send
|
|
* @param {Array.<string>} expectedResponseHeaders the expected HTTP headers to recieve
|
|
* @returns {Promise} resolved when the fetch is done
|
|
*/
|
|
async fetchData (url, type = "json", requestHeaders = undefined, expectedResponseHeaders = undefined) {
|
|
const mockData = this.config.mockData;
|
|
if (mockData) {
|
|
const data = mockData.substring(1, mockData.length - 1);
|
|
return JSON.parse(data);
|
|
}
|
|
const useCorsProxy = typeof this.config.useCorsProxy !== "undefined" && this.config.useCorsProxy;
|
|
return performWebRequest(url, type, useCorsProxy, requestHeaders, expectedResponseHeaders);
|
|
}
|
|
});
|
|
|
|
/**
|
|
* Collection of registered weather providers.
|
|
*/
|
|
WeatherProvider.providers = [];
|
|
|
|
/**
|
|
* Static method to register a new weather provider.
|
|
* @param {string} providerIdentifier The name of the weather provider
|
|
* @param {object} providerDetails The details of the weather provider
|
|
*/
|
|
WeatherProvider.register = function (providerIdentifier, providerDetails) {
|
|
WeatherProvider.providers[providerIdentifier.toLowerCase()] = WeatherProvider.extend(providerDetails);
|
|
};
|
|
|
|
/**
|
|
* Static method to initialize a new weather provider.
|
|
* @param {string} providerIdentifier The name of the weather provider
|
|
* @param {object} delegate The weather module
|
|
* @returns {object} The new weather provider
|
|
*/
|
|
WeatherProvider.initialize = function (providerIdentifier, delegate) {
|
|
const pi = providerIdentifier.toLowerCase();
|
|
|
|
const provider = new WeatherProvider.providers[pi]();
|
|
const config = Object.assign({}, provider.defaults, delegate.config);
|
|
|
|
provider.delegate = delegate;
|
|
provider.setConfig(config);
|
|
|
|
provider.providerIdentifier = pi;
|
|
if (!provider.providerName) {
|
|
provider.providerName = pi;
|
|
}
|
|
|
|
if (config.allowOverrideNotification) {
|
|
return new OverrideWrapper(provider);
|
|
}
|
|
|
|
return provider;
|
|
};
|