Skip to content
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

Return None if no GTFS departures found #20919

Merged
merged 1 commit into from Feb 17, 2019

Conversation

Projects
None yet
4 participants
@renemarc
Copy link
Contributor

renemarc commented Feb 9, 2019

Description:

Currently, if a bus timetable query returns nothing because no more departures are scheduled for today, then the resulting state is 0, as in "0 minutes until departure", which is wrong as it blurs the lines with the real state of 0 when a bus really is less than a minute until departure. This PR changes the resulting state when no results are found to None, which is more accurate.

Since a default result changes, this PR should be labelled breaking change.

Breaking Change:
The GTFS sensor will now return unknown state instead of 0 if no next departures are found.

Related issue (if applicable): relates to #7956, but does not fix the issue.

Checklist:

  • The code change is tested and works locally.
  • Local tests pass with tox. Your PR cannot be merged unless tests pass
  • There is no commented out code in this PR.

@renemarc renemarc force-pushed the renemarc:gtfs-none-is-not-zero branch from 6432092 to 89cd396 Feb 10, 2019

@MartinHjelmare
Copy link
Member

MartinHjelmare left a comment

The change is good!

I've noticed another problem that would be good to address here or in another PR.

@@ -241,7 +241,7 @@ def update(self):
self._departure = get_next_departure(
self._pygtfs, self.origin, self.destination, self._offset)
if not self._departure:
self._state = 0
self._state = None
self._attributes = {'Info': 'No more departures today'}
if self._name == '':
self._name = (self._custom_name or DEFAULT_NAME)

This comment has been minimized.

Copy link
@MartinHjelmare

MartinHjelmare Feb 16, 2019

Member

It's not good that we might change name and as a result entity_id between restarts depending on api return result.

This comment has been minimized.

Copy link
@renemarc

renemarc Feb 17, 2019

Author Contributor

You are right, this can indeed create an unclear entity_id situation. The sensor also can have one of two default names, which is confusing. I'll open another PR to cover these naming issues. Thanks! 😃

@renemarc renemarc changed the title RFC: Return None if no GTFS departures found (breaking change) RFC: Return None if no GTFS departures found Feb 17, 2019

@renemarc renemarc changed the title RFC: Return None if no GTFS departures found Return None if no GTFS departures found Feb 17, 2019

@MartinHjelmare

This comment has been minimized.

Copy link
Member

MartinHjelmare commented Feb 17, 2019

Please highlight the breaking change in a paragraph in the PR description for the release notes. Then we can merge.

@renemarc

This comment has been minimized.

Copy link
Contributor Author

renemarc commented Feb 17, 2019

Please highlight the breaking change in a paragraph in the PR description for the release notes. Then we can merge.

Done! 😃

@MartinHjelmare MartinHjelmare added this to the 0.88.0 milestone Feb 17, 2019

@MartinHjelmare MartinHjelmare merged commit 33b8dbe into home-assistant:dev Feb 17, 2019

5 checks passed

Hound No violations found. Woof!
WIP ready for review
Details
cla-bot Everyone involved has signed the CLA
continuous-integration/travis-ci/pr The Travis CI build passed
Details
coverage/coveralls Coverage remained the same at 93.319%
Details

@wafflebot wafflebot bot removed the in progress label Feb 17, 2019

@renemarc renemarc deleted the renemarc:gtfs-none-is-not-zero branch Feb 18, 2019

@balloob balloob referenced this pull request Feb 20, 2019

Merged

0.88.0 #21238

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.