FaserF / ha-deutschebahn

Unofficial HA DB Integration, due to removal as of Home Assistant 2022.11
Apache License 2.0
40 stars 7 forks source link

minor problems with offset and delayed trains / feature request #9

Closed xMuehlex closed 1 year ago

xMuehlex commented 1 year ago

Hi FaserF. I probably found some minor issues with the new DB integration. The "offset" setting does not work, the normal departure time is always displayed without offset. I also noticed that a delayed train prevents the following trains from being displayed. It always displays the delayed train until it finally departs. However, I suspect the problem here is with the Fahrplan-API.

Feature request: The Fahrplan-API also knows the attributes "name", e.g. ICE 1234 and "track", i.e. the track number of the departure station. Would it be possible to integrate these attributes?

Thanks in advance xMuehlex

noxhirsch commented 1 year ago

There seems to be a mistake here: https://github.com/FaserF/ha-deutschebahn/blob/cfbe39d0e4756edc6251d49c482163e747eb914d/custom_components/deutschebahn/sensor.py#LL65C29-L65C29 While the config flow asks for the offset in minutes, the entered number in the code is converted to seconds. I have changed this line locally to self.offset = timedelta(minutes=config[CONF_OFFSET]) and it seems to more or less solve the problem. Smaller offsets seem to be ignored - but I suspect that this is the fault of the Deutsche Bahn website. Can you also test this on your end and see if that solves the problem for you? Then I can create a PR.

t-flow-sash commented 1 year ago

@noxhirsch Just checked on my end and the slight code adjustment suggested by you works fine. Offset is now interpreted correctly. Thanks!

FaserF commented 1 year ago

Thank you all for your input! And thanks for @noxhirsch to find the issue. New release 2.0.4 will fix this.