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

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

merged 2 commits into from
Aug 23, 2017

Conversation

robmarkcole
Copy link
Contributor
@robmarkcole robmarkcole commented Aug 19, 2017

Fixes #8894

Description:

Fixes #8894 where an error was thrown if there were no next-buses or trains

Related issue (if applicable): fixes #8894

If the code communicates with devices, web services, or third-party tools:

  • [ x] Local tests with tox run successfully. Your PR cannot be merged unless tests pass

@Kernald
Copy link
Contributor
Kernald commented Aug 21, 2017

Out of curiosity, how the "no more trains/bus" renders on the front-end? The sensor.gtfs component indicates 0, which isn't perfect. If you're doing something else here, I might open a PR reproducing the behavior on sensor.gtfs.

_delta_mins, [bus['scheduled'] for bus in self._next_buses]
))
else:
self._state = STATE_UNKNOWN
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please don't use STATE_UNKNOWN, instead set it to None

[train['scheduled'] for train in self._next_trains]
))
if self._next_trains:
self._state = min(map(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can merge the map into the list comprehension:

min(_delta_mins(train['scheduled']) for train in self._next_trains)

[train['scheduled'] for train in self._next_trains]
))
else:
self._state = STATE_UNKNOWN
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use None

@balloob balloob merged commit 4890953 into home-assistant:dev Aug 23, 2017
@balloob
Copy link
Member
balloob commented Aug 23, 2017

Awesome, thanks! 🐬

@balloob balloob mentioned this pull request Aug 25, 2017
@home-assistant home-assistant locked and limited conversation to collaborators Dec 11, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

uk_transport requires STATE_UNKNOWN
5 participants
0