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

[deutschebahn] Initial contribution: New binding for DeutscheBahn Fahrplan #11384

Merged
merged 10 commits into from
Nov 28, 2021

Conversation

soenkekueper
Copy link
Contributor

This binding uses the Timetable API of DeutscheBahn to query the DB timetable for an given railway station in germany. So openhab can display the next trains that are arriving / departing at this station, including live informations about delays or changes.

Therefore the binding provides an bridge type, that connects to the API and provides data, and an train thing that represents an train within this timetable.

The result may look like this:
Abfahrten_HannoverHBF

Forum topic can be found here:
https://community.openhab.org/t/binding-for-deutschebahn-timetable/127534

Closes #11376

@soenkekueper soenkekueper requested a review from a team as a code owner October 14, 2021 12:47
@soenkekueper
Copy link
Contributor Author

@cweitkamp cweitkamp added the new binding If someone has started to work on a binding. For a new binding PR. label Oct 16, 2021
Signed-off-by: Sönke Küper <soenkekueper@gmx.de>
…hannover hbf which has non schema conforming responses.

Signed-off-by: Sönke Küper <soenkekueper@gmx.de>
Signed-off-by: Sönke Küper <soenkekueper@gmx.de>
Signed-off-by: Sönke Küper <soenkekueper@gmx.de>
Signed-off-by: Sönke Küper <soenkekueper@gmx.de>
Signed-off-by: Sönke Küper <soenkekueper@gmx.de>
Signed-off-by: Sönke Küper <soenkekueper@gmx.de>
# DeutscheBahn Binding

The DeutscheBahn Binding provides the latest timetable information for all trains that arrive or depart at a specific train station, including live information for delays and changes in timetable.
The informations are requested from the timetable api of DeutscheBahn developer portal, so you'll need a (free) developer account to use this binding.
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
The informations are requested from the timetable api of DeutscheBahn developer portal, so you'll need a (free) developer account to use this binding.
The information are requested from the timetable api of DeutscheBahn developer portal, so you'll need a (free) developer account to use this binding.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

5. Choose your previously created application and hit "Abonnieren"
6. In confirmation-dialog choose "Wechsel zu meine Abonnements"
7. Create an access key for the production environment by hitting "Schlüssel Erstellen"
8. Copy the "Zugangstoken". This is required to access the api from openhab.
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
8. Copy the "Zugangstoken". This is required to access the api from openhab.
8. Copy the "Zugangstoken". This is required to access the api from openHAB.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed


### Determine the EVA-No of your station

For the selection of the station within openhab you need the eva nr. of the station.
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
For the selection of the station within openhab you need the eva nr. of the station.
For the selection of the station within openHAB you need the eva no. of the station.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed


### Configure timetable bridge

With access key for developer portal and eva nr. of your station you'r ready to configure a timetable (bridge) for this station.
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
With access key for developer portal and eva nr. of your station you'r ready to configure a timetable (bridge) for this station.
With access key for developer portal and eva no. of your station you're ready to configure a timetable (bridge) for this station.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

the next train that arrives / departs at the given station. Position 2 will be the second one, and so on. If you want to
show the next 4 trains for a station, create 4 things with positions 1 to 4.

**Attention:** The timetable api only provides data for the next 18 hours. If the timetable contains less trains entries than you've created
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
**Attention:** The timetable api only provides data for the next 18 hours. If the timetable contains less trains entries than you've created
**Attention:** The timetable api only provides data for the next 18 hours. If the timetable contains less train entries than you've created

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

and if you have selected only arrivals the arrival channel values will always be defined.
Channels will have an 'NULL' channel value, when corresponding attribute is not set.

Basically most informations are available as planned and changed value. This allows to easy display changed values (for example the delay or changed platform).
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
Basically most informations are available as planned and changed value. This allows to easy display changed values (for example the delay or changed platform).
Basically most information are available as planned and changed value. This allows to easy display changed values (for example the delay or changed platform).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

