Skip to content

Commit

Permalink
fixed error when departure time is null
Browse files Browse the repository at this point in the history
  • Loading branch information
fluffykraken authored Feb 28, 2019
1 parent f6a9806 commit 072e6ea
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions bvgsensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# Version 0.1 - initial release
# Version 0.2 - added multiple destinations, optimized error logging
# Version 0.3 fixed encoding, simplified config for direction
# Version 0.3.1 fixed a bug when departure is null

from urllib.request import urlopen
import json
Expand Down Expand Up @@ -193,6 +194,8 @@ def getSingleConnection(self, direction, min_due_in, nmbr):
# _LOGGER.warning("conf_direction: {} pos_direction {}".format(direction, pos['direction']))
# if pos['direction'] in direction:
if dest in pos['direction']:
if pos['when'] is None:
continue
dep_time = datetime.strptime(pos['when'][:-6], "%Y-%m-%dT%H:%M:%S.%f")
dep_time = pytz.timezone('Europe/Berlin').localize(dep_time)
delay = (pos['delay'] // 60) if pos['delay'] is not None else 0
Expand Down

0 comments on commit 072e6ea

Please sign in to comment.