Add wind direction

Signed-off-by: Knut Ahlers <knut@ahlers.me>
This commit is contained in:
Knut Ahlers 2023-05-08 17:07:43 +02:00
parent 18b8cc0d57
commit 60976d4dc1
Signed by: luzifer
GPG key ID: D91C3E91E4CAD6F5

View file

@ -24,8 +24,9 @@ class Weather(Block):
self.icon_from_id(weather['weather'][0]['icon']) 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'], temp=weather['main']['temp'],
wind_icon=self.wind_icon(weather['wind']['deg']),
windspeed=weather['wind']['speed'], windspeed=weather['wind']['speed'],
) )
@ -90,6 +91,21 @@ class Weather(Block):
else: else:
self.set_icon('\ue346') # nf-weather-night_fog 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(): def main():
block = Weather(None) block = Weather(None)