From 96171ca4e57856afe67b895118fd8b0b8e0a5dc5 Mon Sep 17 00:00:00 2001 From: Darren VanBuren Date: Sun, 8 Dec 2024 20:32:38 -0600 Subject: [PATCH] Update to handle wind and the timestamp better --- plugin.py | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/plugin.py b/plugin.py index c4a2bb0..57f6244 100644 --- a/plugin.py +++ b/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