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

Allow resetting time in google_travel_time #88256

Merged
merged 12 commits into from Oct 11, 2023

Conversation

eifinger
Copy link
Contributor

@eifinger eifinger commented Feb 16, 2023

Proposed change

Allow resetting already defined departure or arrival times.
Equivalent to #88253

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

  • This PR fixes or closes issue: fixes #
  • This PR is related to issue:
  • Link to documentation pull request:

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
  • The code has been formatted using Black (black --fast 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.
  • Untested files have been added to .coveragerc.

To help with the load of incoming pull requests:

@eifinger eifinger changed the title Use vol.Maybe Use vol.Maybe in google_travel_time Feb 16, 2023
@balloob balloob marked this pull request as draft February 16, 2023 17:28
@balloob
Copy link
Member

balloob commented Feb 16, 2023

Marked as draft until frontend is done.

@eifinger eifinger changed the title Use vol.Maybe in google_travel_time Allow resetting time in google_travel_time Mar 29, 2023
@eifinger eifinger marked this pull request as ready for review March 29, 2023 20:01
@eifinger eifinger marked this pull request as draft March 29, 2023 20:04
@eifinger eifinger marked this pull request as ready for review March 29, 2023 20:38
@eifinger
Copy link
Contributor Author

@epenet you reviewed the PR for waze. Could you also have a look on this one since it is basically the same

Copy link
Contributor

@epenet epenet left a comment

Choose a reason for hiding this comment

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

I'm not sure your PR works as intended. I think you may still need a default=None in some places.

Basically, when a blank string is selected in the frontend, the data passed back will not contain the key at all, and therefore will not update the options.
I think you may need to set default=None or default="" where you want the key to be present in the resulting options.

Please adjust the test to ensure other options can also still be cleared.

@eifinger
Copy link
Contributor Author

I'm not sure your PR works as intended. I think you may still need a default=None in some places.

Basically, when a blank string is selected in the frontend, the data passed back will not contain the key at all, and therefore will not update the options. I think you may need to set default=None or default="" where you want the key to be present in the resulting options.

Please adjust the test to ensure other options can also still be cleared.

The only thing which can be cleared is CONF_TIME and that works. I checked that manually and the tests do reflect that as well:

This line defines the test:
Given the time type is CONF_ARRIVAL_TIME and is set to test
this line:
and the user_input does not contain CONF_TIME (because it was emptied)
this line:
then neither CONF_ARRIVAL_TIME nor CONF_DEPARTURE_TIME is configured

@eifinger
Copy link
Contributor Author

The other options can be emptied by selecting the value without any description. This looks horrible and needs to be addressed but not in this PR
image

@epenet
Copy link
Contributor

epenet commented Mar 31, 2023

But what about CONF_LANGUAGE, CONF_AVOID, CONF_TRAFFIC_MODEL, CONF_TRANSIT_MODE, CONF_TRANSIT_ROUTING_PREFERENCE?

Since you dropped the default, I think they can't be reset.

@eifinger
Copy link
Contributor Author

You are right. Its no problem for entries which define less than 7 possible values. Because then radio buttons are used and I can select the one without any description aka None value.
As soon as there are 7 or more possible values like in CONF_LANGUAGE CONF_TRANSIT_MODE a combobox/dropdown(?) is used and reset does not work.

@epenet
Copy link
Contributor

epenet commented Mar 31, 2023

You are right. Its no problem for entries which define less than 7 possible values. Because then radio buttons are used and I can select the one without any description aka None value. As soon as there are 7 or more possible values like in CONF_LANGUAGE CONF_TRANSIT_MODE a combobox/dropdown(?) is used and reset does not work.

I suggest that you take a look at the discussion on #90412
An "easy" way to solve that is to set default="" or default=None in the schema, so that if frontend doesn't pass the key it gets set to the default (None or "").
That's what I started with there - but then it was improved with selectors, translations and a sentinel.

I suggest that you do something similar here.

@epenet epenet added this to the 2023.4.0 milestone Mar 31, 2023
@epenet
Copy link
Contributor

epenet commented Mar 31, 2023

#90412 has been accepted and merged.
I suggest that you review it and adjust this one accordinly, with selectors, translations and a sentinel.
Maybe you should use selectors also for waze.

@home-assistant home-assistant bot marked this pull request as draft March 31, 2023 12:53
@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.

@frenck frenck removed this from the 2023.4.0 milestone Apr 5, 2023
@eifinger eifinger marked this pull request as ready for review September 15, 2023 13:18
@edenhaus
Copy link
Contributor

Short update: Frontend will add support for not selecting any option, and therefore, we can remove all NONE_SENTINEL.
We should wait for the frontend before merging this PR

@home-assistant home-assistant bot marked this pull request as draft October 2, 2023 16:52
@eifinger eifinger marked this pull request as ready for review October 3, 2023 19:56
@home-assistant home-assistant bot requested a review from edenhaus October 3, 2023 19:56
@home-assistant home-assistant bot marked this pull request as draft October 11, 2023 06:50
@eifinger eifinger marked this pull request as ready for review October 11, 2023 07:33
Copy link
Contributor

@edenhaus edenhaus left a comment

Choose a reason for hiding this comment

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

Thanks @eifinger 👍

@edenhaus edenhaus merged commit 7d11052 into home-assistant:dev Oct 11, 2023
23 checks passed
@github-actions github-actions bot locked and limited conversation to collaborators Oct 12, 2023
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.

None yet

6 participants