Skip to content

Commit

Permalink
Fix missing temperature issue - Fixes #2 (#3)
Browse files Browse the repository at this point in the history
* Add time parameter to API URL

* Bump version

* include the current hour in calculations

* Fix mistake in timestamp comparison
  • Loading branch information
DylanGore authored Aug 16, 2021
1 parent c491728 commit d0d5e1e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
8 changes: 5 additions & 3 deletions meteireann/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,11 @@ def __init__(self, websession=None, api_url=API_URL, latitude=54.7210798611, lon
'''Initialize the weather object.'''
# pylint: disable=too-many-arguments

# Get the current UTC time
now = datetime.datetime.utcnow()

# Store the forecast parameters
self._api_url = f'{api_url}?lat={latitude};long={longitude};alt={altitude}'
self._api_url = f'{api_url}?lat={latitude};long={longitude};alt={altitude};from={now.date()}T{now.hour}:00'

# Create a new session if one isn't passed in
if websession is None:
Expand Down Expand Up @@ -202,7 +205,7 @@ async def fetching_data(self, *_):

def get_current_weather(self):
'''Get the current weather data from Met Éireann.'''
return self.get_weather(datetime.datetime.now(pytz.utc))
return self.get_weather(datetime.datetime.now(pytz.utc).replace(minute=0, second=0, microsecond=0))

def get_forecast(self, time_zone, hourly=False):
'''Get the forecast weather data from Met Éireann.'''
Expand All @@ -226,7 +229,6 @@ def get_weather(self, time, max_hour=6, hourly=False):
# pylint: disable=too-many-locals
if self.data is None:
return {}

day = time.date()
daily_temperatures = []
daily_precipitation = []
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
name='PyMetEireann',
packages=['meteireann'],
install_requires=['xmltodict', 'aiohttp', 'async_timeout', 'pytz'],
version='0.3',
version='0.4.1',
description='A library to communicate with the Met Éireann Public Weather Forecast and Weather Warning APIs',
long_description=long_description,
long_description_content_type='text/markdown',
Expand Down

0 comments on commit d0d5e1e

Please sign in to comment.