Add wind direction
Signed-off-by: Knut Ahlers <knut@ahlers.me>
This commit is contained in:
parent
18b8cc0d57
commit
60976d4dc1
1 changed files with 17 additions and 1 deletions
|
@ -24,8 +24,9 @@ class Weather(Block):
|
|||
|
||||
self.icon_from_id(weather['weather'][0]['icon'])
|
||||
|
||||
return '{temp:.1f}°C \ue34b {windspeed:.1f}m/s'.format(
|
||||
return '{temp:.1f}°C {wind_icon} {windspeed:.1f}m/s'.format(
|
||||
temp=weather['main']['temp'],
|
||||
wind_icon=self.wind_icon(weather['wind']['deg']),
|
||||
windspeed=weather['wind']['speed'],
|
||||
)
|
||||
|
||||
|
@ -90,6 +91,21 @@ class Weather(Block):
|
|||
else:
|
||||
self.set_icon('\ue346') # nf-weather-night_fog
|
||||
|
||||
def wind_icon(self, direction):
|
||||
icons = [
|
||||
'\ue353', # nf-weather-direction_up
|
||||
'\ue352', # nf-weather-direction_up_right
|
||||
'\ue349', # nf-weather-direction_right
|
||||
'\ue380', # nf-weather-direction_down_right
|
||||
'\ue340', # nf-weather-direction_down
|
||||
'\ue33f', # nf-weather-direction_down_left
|
||||
'\ue344', # nf-weather-direction_left
|
||||
'\ue37f', # nf-weather-direction_up_left
|
||||
'\ue353', # nf-weather-direction_up
|
||||
]
|
||||
|
||||
return icons[round(direction / 45)]
|
||||
|
||||
|
||||
def main():
|
||||
block = Weather(None)
|
||||
|
|
Loading…
Reference in a new issue