Skip to content

Search specific train in Nederlandse Spoorwegen#28898

Merged
springstan merged 6 commits into
home-assistant:devfrom
gurbyz:specific-trip-time
Feb 2, 2020
Merged

Search specific train in Nederlandse Spoorwegen#28898
springstan merged 6 commits into
home-assistant:devfrom
gurbyz:specific-trip-time

Conversation

@gurbyz
Copy link
Copy Markdown
Contributor

@gurbyz 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
Copy link
Copy Markdown
Contributor

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 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 November 20, 2019 16:26
@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
Comment thread homeassistant/components/nederlandse_spoorwegen/sensor.py
@springstan
Copy link
Copy Markdown
Member

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

Merge home assistant dev into fork
# Conflicts:
#	homeassistant/components/nederlandse_spoorwegen/sensor.py
@springstan
Copy link
Copy Markdown
Member

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
Copy Markdown
Member

@MartinHjelmare MartinHjelmare left a comment

Choose a reason for hiding this comment

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

Can be merged when build passes.

@gurbyz
Copy link
Copy Markdown
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
@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

None yet

Development

Successfully merging this pull request may close these issues.

4 participants