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

Search specific train in Nederlandse Spoorwegen #28898

Merged
merged 6 commits into from Feb 2, 2020

Conversation

@gurbyz
Copy link
Contributor

gurbyz commented Nov 20, 2019

Description:

Added optional configuration variable time to search for a specific train.

Why is this needed? The current implementation was searching for the next train only. For some travelers and/or stations this isn't convenient. E.g. when you want to get trip information about your fast train ("Intercity"), but a slow train ("Sprinter") for same departing station and arrival station is departing only a few minutes before the fast train. Then the time interval in where you get the information for your specific train is too small and you can't make automations for it, like notify you in time (!) when your train is delayed.

To not hit the FUP threshold for NS API calls (when e.g. watching for all specific trains that your household uses) the sensor only updates around the searched specific trip time. Outside this interval the sensor gives unknown in Home Assistant.

Related issue (if applicable): n.a.

Pull request with documentation for home-assistant.io (if applicable): home-assistant/home-assistant.io#11235

Example entry for configuration.yaml (if applicable):

sensor:
  - platform: nederlandse_spoorwegen
    email: YOUR_NS_API_USERNAME
    password: YOUR_NS_API_PASSWORD
    routes:
      - name: 'The next train'
        from: Dvd
        to: Almb
      - name: 'A specific train'
        from: Dvd
        to: Almb
        time: '17:31:00'

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.
  • I have followed the development checklist

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. Update and include derived files by running python3 -m script.hassfest.
  • New or updated dependencies have been added to requirements_all.txt by running python3 -m script.gen_requirements_all.
  • Untested files have been added to .coveragerc.

If the code does not interact with devices:

  • Tests have been added to verify that the new code works.
@homeassistant

This comment has been minimized.

Copy link
Contributor

homeassistant commented Nov 20, 2019

Hi @gurbyz,

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!

@gurbyz gurbyz mentioned this pull request Nov 20, 2019
2 of 2 tasks complete
@gurbyz gurbyz changed the title Nederlandse Spoorwegen: search for specific trip Nederlandse Spoorwegen: search for specific train Nov 20, 2019
@gurbyz gurbyz marked this pull request as ready for review Nov 20, 2019
@fabaff fabaff changed the title Nederlandse Spoorwegen: search for specific train Search for specific train Nov 21, 2019
@MartinHjelmare MartinHjelmare changed the title Search for specific train Search specific train in Nederlandse Spoorwegen Nov 21, 2019
@MartinHjelmare MartinHjelmare moved this from Incoming to Needs review in Dev Nov 21, 2019
Dev automation moved this from Needs review to Review in progress Jan 9, 2020
@springstan

This comment has been minimized.

Copy link
Member

springstan commented Feb 1, 2020

@gurbyz any updates on this PR? Please adjust the code according to the suggestions and solve the merge conflict. Thanks 👍

gurbyz added 2 commits Feb 1, 2020
Merge home assistant dev into fork
# Conflicts:
#	homeassistant/components/nederlandse_spoorwegen/sensor.py
@springstan

This comment has been minimized.

Copy link
Member

springstan commented Feb 1, 2020

You will need to format your code with black and run python3 -m script.gen_requirements_all to fix the checkformat and validate error ✌

Copy link
Member

MartinHjelmare left a comment

Can be merged when build passes.

Dev automation moved this from Review in progress to Reviewer approved Feb 1, 2020
@gurbyz

This comment has been minimized.

Copy link
Contributor Author

gurbyz commented Feb 1, 2020

When I perform python3 -m script.gen_requirements_all nothing happens locally. git status gives no changes.

@springstan springstan merged commit 75f1e57 into home-assistant:dev Feb 2, 2020
10 checks passed
10 checks passed
CI Build #20200201.45 succeeded
Details
CI (FullCheck Mypy) FullCheck Mypy succeeded
Details
CI (FullCheck Pylint) FullCheck Pylint succeeded
Details
CI (Overview CheckFormat) Overview CheckFormat succeeded
Details
CI (Overview Lint) Overview Lint succeeded
Details
CI (Overview Validate) Overview Validate succeeded
Details
CI (Tests PyTest Python37) Tests PyTest Python37 succeeded
Details
cla-bot Everyone involved has signed the CLA
codecov/patch 94.81% of diff hit (target 94.47%)
Details
codecov/project 94.63% (target 90%)
Details
Dev automation moved this from Reviewer approved to Done Feb 2, 2020
@lock lock bot locked and limited conversation to collaborators Feb 3, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
Dev
  
Done
Linked issues

Successfully merging this pull request may close these issues.

None yet

4 participants
You can’t perform that action at this time.