Update to handle wind and the timestamp better
This commit is contained in:
parent
286fa3a990
commit
96171ca4e5
1 changed files with 13 additions and 4 deletions
17
plugin.py
17
plugin.py
|
@ -85,17 +85,26 @@ class OpenWeather(callbacks.Plugin):
|
|||
exclude='minutely,hourly,daily', units='imperial')
|
||||
self.log.info(str(one_call))
|
||||
curr = one_call.current
|
||||
report_time = time.ctime(curr.reference_time())
|
||||
report_time = curr.reference_time('iso')
|
||||
self.log.info(str(curr))
|
||||
temp = curr.temperature()
|
||||
measured_temp = temp['temp']
|
||||
feels_like = temp['feels_like']
|
||||
wind_data = curr.wind('miles_hour')
|
||||
wind_speed = round(wind_data.get('speed', 0), 2)
|
||||
wind_gust = round(wind_data.get('gust', -1), 2)
|
||||
wind_dir = wind_data['deg']
|
||||
wind_str = str()
|
||||
if('gust' in wind_data):
|
||||
wind_str = f'Wind {wind_dir} @ {wind_speed} mph, gusts to {wind_gust} mph.'
|
||||
else:
|
||||
wind_str = f'Wind {wind_dir} @ {wind_speed} mph.'
|
||||
|
||||
cond = curr.detailed_status
|
||||
|
||||
|
||||
irc.reply(f'Conditions at {loc.name} as of {report_time}: '
|
||||
+ f'{cond} and {measured_temp} F, feels like {feels_like} F')
|
||||
|
||||
+ f'{cond} and {measured_temp} F, feels like {feels_like} F. '
|
||||
+ wind_str)
|
||||
|
||||
Class = OpenWeather
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue