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
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

35 lines
816 B

  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