From a1708a14697bb9a548e0e92f1fe3bb7197b497d5 Mon Sep 17 00:00:00 2001 From: oemel09 Date: Wed, 8 Jul 2020 10:19:49 +0200 Subject: [PATCH 1/6] Fixes getting only full day forecasts --- modules/default/weatherforecast/weatherforecast.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/default/weatherforecast/weatherforecast.js b/modules/default/weatherforecast/weatherforecast.js index d872ee01..874c48fe 100644 --- a/modules/default/weatherforecast/weatherforecast.js +++ b/modules/default/weatherforecast/weatherforecast.js @@ -297,8 +297,8 @@ Module.register("weatherforecast", { let numberOfDays; if (this.config.forecastEndpoint === "forecast") { numberOfDays = this.config.maxNumberOfDays < 1 || this.config.maxNumberOfDays > 5 ? 5 : this.config.maxNumberOfDays; - // don't get forecasts for the 6th day, as it would not represent the whole day - numberOfDays = numberOfDays * 8 - (Math.floor(new Date().getHours() / 3) % 8); + // don't get forecasts for the next day, as it would not represent the whole day + numberOfDays = numberOfDays * 8 - (Math.round(new Date().getHours() / 3) % 8); } else { numberOfDays = this.config.maxNumberOfDays < 1 || this.config.maxNumberOfDays > 17 ? 7 : this.config.maxNumberOfDays; } From 93c0787efdb98c3b0c09ccb740ccea9b2cb0e206 Mon Sep 17 00:00:00 2001 From: Chris Brunner Date: Wed, 8 Jul 2020 09:48:03 -0700 Subject: [PATCH 2/6] Add support for OpenWeather onecall API --- .../weatherforecast/weatherforecast.js | 35 ++++++++++++++++--- 1 file changed, 30 insertions(+), 5 deletions(-) diff --git a/modules/default/weatherforecast/weatherforecast.js b/modules/default/weatherforecast/weatherforecast.js index d872ee01..42937879 100644 --- a/modules/default/weatherforecast/weatherforecast.js +++ b/modules/default/weatherforecast/weatherforecast.js @@ -9,6 +9,8 @@ Module.register("weatherforecast", { defaults: { location: false, locationID: false, + lat: false, + lon: false, appid: "", units: config.units, maxNumberOfDays: 7, @@ -29,6 +31,7 @@ Module.register("weatherforecast", { apiVersion: "2.5", apiBase: "https://api.openweathermap.org/data/", forecastEndpoint: "forecast/daily", + excludes: false, appendLocationNameToHeader: true, calendarClass: "calendar", @@ -283,6 +286,8 @@ Module.register("weatherforecast", { var params = "?"; if (this.config.locationID) { params += "id=" + this.config.locationID; + } else if (this.config.lat && this.config.lon) { + params += "lat=" + this.config.lat + "&lon=" + this.config.lon; } else if (this.config.location) { params += "q=" + this.config.location; } else if (this.firstEvent && this.firstEvent.geo) { @@ -304,6 +309,7 @@ Module.register("weatherforecast", { } params += "&cnt=" + numberOfDays; + params += "&exclude=" + this.config.excludes; params += "&units=" + this.config.units; params += "&lang=" + this.config.lang; params += "&APPID=" + this.config.appid; @@ -331,15 +337,34 @@ Module.register("weatherforecast", { * argument data object - Weather information received form openweather.org. */ processWeather: function (data) { - this.fetchedLocationName = data.city.name + ", " + data.city.country; + // Forcast16 (paid) API endpoint provides this data. Onecall endpoint + // does not. + if (data.city) { + this.fetchedLocationName = data.city.name + ", " + data.city.country; + } else if (this.config.location) { + this.fetchedLocationName = this.config.location; + } else { + this.fetchedLocationName = "Unknown"; + } this.forecast = []; var lastDay = null; var forecastData = {}; - for (var i = 0, count = data.list.length; i < count; i++) { - var forecast = data.list[i]; - this.parserDataWeather(forecast); // hack issue #1017 + // Handle different structs between forecast16 and onecall endpoints + var forecastList = null; + if (data.list) { + forecastList = data.list; + } else if (data.daily) { + forecastList = data.daily; + } else { + Log.error("Unexpected forecast data"); + return undefined; + } + + for (var i = 0, count = forecastList.length; i < count; i++) { + var forecast = forecastList[i]; + forecast = this.parserDataWeather(forecast); // hack issue #1017 var day; var hour; @@ -357,7 +382,7 @@ Module.register("weatherforecast", { icon: this.config.iconTable[forecast.weather[0].icon], maxTemp: this.roundValue(forecast.temp.max), minTemp: this.roundValue(forecast.temp.min), - rain: this.processRain(forecast, data.list) + rain: this.processRain(forecast, forecastList) }; this.forecast.push(forecastData); From 679d464f4cf7e9de579ff7c349318ee97ecd8734 Mon Sep 17 00:00:00 2001 From: Chris Brunner Date: Wed, 8 Jul 2020 09:53:50 -0700 Subject: [PATCH 3/6] Update chagelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7d5bc9b4..1e825dd5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ This project adheres to [Semantic Versioning](https://semver.org/). _This release is scheduled to be released on 2020-10-01._ ### Added +- Added support in weatherforecast for OpenWeather onecall API ### Updated From 2973a03d403a17084f5e1dd12bdad23b3c53046b Mon Sep 17 00:00:00 2001 From: Chris Brunner Date: Wed, 8 Jul 2020 10:11:12 -0700 Subject: [PATCH 4/6] Prettier... --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1e825dd5..1c5b27bb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ This project adheres to [Semantic Versioning](https://semver.org/). _This release is scheduled to be released on 2020-10-01._ ### Added + - Added support in weatherforecast for OpenWeather onecall API ### Updated From caa51b10297426e8aee7ed3e30aade5904786e1a Mon Sep 17 00:00:00 2001 From: Laurynas Kerezius Date: Wed, 8 Jul 2020 20:52:24 +0000 Subject: [PATCH 5/6] Add lithuanian language --- translations/lt.json | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 translations/lt.json diff --git a/translations/lt.json b/translations/lt.json new file mode 100644 index 00000000..87fbd791 --- /dev/null +++ b/translations/lt.json @@ -0,0 +1,36 @@ +{ + "LOADING": "Kraunasi …", + + "TODAY": "Šiandien", + "TOMORROW": "Rytoj", + "DAYAFTERTOMORROW": "Už 2 dienų", + "RUNNING": "Pasibaigs už", + "EMPTY": "Nėra artimų įvykių.", + + "WEEK": "{weekNumber} savaitė", + + "N": "N", + "NNE": "NNE", + "NE": "NE", + "ENE": "ENE", + "E": "E", + "ESE": "ESE", + "SE": "SE", + "SSE": "SSE", + "S": "S", + "SSW": "SSW", + "SW": "SW", + "WSW": "WSW", + "W": "W", + "WNW": "WNW", + "NW": "NW", + "NNW": "NNW", + + "UPDATE_NOTIFICATION": "Galimas MagicMirror² naujinimas.", + "UPDATE_NOTIFICATION_MODULE": "Galimas {MODULE_NAME} naujinimas.", + "UPDATE_INFO_SINGLE": "Šis įdiegimas atsilieka {COMMIT_COUNT} įsipareigojimu {BRANCH_NAME} šakoje.", + "UPDATE_INFO_MULTIPLE": "Šis įdiegimas atsilieka {COMMIT_COUNT} įsipareigojimais {BRANCH_NAME} šakoje.", + + "FEELS": "Jaučiasi kaip", + "PRECIP": "Krituliai" +} From 029da3791bac3cd23b47d4564397287880213d9d Mon Sep 17 00:00:00 2001 From: larryare <47447699+larryare@users.noreply.github.com> Date: Wed, 8 Jul 2020 23:57:57 +0300 Subject: [PATCH 6/6] Update CHANGELOG.md Added lithuanian language entry. --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7d5bc9b4..efd63fe7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,8 @@ _This release is scheduled to be released on 2020-10-01._ ### Added +- Add lithuanian language. + ### Updated - Change incorrect weather.js default properties.