diff options
| author | 2019-07-16 16:42:32 +0100 | |
|---|---|---|
| committer | 2019-07-16 16:42:32 +0100 | |
| commit | 69bab503354b1dfd7484479ccff862604cff58cd (patch) | |
| tree | 43b253b4a2519019abf568955db998db28e05d9a /modules/weather.py | |
| parent | expose reverse geocoding through exports (diff) | |
| signature | ||
use reverse geocoding to turn location to latlon for weather
Diffstat (limited to 'modules/weather.py')
| -rw-r--r-- | modules/weather.py | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/modules/weather.py b/modules/weather.py index 99389b8d..2b2d67ac 100644 --- a/modules/weather.py +++ b/modules/weather.py @@ -44,13 +44,17 @@ class Module(ModuleManager.BaseModule): args = {"units": "metric", "APPID": api_key} - location_name = None - if location: - lat, lon, location_name = location - args["lat"] = lat - args["lon"] = lon - else: - args["q"] = event["args"] + + if location == None: + location_info = self.exports.get_one("get-location")(event["args"]) + if location_info == None: + raise utils.EventError("Unknown location") + location = [location_info["lat"], location_info["lon"], + location_info.get("name", None)] + + lat, lon, location_name = location + args["lat"] = lat + args["lon"] = lon page = utils.http.request(URL_WEATHER, get_params=args, json=True) if page: |
