use reverse geocoding to turn location to latlon for weather

This commit is contained in:
jesopo 2019-07-16 16:42:32 +01:00
parent 759324bb65
commit 69bab50335

View file

@ -44,13 +44,17 @@ class Module(ModuleManager.BaseModule):
args = {"units": "metric", "APPID": api_key} args = {"units": "metric", "APPID": api_key}
location_name = None
if location: if location == None:
lat, lon, location_name = location location_info = self.exports.get_one("get-location")(event["args"])
args["lat"] = lat if location_info == None:
args["lon"] = lon raise utils.EventError("Unknown location")
else: location = [location_info["lat"], location_info["lon"],
args["q"] = event["args"] 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) page = utils.http.request(URL_WEATHER, get_params=args, json=True)
if page: if page: