mirror of
https://github.com/MichMich/MagicMirror.git
synced 2025-06-29 20:49:54 +00:00
Fixes the UK Met Office Datahub provider (#3499)
Fixes #3384 Changed the UKMetOfficeDataHub provider to the new API structure as per the documentation. API Base URL updated. Header information amended to the correct key name. API Secret no longer required so removed. Changelog updated to reflect the change.
This commit is contained in:
parent
3b22622054
commit
4d14f4a2c1
@ -20,6 +20,7 @@ _This release is scheduled to be released on 2024-10-01._
|
|||||||
### Fixed
|
### Fixed
|
||||||
|
|
||||||
- Fixed `checks` badge in README.md
|
- Fixed `checks` badge in README.md
|
||||||
|
- [weather] Fixed issue with the UK Met Office provider following a change in their API paths and header info.
|
||||||
|
|
||||||
## [2.28.0] - 2024-07-01
|
## [2.28.0] - 2024-07-01
|
||||||
|
|
||||||
|
@ -11,9 +11,8 @@
|
|||||||
* This provider requires longitude/latitude coordinates, rather than a location ID (as with the previous Met Office provider)
|
* This provider requires longitude/latitude coordinates, rather than a location ID (as with the previous Met Office provider)
|
||||||
* Provide the following in your config.js file:
|
* Provide the following in your config.js file:
|
||||||
* weatherProvider: "ukmetofficedatahub",
|
* weatherProvider: "ukmetofficedatahub",
|
||||||
* apiBase: "https://api-metoffice.apiconnect.ibmcloud.com/metoffice/production/v0/forecasts/point/",
|
* apiBase: "https://data.hub.api.metoffice.gov.uk/sitespecific/v0/point/",
|
||||||
* apiKey: "[YOUR API KEY]",
|
* apiKey: "[YOUR API KEY]",
|
||||||
* apiSecret: "[YOUR API SECRET]",
|
|
||||||
* lat: [LATITUDE (DECIMAL)],
|
* lat: [LATITUDE (DECIMAL)],
|
||||||
* lon: [LONGITUDE (DECIMAL)]
|
* lon: [LONGITUDE (DECIMAL)]
|
||||||
*
|
*
|
||||||
@ -38,14 +37,13 @@ WeatherProvider.register("ukmetofficedatahub", {
|
|||||||
|
|
||||||
// Set the default config properties that is specific to this provider
|
// Set the default config properties that is specific to this provider
|
||||||
defaults: {
|
defaults: {
|
||||||
apiBase: "https://api-metoffice.apiconnect.ibmcloud.com/metoffice/production/v0/forecasts/point/",
|
apiBase: "https://data.hub.api.metoffice.gov.uk/sitespecific/v0/point/",
|
||||||
apiKey: "",
|
apiKey: "",
|
||||||
apiSecret: "",
|
|
||||||
lat: 0,
|
lat: 0,
|
||||||
lon: 0
|
lon: 0
|
||||||
},
|
},
|
||||||
|
|
||||||
// Build URL with query strings according to DataHub API (https://metoffice.apiconnect.ibmcloud.com/metoffice/production/api)
|
// Build URL with query strings according to DataHub API (https://datahub.metoffice.gov.uk/docs/f/category/site-specific/type/site-specific/api-documentation#get-/point/hourly)
|
||||||
getUrl (forecastType) {
|
getUrl (forecastType) {
|
||||||
let queryStrings = "?";
|
let queryStrings = "?";
|
||||||
queryStrings += `latitude=${this.config.lat}`;
|
queryStrings += `latitude=${this.config.lat}`;
|
||||||
@ -58,12 +56,11 @@ WeatherProvider.register("ukmetofficedatahub", {
|
|||||||
|
|
||||||
// Build the list of headers for the request
|
// Build the list of headers for the request
|
||||||
// For DataHub requests, the API key/secret are sent in the headers rather than as query strings.
|
// For DataHub requests, the API key/secret are sent in the headers rather than as query strings.
|
||||||
// Headers defined according to Data Hub API (https://metoffice.apiconnect.ibmcloud.com/metoffice/production/api)
|
// Headers defined according to Data Hub API (https://datahub.metoffice.gov.uk/docs/f/category/site-specific/type/site-specific/api-documentation#get-/point/hourly)
|
||||||
getHeaders () {
|
getHeaders () {
|
||||||
return {
|
return {
|
||||||
accept: "application/json",
|
accept: "application/json",
|
||||||
"x-ibm-client-id": this.config.apiKey,
|
apikey: this.config.apiKey
|
||||||
"x-ibm-client-secret": this.config.apiSecret
|
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user