Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@zbrox
Copy link

@zbrox zbrox commented Aug 19, 2025

Proposed change

The Västtrafik integration was legacy and you couldn't configure it from the UI. With this change it is configurable from the UI and should keep backwards compatibility.

First time contributing and I was unsure for most of the process when it comes to taking an integration out of legacy. Open to whatever feedback!

Type of change

  • Dependency upgrade
  • Bugfix (non-breaking change which fixes an issue)
  • New integration (thank you!)
  • New feature (which adds functionality to an existing integration)
  • Deprecation (breaking change to happen in the future)
  • Breaking change (fix/feature causing existing functionality to break)
  • Code quality improvements to existing code or addition of tests

Additional information

Checklist

  • The code change is tested and works locally.
  • Local tests pass. Your PR cannot be merged unless tests pass
  • There is no commented out code in this PR.
  • I have followed the development checklist
  • I have followed the perfect PR recommendations
  • The code has been formatted using Ruff (ruff format homeassistant tests)
  • Tests have been added to verify that the new code works.

If user exposed functionality or configuration variables are added/changed:

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

  • The manifest file has all fields filled out correctly.
    Updated and included derived files by running: python3 -m script.hassfest.
  • New or updated dependencies have been added to requirements_all.txt.
    Updated by running python3 -m script.gen_requirements_all.
  • For the updated dependencies - a link to the changelog, or at minimum a diff between library versions is added to the PR description.

To help with the load of incoming pull requests:

@zbrox zbrox requested a review from a team as a code owner August 19, 2025 13:02
Copy link

@home-assistant home-assistant bot left a comment

Choose a reason for hiding this comment

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

Hi @zbrox

It seems you haven't yet signed a CLA. Please do so here.

Once you do that we will be able to review and accept this pull request.

Thanks!

@home-assistant home-assistant bot added cla-needed config-flow This integration migrates to the UI by adding a config flow has-tests labels Aug 19, 2025
@home-assistant
Copy link

Please take a look at the requested changes, and use the Ready for review button when you are done, thanks 👍

Learn more about our pull request process.

@MartinHjelmare MartinHjelmare changed the title update vasttrafik integration to be ui configurable Update vasttrafik integration to be ui configurable Aug 19, 2025
@zbrox zbrox force-pushed the feat/vasttrafik-upgrade branch from f2f3551 to 91ffda0 Compare August 19, 2025 15:08
@zbrox zbrox marked this pull request as ready for review August 19, 2025 15:10
@zbrox zbrox requested a review from MartinHjelmare August 19, 2025 15:12
Copy link
Member

@gjohansson-ST gjohansson-ST left a comment

Choose a reason for hiding this comment

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

Some initial comments where-of some might be a bit big so feel free to ask if it's not entirely clear.
Besides that you have subentries, there should be plenty of previous PR's to look at.

@zbrox zbrox force-pushed the feat/vasttrafik-upgrade branch from 35590e4 to 2228584 Compare November 3, 2025 12:25
@emontnemery
Copy link
Contributor

@zbrox please avoid force-pushing. Instead merge upstream/dev to your branch, either manually or by using this button:
image

zbrox added 3 commits November 3, 2025 17:05
Reuse the same schema
Use text selector for simpler input of multivalue filters
Maybe add an optional configuration for it in the departure board
configuration
@zbrox
Copy link
Author

zbrox commented Nov 3, 2025

@zbrox please avoid force-pushing. Instead merge upstream/dev to your branch, either manually or by using this button: image

Sorry, this was probably me making a change on a previous commit which I forgot I have already pushed anad jj just doing the force push. Will be more watchful for this

@emontnemery
Copy link
Contributor

CI is failing.

return self.async_create_entry(title="Västtrafik", data=user_input)

return self.async_show_form(
step_id="user", data_schema=STEP_USER_DATA_SCHEMA, errors=errors or {}
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
step_id="user", data_schema=STEP_USER_DATA_SCHEMA, errors=errors or {}
step_id="user", data_schema=STEP_USER_DATA_SCHEMA, errors=errors

Copy link
Author

Choose a reason for hiding this comment

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

Mypy is complaining if we remove the default value here. Since above the errors can be reset to be a None

Copy link
Member

Choose a reason for hiding this comment

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

Sorry, didn't check but default error to be an empty dict and not None

data_schema=self.add_suggested_values_to_schema(
STEP_USER_DATA_SCHEMA, user_input or entry.data
),
errors=errors or {},
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
errors=errors or {},
errors=errors,

Copy link
Author

Choose a reason for hiding this comment

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

Same as above


station_schema = vol.Schema(
{
vol.Required("station"): vol.In(station_options),
Copy link
Member

Choose a reason for hiding this comment

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

If you use the SelectSelectorinstead this could be presented nicely with the proper labels instead of just the station value.

Copy link
Author

Choose a reason for hiding this comment

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

In a minute :)

Copy link
Author

Choose a reason for hiding this comment

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

Something like in 82ae6ad maybe?

Copy link
Member

@gjohansson-ST gjohansson-ST Nov 4, 2025

Choose a reason for hiding this comment

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

station_options = [
        SelectOptionDict(value=station["value"], label=station["label"])
        for station in self._search_results
    ]
...
vol.Required("station"): SelectSelector(
        SelectSelectorConfig(options=station_options)
    )

Copy link
Author

Choose a reason for hiding this comment

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

Are you ok with the last commit?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants