| #!/usr/bin/env python | |
| # -*- coding: utf-8 -*- | |
| # | |
| # RPi_SmartWatch_MAX7219 | |
| # Created by Jonatas Freitas - https://github.com/jonatasfreitasv | |
| # https://github.com/jonatasfreitasv/RPi_SmartWatch_MAX7219 | |
| # | |
| import datetime, time, urllib, json | |
| # OpenWeather | |
| weather_city = "Kranj" | |
| weather_key = "2de143494c0b295cca9337e1e96b00e0" | |
| weather_url = ("http://api.openweathermap.org/data/2.5/weather?q=%s&units=metric&appid=%s") % (weather_city, weather_key) | |
| # Get weather data | |
| weather_data = urllib.urlopen(weather_url) | |
| weather_json = json.loads(weather_data.read()) | |
| # Variables | |
| degrees = u"\N{DEGREE SIGN}" | |
| city = weather_json["name"] | |
| temp = "%s%sC" % (weather_json["main"]["temp"], degrees) | |
| #cloudness = "Clouds:%s%%" % str(weather_json["clouds"]["all"]) | |
| weather = "%s, %s" % (weather_json["weather"][0]["description"], weather_json["weather"][1]["description"]) | |
| humidity = "%s%%" % str(weather_json["main"]["humidity"]) | |
| time = "-%s-" % str(datetime.datetime.now().strftime("%H:%M")) | |
| pressure = "%s hPa" % weather_json["main"]["pressure"] | |
| wind = "%s m/s" % weather_json["wind"]["speed"] | |
| print("%s: %s %s" % (city, temp, weather)) | |
| print("Pritisk: %s Vlaznost: %s Veter: %s" % (pressure, humidity, wind)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment