fix: #611 if current not exist use main section to get temperature

This commit is contained in:
Florian Bezannier
2024-01-15 22:30:55 +01:00
committed by Florian BEZANNIER
parent 004b9ef485
commit 8d35953747
+2 -1
View File
@@ -16,7 +16,8 @@ def get_temp(latitude: str, longitude: str, api_key: str) -> float:
"appid": api_key,
"units": "metric"},
timeout=TIMEOUT_IN_S)
temp = weather_rep.json()["current"]["temp"]
weather_res_json = weather_rep.json()
temp = weather_res_json.get("current", weather_res_json.get("main"))["temp"]
logger.debug("Temperature :%fc", temp)
return temp
except ConnectionError: