From 8d35953747baf34e6f446f297d3741f1a0f4bd18 Mon Sep 17 00:00:00 2001 From: Florian Bezannier Date: Sun, 14 Jan 2024 12:14:01 +0100 Subject: [PATCH] fix: #611 if current not exist use main section to get temperature --- psa_car_controller/psacc/utils/utils.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/psa_car_controller/psacc/utils/utils.py b/psa_car_controller/psacc/utils/utils.py index 2729511a..5dc3ce3e 100644 --- a/psa_car_controller/psacc/utils/utils.py +++ b/psa_car_controller/psacc/utils/utils.py @@ -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: