8000 Fix issue 8894 with uk_transport component if no next_buses or next_trains by robmarkcole · Pull Request #9046 · home-assistant/core · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Fix issue 8894 with uk_transport component if no next_buses or next_trains #9046

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 23, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 12 additions & 7 deletions homeassistant/components/sensor/uk_transport.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,9 +180,12 @@ def _update(self):
'estimated': departure['best_departure_estimate']
})

self._state = min(map(
_delta_mins, [bus['scheduled'] for bus in self._next_buses]
))
if self._next_buses:
self._state = min(
_delta_mins(bus['scheduled'])
for bus in self._next_buses)
else:
self._state = None

@property
def device_state_attributes(self):
Expand Down Expand Up @@ -242,10 +245,12 @@ def _update(self):
'operator_name': departure['operator_name']
})

self._state = min(map(
_delta_mins,
[train['scheduled'] for train in self._next_trains]
))
if self._next_trains:
self._state = min(
_delta_mins(train['scheduled'])
for train in self._next_trains)
else:
self._state = None

@property
def device_state_attributes(self):
Expand Down
0