| changed-status | String | Provides the changed status (planned, added, cancelled) of a train. |
| cancellation-time | DateTime | Time when the cancellation of this stop was created. |
| line | String | The line of the train. |
| messages | String | Messages for this train. Contains all translated codes from the messages of the selected train stop. Multiple messages will be separated with an single dash. |
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
| messages | String | Messages for this train. Contains all translated codes from the messages of the selected train stop. Multiple messages will be separated with an single dash. |
| messages | String | Messages for this train. Contains all translated codes from the messages of the selected train stop. Multiple messages will be separated with a single dash. |

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

| cancellation-time | DateTime | Time when the cancellation of this stop was created. |
| line | String | The line of the train. |
| messages | String | Messages for this train. Contains all translated codes from the messages of the selected train stop. Multiple messages will be separated with an single dash. |
| hidden | Switch | On if the event should not be shown on WBT because travellers are not supposed to enter or exit the train at this stop. |
Copy link
Member

Choose a reason for hiding this comment

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

WBT?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The descriptions are taken from the original api documentation, so even i don't know what WBT means. I think it might be "Wall Board Timetable" or something else. So due this has no relevance here, i removed it.

| line | String | The line of the train. |
| messages | String | Messages for this train. Contains all translated codes from the messages of the selected train stop. Multiple messages will be separated with an single dash. |
| hidden | Switch | On if the event should not be shown on WBT because travellers are not supposed to enter or exit the train at this stop. |
| wings | String | A sequence of trip id separated by the pipe symbols. |
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
| wings | String | A sequence of trip id separated by the pipe symbols. |
| wings | String | A sequence of trip id separated by pipe symbols. |

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed


Using the widget for displaying the next four departures:

![Departures Hannover HBF](doc/images/Abfahrten_HannoverHBF.png "openHAB page with four widgets displaying the next departures at Hannover HBF")
Copy link
Member

Choose a reason for hiding this comment

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

I think images need to reside directly under doc/ to be rendered correctly on the OH webpage.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

Signed-off-by: Sönke Küper <soenkekueper@gmx.de>
Signed-off-by: Sönke Küper <soenkekueper@gmx.de>
Copy link
Member

@fwolter fwolter left a comment

Choose a reason for hiding this comment

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

There are 3 compiler warnings left:

[WARNING] C:\Users\Fabian Wolter\Documents\GitHub\openhab-addons\bundles\org.openhab.binding.deutschebahn\src\main\java\org\openhab\binding\deutschebahn\internal\AbstractDtoAttributeSelector.java:[80,34] Null type mismatch (type annotations): required 'VALUE_TYPE' but this expression has type '@Nullable VALUE_TYPE', where 'VALUE_TYPE' is a free type variable
[WARNING] C:\Users\Fabian Wolter\Documents\GitHub\openhab-addons\bundles\org.openhab.binding.deutschebahn\src\main\java\org\openhab\binding\deutschebahn\internal\DeutscheBahnTrainHandler.java:[20,8] The import org.openhab.binding.deutschebahn.internal.timetable.dto.Event is never used
[WARNING] C:\Users\Fabian Wolter\Documents\GitHub\openhab-addons\bundles\org.openhab.binding.deutschebahn\src\main\java\org\openhab\binding\deutschebahn\internal\DeutscheBahnTrainHandler.java:[22,8] The import org.openhab.binding.deutschebahn.internal.timetable.dto.TripLabel is never used

@soenkekueper
Copy link
Contributor Author

I'm a little bit confued on that, due i've had some more unused imports, but they've been contained within the analysis report printed out at the very end of the build log and corrected all of them. No these compiler warnings aren't displayed either within eclipse nor in the report - hard to find... I'll fix them, but i would be great if all warnings would appear in build report...

Signed-off-by: Sönke Küper <soenkekueper@gmx.de>
Copy link
Member

@fwolter fwolter left a comment

Choose a reason for hiding this comment

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

LGTM

@fwolter fwolter merged commit 50d5622 into openhab:main Nov 28, 2021
@fwolter fwolter added this to the 3.2 milestone Nov 28, 2021
@soenkekueper soenkekueper deleted the 11376-deutschebahn branch November 28, 2021 18:01
@fwolter
Copy link
Member

fwolter commented Nov 29, 2021

Now, you could add your binding's logo to the openHAB website. See https://next.openhab.org/docs/developer/bindings/#add-your-binding-s-logo-to-the-openhab-website

NickWaterton pushed a commit to NickWaterton/openhab-addons that referenced this pull request Dec 30, 2021
…rplan (openhab#11384)

* Created binding for DeutscheBahn Timetable API.

Signed-off-by: Sönke Küper <soenkekueper@gmx.de>

* Disabled schema validation and used original schema. Added tests for hannover hbf which has non schema conforming responses.

Signed-off-by: Sönke Küper <soenkekueper@gmx.de>

* Added information about UNDEF and NULL channel values.

Signed-off-by: Sönke Küper <soenkekueper@gmx.de>

* Added sample widget and screenshot

Signed-off-by: Sönke Küper <soenkekueper@gmx.de>

* Filtering duplicate messages

Signed-off-by: Sönke Küper <soenkekueper@gmx.de>

* Fixed some typos.

Signed-off-by: Sönke Küper <soenkekueper@gmx.de>

* Updated to jUnit5

Signed-off-by: Sönke Küper <soenkekueper@gmx.de>

* Applied review remarks in Readme

Signed-off-by: Sönke Küper <soenkekueper@gmx.de>

* Applied some review remarks

Signed-off-by: Sönke Küper <soenkekueper@gmx.de>

* 0000: Fixed compile warnings

Signed-off-by: Sönke Küper <soenkekueper@gmx.de>

Co-authored-by: Sönke Küper <soenkekueper@gmx.de>
Signed-off-by: Nick Waterton <n.waterton@outlook.com>
mischmidt83 pushed a commit to mischmidt83/openhab-addons that referenced this pull request Jan 9, 2022
…rplan (openhab#11384)

* Created binding for DeutscheBahn Timetable API.

Signed-off-by: Sönke Küper <soenkekueper@gmx.de>

* Disabled schema validation and used original schema. Added tests for hannover hbf which has non schema conforming responses.

Signed-off-by: Sönke Küper <soenkekueper@gmx.de>

* Added information about UNDEF and NULL channel values.

Signed-off-by: Sönke Küper <soenkekueper@gmx.de>

* Added sample widget and screenshot

Signed-off-by: Sönke Küper <soenkekueper@gmx.de>

* Filtering duplicate messages

Signed-off-by: Sönke Küper <soenkekueper@gmx.de>

* Fixed some typos.

Signed-off-by: Sönke Küper <soenkekueper@gmx.de>

* Updated to jUnit5

Signed-off-by: Sönke Küper <soenkekueper@gmx.de>

* Applied review remarks in Readme

Signed-off-by: Sönke Küper <soenkekueper@gmx.de>

* Applied some review remarks

Signed-off-by: Sönke Küper <soenkekueper@gmx.de>

* 0000: Fixed compile warnings

Signed-off-by: Sönke Küper <soenkekueper@gmx.de>

Co-authored-by: Sönke Küper <soenkekueper@gmx.de>
Signed-off-by: Michael Schmidt <mi.schmidt.83@gmail.com>
nemerdaud pushed a commit to nemerdaud/openhab-addons that referenced this pull request Jan 28, 2022
…rplan (openhab#11384)

* Created binding for DeutscheBahn Timetable API.

Signed-off-by: Sönke Küper <soenkekueper@gmx.de>

* Disabled schema validation and used original schema. Added tests for hannover hbf which has non schema conforming responses.

Signed-off-by: Sönke Küper <soenkekueper@gmx.de>

* Added information about UNDEF and NULL channel values.

Signed-off-by: Sönke Küper <soenkekueper@gmx.de>

* Added sample widget and screenshot

Signed-off-by: Sönke Küper <soenkekueper@gmx.de>

* Filtering duplicate messages

Signed-off-by: Sönke Küper <soenkekueper@gmx.de>

* Fixed some typos.

Signed-off-by: Sönke Küper <soenkekueper@gmx.de>

* Updated to jUnit5

Signed-off-by: Sönke Küper <soenkekueper@gmx.de>

* Applied review remarks in Readme

Signed-off-by: Sönke Küper <soenkekueper@gmx.de>

* Applied some review remarks

Signed-off-by: Sönke Küper <soenkekueper@gmx.de>

* 0000: Fixed compile warnings

Signed-off-by: Sönke Küper <soenkekueper@gmx.de>

Co-authored-by: Sönke Küper <soenkekueper@gmx.de>
marcfischerboschio pushed a commit to bosch-io/openhab-addons that referenced this pull request May 5, 2022
…rplan (openhab#11384)

* Created binding for DeutscheBahn Timetable API.

Signed-off-by: Sönke Küper <soenkekueper@gmx.de>

* Disabled schema validation and used original schema. Added tests for hannover hbf which has non schema conforming responses.

Signed-off-by: Sönke Küper <soenkekueper@gmx.de>

* Added information about UNDEF and NULL channel values.

Signed-off-by: Sönke Küper <soenkekueper@gmx.de>

* Added sample widget and screenshot

Signed-off-by: Sönke Küper <soenkekueper@gmx.de>

* Filtering duplicate messages

Signed-off-by: Sönke Küper <soenkekueper@gmx.de>

* Fixed some typos.

Signed-off-by: Sönke Küper <soenkekueper@gmx.de>

* Updated to jUnit5

Signed-off-by: Sönke Küper <soenkekueper@gmx.de>

* Applied review remarks in Readme

Signed-off-by: Sönke Küper <soenkekueper@gmx.de>

* Applied some review remarks

Signed-off-by: Sönke Küper <soenkekueper@gmx.de>

* 0000: Fixed compile warnings

Signed-off-by: Sönke Küper <soenkekueper@gmx.de>

Co-authored-by: Sönke Küper <soenkekueper@gmx.de>
andan67 pushed a commit to andan67/openhab-addons that referenced this pull request Nov 6, 2022
…rplan (openhab#11384)

* Created binding for DeutscheBahn Timetable API.

Signed-off-by: Sönke Küper <soenkekueper@gmx.de>

* Disabled schema validation and used original schema. Added tests for hannover hbf which has non schema conforming responses.

Signed-off-by: Sönke Küper <soenkekueper@gmx.de>

* Added information about UNDEF and NULL channel values.

Signed-off-by: Sönke Küper <soenkekueper@gmx.de>

* Added sample widget and screenshot

Signed-off-by: Sönke Küper <soenkekueper@gmx.de>

* Filtering duplicate messages

Signed-off-by: Sönke Küper <soenkekueper@gmx.de>

* Fixed some typos.

Signed-off-by: Sönke Küper <soenkekueper@gmx.de>

* Updated to jUnit5

Signed-off-by: Sönke Küper <soenkekueper@gmx.de>

* Applied review remarks in Readme

Signed-off-by: Sönke Küper <soenkekueper@gmx.de>

* Applied some review remarks

Signed-off-by: Sönke Küper <soenkekueper@gmx.de>

* 0000: Fixed compile warnings

Signed-off-by: Sönke Küper <soenkekueper@gmx.de>

Co-authored-by: Sönke Küper <soenkekueper@gmx.de>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
new binding If someone has started to work on a binding. For a new binding PR.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[deutscheBahn] New binding: DeutscheBahn Timetables API
3 participants