Release 2.22.0 (#2983)
## [2.22.0] - 2023-01-01
Thanks to: @angeldeejay, @buxxi, @dariom, @dWoolridge,
@KristjanESPERANTO, @MagMar94, @naveensrinivasan, @retroflex, @SkySails
and @Tom.
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!
### Added
- Added test for remoteFile option in compliments module
- Added hourlyWeather functionality to Weather.gov weather provider
- Removed weatherEndpoint definition from weathergov.js (not used)
- Added css class names "today" and "tomorrow" for default calendar
- Added Collaboration.md
- Added new github action for dependency review (#2862)
- Added a WeatherProvider for Open-Meteo
- Added Yr as a weather provider
- Added config options "ignoreXOriginHeader" and
"ignoreContentSecurityPolicy"
### Removed
- Removed usage of internal fetch function of node until it is more
stable
### Updated
- Cleaned up test directory (#2937) and jest config (#2959)
- Wait for all modules to start before declaring the system ready
(#2487)
- Updated e2e tests (moved `done()` in helper functions) and use es6
syntax in all tests
- Updated da translation
- Rework weather module
- Make sure smhi provider api only gets a maximum of 6 digits
coordinates (#2955)
- Use fetch instead of XMLHttpRequest in weatherprovider (#2935)
- Reworked how weatherproviders handle units (#2849)
- Use unix() method for parsing times, fix suntimes on the way (#2950)
- Refactor conversion functions into utils class (#2958)
- The `cors`-method in `server.js` now supports sending and recieving
HTTP headers
- Replace `…` by `…`
- Cleanup compliments module
- Updated dependencies including electron to v22 (#2903)
### Fixed
- Correctly show apparent temperature in SMHI weather provider
- Ensure updatenotification module isn't shown when local is _ahead_ of
remote
- Handle node_helper errors during startup (#2944)
- Possibility to change FontAwesome class in calendar, so icons like
`fab fa-facebook-square` works.
- Fix cors problems with newsfeed articles (as far as possible), allow
disabling cors per feed with option `useCorsProxy: false` (#2840)
- Tests not waiting for the application to start and stop before
starting the next test
- Fix electron tests failing sometimes in github workflow
- Fixed gap in clock module when displayed on the left side with
displayType=digital
- Fixed playwright issue by upgrading to v1.29.1 (#2969)
Signed-off-by: naveen <172697+naveensrinivasan@users.noreply.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>
2023-01-01 18:09:08 +01:00
|
|
|
/* global Class, performWebRequest */
|
2017-09-21 16:38:18 +02:00
|
|
|
|
2022-01-26 23:09:26 +01:00
|
|
|
/* MagicMirror²
|
2017-09-21 16:38:18 +02:00
|
|
|
* Module: Weather
|
|
|
|
*
|
2020-04-28 23:05:28 +02:00
|
|
|
* By Michael Teeuw https://michaelteeuw.nl
|
2017-09-21 16:38:18 +02:00
|
|
|
* MIT Licensed.
|
2017-10-18 13:38:56 +02:00
|
|
|
*
|
2017-09-21 16:38:18 +02:00
|
|
|
* This class is the blueprint for a weather provider.
|
|
|
|
*/
|
2021-04-18 14:53:15 +02:00
|
|
|
const WeatherProvider = Class.extend({
|
2017-09-21 16:38:18 +02:00
|
|
|
// Weather Provider Properties
|
|
|
|
providerName: null,
|
2021-01-23 11:21:56 +01:00
|
|
|
defaults: {},
|
2017-09-21 16:38:18 +02:00
|
|
|
|
2020-07-30 12:58:35 +02:00
|
|
|
// The following properties have accessor methods.
|
2017-09-21 16:38:18 +02:00
|
|
|
// Try to not access them directly.
|
2017-09-22 12:26:47 +02:00
|
|
|
currentWeatherObject: null,
|
2017-09-21 16:38:18 +02:00
|
|
|
weatherForecastArray: null,
|
2021-01-23 10:45:55 +01:00
|
|
|
weatherHourlyArray: null,
|
2018-12-27 17:13:06 +01:00
|
|
|
fetchedLocationName: null,
|
2017-09-21 16:38:18 +02:00
|
|
|
|
2019-06-05 09:46:59 +02:00
|
|
|
// The following properties will be set automatically.
|
2017-09-21 16:38:18 +02:00
|
|
|
// You do not need to overwrite these properties.
|
|
|
|
config: null,
|
|
|
|
delegate: null,
|
|
|
|
providerIdentifier: null,
|
|
|
|
|
|
|
|
// Weather Provider Methods
|
2019-06-05 09:46:59 +02:00
|
|
|
// All the following methods can be overwritten, although most are good as they are.
|
2017-09-21 16:38:18 +02:00
|
|
|
|
|
|
|
// Called when a weather provider is initialized.
|
2020-05-11 22:22:32 +02:00
|
|
|
init: function (config) {
|
2017-09-21 16:38:18 +02:00
|
|
|
this.config = config;
|
2018-12-27 19:37:02 +01:00
|
|
|
Log.info(`Weather provider: ${this.providerName} initialized.`);
|
2017-09-21 16:38:18 +02:00
|
|
|
},
|
|
|
|
|
|
|
|
// Called to set the config, this config is the same as the weather module's config.
|
2020-05-11 22:22:32 +02:00
|
|
|
setConfig: function (config) {
|
2018-12-27 19:37:02 +01:00
|
|
|
this.config = config;
|
|
|
|
Log.info(`Weather provider: ${this.providerName} config set.`, this.config);
|
2017-09-21 16:38:18 +02:00
|
|
|
},
|
|
|
|
|
|
|
|
// Called when the weather provider is about to start.
|
2020-05-11 22:22:32 +02:00
|
|
|
start: function () {
|
2018-12-27 19:37:02 +01:00
|
|
|
Log.info(`Weather provider: ${this.providerName} started.`);
|
2017-09-21 16:38:18 +02:00
|
|
|
},
|
|
|
|
|
|
|
|
// This method should start the API request to fetch the current weather.
|
2019-06-05 09:46:59 +02:00
|
|
|
// This method should definitely be overwritten in the provider.
|
2020-05-11 22:22:32 +02:00
|
|
|
fetchCurrentWeather: function () {
|
2018-12-27 19:37:02 +01:00
|
|
|
Log.warn(`Weather provider: ${this.providerName} does not subclass the fetchCurrentWeather method.`);
|
2017-09-21 16:38:18 +02:00
|
|
|
},
|
|
|
|
|
|
|
|
// This method should start the API request to fetch the weather forecast.
|
2019-06-05 09:46:59 +02:00
|
|
|
// This method should definitely be overwritten in the provider.
|
2020-05-11 22:22:32 +02:00
|
|
|
fetchWeatherForecast: function () {
|
2018-12-27 19:37:02 +01:00
|
|
|
Log.warn(`Weather provider: ${this.providerName} does not subclass the fetchWeatherForecast method.`);
|
2017-09-21 16:38:18 +02:00
|
|
|
},
|
|
|
|
|
2021-01-23 10:45:55 +01:00
|
|
|
// This method should start the API request to fetch the weather hourly.
|
2020-06-30 02:40:41 -04:00
|
|
|
// This method should definitely be overwritten in the provider.
|
2021-01-23 10:45:55 +01:00
|
|
|
fetchWeatherHourly: function () {
|
|
|
|
Log.warn(`Weather provider: ${this.providerName} does not subclass the fetchWeatherHourly method.`);
|
2020-06-30 02:40:41 -04:00
|
|
|
},
|
|
|
|
|
2017-09-21 16:38:18 +02:00
|
|
|
// This returns a WeatherDay object for the current weather.
|
2020-05-11 22:22:32 +02:00
|
|
|
currentWeather: function () {
|
2018-12-27 19:37:02 +01:00
|
|
|
return this.currentWeatherObject;
|
2017-09-21 16:38:18 +02:00
|
|
|
},
|
|
|
|
|
|
|
|
// This returns an array of WeatherDay objects for the weather forecast.
|
2020-05-11 22:22:32 +02:00
|
|
|
weatherForecast: function () {
|
2018-12-27 19:37:02 +01:00
|
|
|
return this.weatherForecastArray;
|
2017-09-21 16:38:18 +02:00
|
|
|
},
|
|
|
|
|
2020-06-30 02:40:41 -04:00
|
|
|
// This returns an object containing WeatherDay object(s) depending on the type of call.
|
2021-01-23 10:45:55 +01:00
|
|
|
weatherHourly: function () {
|
|
|
|
return this.weatherHourlyArray;
|
2020-06-30 02:40:41 -04:00
|
|
|
},
|
|
|
|
|
2018-12-30 20:46:25 +01:00
|
|
|
// This returns the name of the fetched location or an empty string.
|
2020-05-11 22:22:32 +02:00
|
|
|
fetchedLocation: function () {
|
2018-12-27 19:37:02 +01:00
|
|
|
return this.fetchedLocationName || "";
|
2018-12-27 17:13:06 +01:00
|
|
|
},
|
|
|
|
|
2017-09-22 13:26:44 +02:00
|
|
|
// Set the currentWeather and notify the delegate that new information is available.
|
2020-05-11 22:22:32 +02:00
|
|
|
setCurrentWeather: function (currentWeatherObject) {
|
2017-09-21 16:38:18 +02:00
|
|
|
// We should check here if we are passing a WeatherDay
|
2018-12-27 19:37:02 +01:00
|
|
|
this.currentWeatherObject = currentWeatherObject;
|
2017-09-21 16:38:18 +02:00
|
|
|
},
|
|
|
|
|
2017-09-22 13:26:44 +02:00
|
|
|
// Set the weatherForecastArray and notify the delegate that new information is available.
|
2020-05-11 22:22:32 +02:00
|
|
|
setWeatherForecast: function (weatherForecastArray) {
|
2017-09-22 13:26:44 +02:00
|
|
|
// We should check here if we are passing a WeatherDay
|
2018-12-27 19:37:02 +01:00
|
|
|
this.weatherForecastArray = weatherForecastArray;
|
2017-09-22 13:26:44 +02:00
|
|
|
},
|
|
|
|
|
2021-01-23 10:45:55 +01:00
|
|
|
// Set the weatherHourlyArray and notify the delegate that new information is available.
|
2021-01-23 11:40:02 +01:00
|
|
|
setWeatherHourly: function (weatherHourlyArray) {
|
2021-01-23 10:45:55 +01:00
|
|
|
this.weatherHourlyArray = weatherHourlyArray;
|
2020-06-30 02:40:41 -04:00
|
|
|
},
|
|
|
|
|
2018-12-30 20:46:25 +01:00
|
|
|
// Set the fetched location name.
|
2020-05-11 22:22:32 +02:00
|
|
|
setFetchedLocation: function (name) {
|
2018-12-27 19:37:02 +01:00
|
|
|
this.fetchedLocationName = name;
|
2018-12-27 17:13:06 +01:00
|
|
|
},
|
|
|
|
|
2017-09-21 16:38:18 +02:00
|
|
|
// Notify the delegate that new weather is available.
|
2020-05-11 22:22:32 +02:00
|
|
|
updateAvailable: function () {
|
2018-12-27 19:37:02 +01:00
|
|
|
this.delegate.updateAvailable(this);
|
2017-09-21 16:38:18 +02:00
|
|
|
},
|
|
|
|
|
Release 2.22.0 (#2983)
## [2.22.0] - 2023-01-01
Thanks to: @angeldeejay, @buxxi, @dariom, @dWoolridge,
@KristjanESPERANTO, @MagMar94, @naveensrinivasan, @retroflex, @SkySails
and @Tom.
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!
### Added
- Added test for remoteFile option in compliments module
- Added hourlyWeather functionality to Weather.gov weather provider
- Removed weatherEndpoint definition from weathergov.js (not used)
- Added css class names "today" and "tomorrow" for default calendar
- Added Collaboration.md
- Added new github action for dependency review (#2862)
- Added a WeatherProvider for Open-Meteo
- Added Yr as a weather provider
- Added config options "ignoreXOriginHeader" and
"ignoreContentSecurityPolicy"
### Removed
- Removed usage of internal fetch function of node until it is more
stable
### Updated
- Cleaned up test directory (#2937) and jest config (#2959)
- Wait for all modules to start before declaring the system ready
(#2487)
- Updated e2e tests (moved `done()` in helper functions) and use es6
syntax in all tests
- Updated da translation
- Rework weather module
- Make sure smhi provider api only gets a maximum of 6 digits
coordinates (#2955)
- Use fetch instead of XMLHttpRequest in weatherprovider (#2935)
- Reworked how weatherproviders handle units (#2849)
- Use unix() method for parsing times, fix suntimes on the way (#2950)
- Refactor conversion functions into utils class (#2958)
- The `cors`-method in `server.js` now supports sending and recieving
HTTP headers
- Replace `…` by `…`
- Cleanup compliments module
- Updated dependencies including electron to v22 (#2903)
### Fixed
- Correctly show apparent temperature in SMHI weather provider
- Ensure updatenotification module isn't shown when local is _ahead_ of
remote
- Handle node_helper errors during startup (#2944)
- Possibility to change FontAwesome class in calendar, so icons like
`fab fa-facebook-square` works.
- Fix cors problems with newsfeed articles (as far as possible), allow
disabling cors per feed with option `useCorsProxy: false` (#2840)
- Tests not waiting for the application to start and stop before
starting the next test
- Fix electron tests failing sometimes in github workflow
- Fixed gap in clock module when displayed on the left side with
displayType=digital
- Fixed playwright issue by upgrading to v1.29.1 (#2969)
Signed-off-by: naveen <172697+naveensrinivasan@users.noreply.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>
2023-01-01 18:09:08 +01:00
|
|
|
/**
|
|
|
|
* 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
|
|
|
|
*/
|
|
|
|
fetchData: async function (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);
|
2022-01-25 22:30:16 +01:00
|
|
|
}
|
Release 2.22.0 (#2983)
## [2.22.0] - 2023-01-01
Thanks to: @angeldeejay, @buxxi, @dariom, @dWoolridge,
@KristjanESPERANTO, @MagMar94, @naveensrinivasan, @retroflex, @SkySails
and @Tom.
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!
### Added
- Added test for remoteFile option in compliments module
- Added hourlyWeather functionality to Weather.gov weather provider
- Removed weatherEndpoint definition from weathergov.js (not used)
- Added css class names "today" and "tomorrow" for default calendar
- Added Collaboration.md
- Added new github action for dependency review (#2862)
- Added a WeatherProvider for Open-Meteo
- Added Yr as a weather provider
- Added config options "ignoreXOriginHeader" and
"ignoreContentSecurityPolicy"
### Removed
- Removed usage of internal fetch function of node until it is more
stable
### Updated
- Cleaned up test directory (#2937) and jest config (#2959)
- Wait for all modules to start before declaring the system ready
(#2487)
- Updated e2e tests (moved `done()` in helper functions) and use es6
syntax in all tests
- Updated da translation
- Rework weather module
- Make sure smhi provider api only gets a maximum of 6 digits
coordinates (#2955)
- Use fetch instead of XMLHttpRequest in weatherprovider (#2935)
- Reworked how weatherproviders handle units (#2849)
- Use unix() method for parsing times, fix suntimes on the way (#2950)
- Refactor conversion functions into utils class (#2958)
- The `cors`-method in `server.js` now supports sending and recieving
HTTP headers
- Replace `…` by `…`
- Cleanup compliments module
- Updated dependencies including electron to v22 (#2903)
### Fixed
- Correctly show apparent temperature in SMHI weather provider
- Ensure updatenotification module isn't shown when local is _ahead_ of
remote
- Handle node_helper errors during startup (#2944)
- Possibility to change FontAwesome class in calendar, so icons like
`fab fa-facebook-square` works.
- Fix cors problems with newsfeed articles (as far as possible), allow
disabling cors per feed with option `useCorsProxy: false` (#2840)
- Tests not waiting for the application to start and stop before
starting the next test
- Fix electron tests failing sometimes in github workflow
- Fixed gap in clock module when displayed on the left side with
displayType=digital
- Fixed playwright issue by upgrading to v1.29.1 (#2969)
Signed-off-by: naveen <172697+naveensrinivasan@users.noreply.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>
2023-01-01 18:09:08 +01:00
|
|
|
const useCorsProxy = typeof this.config.useCorsProxy !== "undefined" && this.config.useCorsProxy;
|
|
|
|
return performWebRequest(url, type, useCorsProxy, requestHeaders, expectedResponseHeaders);
|
2017-09-21 16:38:18 +02:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Collection of registered weather providers.
|
|
|
|
*/
|
2018-12-27 19:37:02 +01:00
|
|
|
WeatherProvider.providers = [];
|
2017-09-21 16:38:18 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Static method to register a new weather provider.
|
2020-07-30 12:58:35 +02:00
|
|
|
* @param {string} providerIdentifier The name of the weather provider
|
|
|
|
* @param {object} providerDetails The details of the weather provider
|
2017-09-21 16:38:18 +02:00
|
|
|
*/
|
2020-05-11 22:22:32 +02:00
|
|
|
WeatherProvider.register = function (providerIdentifier, providerDetails) {
|
2018-12-27 19:37:02 +01:00
|
|
|
WeatherProvider.providers[providerIdentifier.toLowerCase()] = WeatherProvider.extend(providerDetails);
|
|
|
|
};
|
2017-09-21 16:38:18 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Static method to initialize a new weather provider.
|
2020-07-30 12:58:35 +02:00
|
|
|
* @param {string} providerIdentifier The name of the weather provider
|
|
|
|
* @param {object} delegate The weather module
|
|
|
|
* @returns {object} The new weather provider
|
2017-09-21 16:38:18 +02:00
|
|
|
*/
|
2020-05-11 22:22:32 +02:00
|
|
|
WeatherProvider.initialize = function (providerIdentifier, delegate) {
|
2023-07-01 21:17:31 +02:00
|
|
|
const pi = providerIdentifier.toLowerCase();
|
2017-09-21 16:38:18 +02:00
|
|
|
|
2023-07-01 21:17:31 +02:00
|
|
|
const provider = new WeatherProvider.providers[pi]();
|
2021-01-23 11:21:56 +01:00
|
|
|
const config = Object.assign({}, provider.defaults, delegate.config);
|
2017-09-21 16:38:18 +02:00
|
|
|
|
2018-12-27 19:37:02 +01:00
|
|
|
provider.delegate = delegate;
|
2021-01-23 11:21:56 +01:00
|
|
|
provider.setConfig(config);
|
2017-09-21 16:38:18 +02:00
|
|
|
|
2023-07-01 21:17:31 +02:00
|
|
|
provider.providerIdentifier = pi;
|
2017-09-21 16:38:18 +02:00
|
|
|
if (!provider.providerName) {
|
2023-07-01 21:17:31 +02:00
|
|
|
provider.providerName = pi;
|
2017-09-21 16:38:18 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return provider;
|
2018-12-27 19:37:02 +01:00
|
|
|
};
|