Skip to content

Commit

Permalink
Minor fix.
Browse files Browse the repository at this point in the history
  • Loading branch information
morosanmihail committed Jul 3, 2023
1 parent cd6253e commit 0d51a52
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions custom_components/london_tfl/tfl_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,14 @@ def is_data_stale(self, max_items):
if len(self._raw_result) > 0:
# check if there are enough already stored to skip a request
now = datetime.now().timestamp()
after_now = [
item for item in self._raw_result
if parser.parse(item['expectedArrival']).timestamp() > now
]
after_now = []
try:
after_now = [
item for item in self._raw_result
if parser.parse(item['expectedArrival']).timestamp() > now
]
except Exception:
after_now = []

if len(after_now) >= max_items:
self._raw_result = after_now
Expand Down

0 comments on commit 0d51a52

Please sign in to comment.