Récupérer la météo et l'envoyer par Gotify Le but de ce projet est avant-tout de tester Gotify et voir s'il peut potentiellement remplacer Telegram dans la plupart de mes projets qui nécessitent des notifications
Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.

get_weather.py 816 B

12345678910111213141516171819202122232425262728293031323334
  1. import requests #pip install requests
  2. from config import Weather
  3. import json #pip install json
  4. def get_data():
  5. url = "https://api.openweathermap.org/data/2.5/onecall?lat=%s&lon=%s&appid=%s&units=metric" % (Weather['lat'], Weather['lon'], Weather['API_key'])
  6. response = requests.get(url)
  7. # print(url)
  8. data = json.loads(response.text)
  9. return data
  10. def weather_tomorrow():
  11. data = get_data()
  12. weather = data['daily'][1]['weather'][0]['main']
  13. return weather
  14. def weather_today():
  15. data = get_data()
  16. weather = data['daily'][0]['weather'][0]['main']
  17. return weather
  18. def get_temp_today():
  19. data = get_data()
  20. temp = data['daily'][0]['temp']['day']
  21. return temp
  22. def get_temp_tomorrow():
  23. data = get_data()
  24. temp = data['daily'][1]['temp']['day']
  25. return temp