From ff34977136e1b7d43d34eebe38568e8f32b259a7 Mon Sep 17 00:00:00 2001 From: Martin Gron Date: Fri, 15 Sep 2023 09:46:13 +0200 Subject: [PATCH 1/4] Changes for yr 2.3 weather api --- modules/default/weather/providers/yr.js | 11 +++-------- package.json | 4 ++-- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/modules/default/weather/providers/yr.js b/modules/default/weather/providers/yr.js index 52de53ba12..cd1ec79732 100644 --- a/modules/default/weather/providers/yr.js +++ b/modules/default/weather/providers/yr.js @@ -352,8 +352,7 @@ WeatherProvider.register("yr", { if (hours.length < 2) { hours = `0${hours}`; } - - return `${this.config.apiBase}/sunrise/2.0/.json?date=${date}&days=${days}&height=${altitude}&lat=${lat}&lon=${lon}&offset=${utcOffsetPrefix}${hours}%3A${minutes}`; + return `${this.config.apiBase}/sunrise/2.3/sun?lat=${lat}&lon=${lon}&date=${date}&offset=${utcOffsetPrefix}${hours}%3A${minutes}`; }, cacheStellarData(data) { @@ -362,8 +361,6 @@ WeatherProvider.register("yr", { getWeatherDataFrom(forecast, stellarData, units) { const weather = new WeatherObject(); - const stellarTimesToday = stellarData?.today ? this.getStellarTimesFrom(stellarData.today, moment().format("YYYY-MM-DD")) : undefined; - const stellarTimesTomorrow = stellarData?.tomorrow ? this.getStellarTimesFrom(stellarData.tomorrow, moment().add(1, "days").format("YYYY-MM-DD")) : undefined; weather.date = moment(forecast.time); weather.windSpeed = forecast.data.instant.details.wind_speed; @@ -377,10 +374,8 @@ WeatherProvider.register("yr", { weather.precipitationProbability = forecast.precipitationProbability; weather.precipitationUnits = units.precipitation_amount; - if (stellarTimesToday) { - weather.sunset = moment(stellarTimesToday.sunset.time); - weather.sunrise = weather.sunset < moment() && stellarTimesTomorrow ? moment(stellarTimesTomorrow.sunrise.time) : moment(stellarTimesToday.sunrise.time); - } + weather.sunrise = stellarData?.today?.properties?.sunrise?.time; + weather.sunset = stellarData?.today?.properties?.sunset?.time; return weather; }, diff --git a/package.json b/package.json index c8fdd5f03a..b96a7be5a4 100644 --- a/package.json +++ b/package.json @@ -4,8 +4,8 @@ "description": "The open source modular smart mirror platform.", "main": "js/electron.js", "scripts": { - "start": "DISPLAY=\"${DISPLAY:=:0}\" ./node_modules/.bin/electron js/electron.js", - "start:dev": "DISPLAY=\"${DISPLAY:=:0}\" ./node_modules/.bin/electron js/electron.js dev", + "start": ".\\node_modules\\.bin\\electron js\\electron.js", + "start:dev": ".\\node_modules\\.bin\\electron js\\electron.js dev", "server": "node ./serveronly", "install-mm": "npm install --no-audit --no-fund --no-update-notifier --only=prod --omit=dev", "install-mm:dev": "npm install --no-audit --no-fund --no-update-notifier", From 5a1043ac0bfb6899c3b5bcfb93f3f46b75961360 Mon Sep 17 00:00:00 2001 From: Martin Gron Date: Fri, 15 Sep 2023 10:22:37 +0200 Subject: [PATCH 2/4] update changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index c719848bfa..ebcb7241b3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -46,6 +46,7 @@ Special thanks to @khassel, @rejas and @sdetweil for taking over most (if not al - Fix date not shown when clock in analog mode (#3100) - Fix envcanada today percentage-of-precipitation (#3106) - Fix updatenotification where no branch is checked out but e.g. a version tag (#3130) +- Fix yr weather provider after changes in yr API (#3189) ## [2.23.0] - 2023-04-04 From 47a0fb0d1ddafc0fc52155f8e732e8a097692597 Mon Sep 17 00:00:00 2001 From: Martin Gron Date: Fri, 15 Sep 2023 10:39:01 +0200 Subject: [PATCH 3/4] revert change --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index b96a7be5a4..c8fdd5f03a 100644 --- a/package.json +++ b/package.json @@ -4,8 +4,8 @@ "description": "The open source modular smart mirror platform.", "main": "js/electron.js", "scripts": { - "start": ".\\node_modules\\.bin\\electron js\\electron.js", - "start:dev": ".\\node_modules\\.bin\\electron js\\electron.js dev", + "start": "DISPLAY=\"${DISPLAY:=:0}\" ./node_modules/.bin/electron js/electron.js", + "start:dev": "DISPLAY=\"${DISPLAY:=:0}\" ./node_modules/.bin/electron js/electron.js dev", "server": "node ./serveronly", "install-mm": "npm install --no-audit --no-fund --no-update-notifier --only=prod --omit=dev", "install-mm:dev": "npm install --no-audit --no-fund --no-update-notifier", From 4f6cf46062f63f41d75703fb86250dbd5ddec8ed Mon Sep 17 00:00:00 2001 From: Martin Gron Date: Wed, 20 Sep 2023 08:21:26 +0200 Subject: [PATCH 4/4] prettier --- modules/default/weather/providers/yr.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/default/weather/providers/yr.js b/modules/default/weather/providers/yr.js index cd1ec79732..be876a6dc8 100644 --- a/modules/default/weather/providers/yr.js +++ b/modules/default/weather/providers/yr.js @@ -374,8 +374,8 @@ WeatherProvider.register("yr", { weather.precipitationProbability = forecast.precipitationProbability; weather.precipitationUnits = units.precipitation_amount; - weather.sunrise = stellarData?.today?.properties?.sunrise?.time; - weather.sunset = stellarData?.today?.properties?.sunset?.time; + weather.sunrise = stellarData?.today?.properties?.sunrise?.time; + weather.sunset = stellarData?.today?.properties?.sunset?.time; return weather; },