diff --git a/apps/owmweather/ChangeLog b/apps/owmweather/ChangeLog index 0313f9d070..020e5770b2 100644 --- a/apps/owmweather/ChangeLog +++ b/apps/owmweather/ChangeLog @@ -4,4 +4,5 @@ 0.04: Minor code improvements 0.05: Upgrade OWM to One Call API 3.0. Add pressure to weather.json 0.06: Fix One Call API 3.0 not returning city names, which are required by the weather app -0.07: Update weather after reconnecting bluetooth if update is due, refactor code \ No newline at end of file +0.07: Update weather after reconnecting bluetooth if update is due, refactor code +0.08: Undo change to One Call API 3.0 \ No newline at end of file diff --git a/apps/owmweather/lib.js b/apps/owmweather/lib.js index 3c01b79d4c..baa9555d03 100644 --- a/apps/owmweather/lib.js +++ b/apps/owmweather/lib.js @@ -1,23 +1,20 @@ function parseWeather(response) { let owmData = JSON.parse(response); - let isOwmData = false; - try { - isOwmData = (owmData.lat && owmData.lon) && owmData.current.weather && owmData.current; - } catch (_e) {} + let isOwmData = owmData.coord && owmData.weather && owmData.main; if (isOwmData) { let json = require("Storage").readJSON('weather.json') || {}; let weather = {}; weather.time = Date.now(); - weather.hum = owmData.current.humidity; - weather.temp = owmData.current.temp; - weather.code = owmData.current.weather[0].id; - weather.wdir = owmData.current.wind_deg; - weather.wind = owmData.current.wind_speed; - weather.loc = owmData.name || ""; - weather.txt = owmData.current.weather[0].main; - weather.hpa = owmData.current.pressure || 0; + weather.hum = owmData.main.humidity; + weather.temp = owmData.main.temp; + weather.code = owmData.weather[0].id; + weather.wdir = owmData.wind.deg; + weather.wind = owmData.wind.speed; + weather.loc = owmData.name; + weather.txt = owmData.weather[0].main; + weather.hpa = owmData.main.pressure || 0; if (weather.wdir != null) { let deg = weather.wdir; @@ -43,7 +40,7 @@ exports.pull = function(completionCallback) { "location": "London" }; let settings = require("Storage").readJSON("owmweather.json", 1); - let uri = "https://api.openweathermap.org/data/3.0/onecall?lat=" + location.lat.toFixed(2) + "&lon=" + location.lon.toFixed(2) + "&exclude=minutely,hourly,daily,alerts&appid=" + settings.apikey; + let uri = "https://api.openweathermap.org/data/2.5/weather?lat=" + location.lat.toFixed(2) + "&lon=" + location.lon.toFixed(2) + "&exclude=hourly,daily&appid=" + settings.apikey; if (Bangle.http){ Bangle.http(uri, {timeout:10000}).then(event => { let result = parseWeather(event.resp); diff --git a/apps/owmweather/metadata.json b/apps/owmweather/metadata.json index 7bf2e556b9..796df8c1cb 100644 --- a/apps/owmweather/metadata.json +++ b/apps/owmweather/metadata.json @@ -1,7 +1,7 @@ { "id": "owmweather", "name": "OpenWeatherMap weather provider", "shortName":"OWM Weather", - "version": "0.07", + "version": "0.08", "description": "Pulls weather from OpenWeatherMap (OWM) API", "icon": "app.png", "type": "bootloader",