-
-
Notifications
You must be signed in to change notification settings - Fork 28.4k
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
Add Swiss public transport via stations #115891
Open
miaucl
wants to merge
5
commits into
home-assistant:dev
Choose a base branch
from
miaucl:spt_via
base: dev
Could not load branches
Branch not found: {{ refName }}
Could not load tags
Nothing to show
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+178
−69
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
3053ab2
add via stations
miaucl 9fdae6f
bump minor version due to backwards incompatibility
miaucl 0a72866
better coverage of many via station options in unit tests
miaucl 64038f5
fix migration unit test for new minor version 1.3
miaucl 2406f2a
switch version bump to major and improve migration test
miaucl File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
"""Helper functions for swiss_public_transport.""" | ||
|
||
from types import MappingProxyType | ||
from typing import Any | ||
|
||
from .const import CONF_DESTINATION, CONF_START, CONF_VIA | ||
|
||
|
||
def unique_id_from_config(config: MappingProxyType[str, Any]) -> str: | ||
"""Build a unique id from a config entry.""" | ||
return f"{config[CONF_START]} {config[CONF_DESTINATION]}" + ( | ||
" via " + ", ".join(config[CONF_VIA]) | ||
if CONF_VIA in config and len(config[CONF_VIA]) > 0 | ||
else "" | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This addition of
via
should probably bump the config entry version again as it's not really backwards compatible.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do I understand correctly that it is forward compatible and does not need a migration but it going back will break. Is that correct? @gjohansson-ST
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if this doesn't need to bump the major version as with the addition of
via
in the unique id I don't think it would work if a user goes backwards in versions.I don't think bumping a minor version is enough.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not that familiar with this kind of policy within home assistant. Currently I only add via stations, but there are some more useful options in the api which will require another jump in the future. What would you suggest? Be on the save side and jump a major? @gjohansson-ST
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@gjohansson-ST We already had a discussion about that here: #107087 (comment)
My interpretation would be to make sure one cannot bump back to a prior version (1.2) as it would break and therefore switch the version bump to a major version to (2.1) instead of (1.3).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I also extended the unit test for the migration to be able to test all different starting versions using parametrisation.