Skip to content

Commit

Permalink
Merge pull request #280 from MitchBred/weather-standby-mode
Browse files Browse the repository at this point in the history
chore(weather-standby-mode): print cloud percentage
  • Loading branch information
MitchBred authored Nov 25, 2023
2 parents effab4b + 81cc0ca commit 20056fa
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
6 changes: 4 additions & 2 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,9 @@ def check(lons_lats_vect):


if __name__ == "__main__":
if weather.api.clouds() < int(os.getenv('WEATHER_CLOUD_PERCENTAGE')):
status.run()
status.run()
clouds = weather.api.clouds()
print(f'Currently, clouds are {clouds}%')
if clouds < int(os.getenv('WEATHER_CLOUD_PERCENTAGE')):
buffer = geodesic_point_buffer(os.getenv("LAT"), os.getenv("LON"), int(os.getenv("KM_RADIUS")))
check(buffer)
5 changes: 3 additions & 2 deletions weather/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,13 @@


def clouds():
global response
url = f"https://api.openweathermap.org/data/2.5/onecall?lat={os.getenv('LAT')}&lon={os.getenv('LON')}&exclude=minutely,hourly,daily,alerts&appid={os.getenv('WEATHER_APP_ID')}"
try:
request = requests.get(url)
response = json.loads(request.text)

return response['current']['clouds']

except requests.exceptions.RequestException as e:
raise SystemExit(e)
except:
return response['current']['clouds']

0 comments on commit 20056fa

Please sign in to comment.