Skip to content

Commit

Permalink
fix: object is not subscriptable #744
Browse files Browse the repository at this point in the history
  • Loading branch information
flobz committed Feb 19, 2024
1 parent 6cb6bf6 commit 18a9362
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions psa_car_controller/psacc/utils/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@

def get_temp(latitude: str, longitude: str, api_key: str) -> float:
try:
if not (latitude is None or longitude is None or api_key is None):
if latitude and longitude and api_key:
weather_rep = requests.get("https://api.openweathermap.org/data/2.5/onecall",
params={"lat": latitude, "lon": longitude,
"exclude": "minutely,hourly,daily,alerts",
"appid": api_key,
"units": "metric"},
timeout=TIMEOUT_IN_S)
weather_res_json = weather_rep.json()
temp = weather_res_json.get("current", weather_res_json.get("main"))["temp"]
temp = weather_res_json.get("current", weather_res_json["main"])["temp"]
logger.debug("Temperature :%fc", temp)
return temp
except ConnectionError:
Expand Down

0 comments on commit 18a9362

Please sign in to comment.