vingerha / gtfs2

Support GTFS in Home Assistant GUI-only
https://github.com/vingerha/gtfs2
MIT License
84 stars 7 forks source link

[Bug]: No Sensors are created. #113

Open zer0brain opened 2 days ago

zer0brain commented 2 days ago

Own Analysis

A clear and concise description of what the bug is.

Hi

I Try to integrate GTFS2 to HA for a while now, but i have the issue that there are no sensors created.

Adding Data source is working fine and as expected.
But its not possible for me to add anything
-location based departures fails with empty "No devices or entities" entries.
-Start/Stop fails with no Error and no Output of any kind.

Provide details on the data source(s)

https://opentransportdata.swiss/dataset/7cc000ea-0973-40c1-a557-7971a4939da3/resource/3a423636-aa9b-470b-8e08-4df7dec45a19/download/gtfs_fp2024_2024-11-25.zip

Config in case of setup using start / stop station

GUI is working as expected, i can select all from drop down my Provider 827: Städtische Verkehrsbetriebe Bern my line all my stations. 
But when i enter a name and press submit it reloads the windows the name is gone the Stations stay the same and nothing happens. Only option is to close the window:

2024-11-27 21:20:54.763 DEBUG (MainThread) [custom_components.gtfs2.config_flow] UserInputs Stops: {'file': 'gtfs_fp2025_2024-11-25', 'url': 'na', 'extract_from': 'zip', 'agency': '827: Städtische Verkehrsbetriebe Bern', 'route_type': '99', 'route': '91-3-A-j25-1: 3 (None) - Städtische Verkehrsbetriebe Bern', 'direction': '0', 'origin': '8595142:0:10000: Bern, Weissenbühl (Tram) (1)', 'destination': '8576646:0:B: Bern, Bahnhof (7)', 'name': 'test', 'include_tomorrow': False}
2024-11-27 21:20:54.763 DEBUG (SyncWorker_61) [custom_components.gtfs2.gtfs_helper] Getting gtfs with data: {'file': 'gtfs_fp2025_2024-11-25', 'url': 'na', 'extract_from': 'zip', 'agency': '827: Städtische Verkehrsbetriebe Bern', 'route_type': '99', 'route': '91-3-A-j25-1: 3 (None) - Städtische Verkehrsbetriebe Bern', 'direction': '0', 'origin': '8595142:0:10000: Bern, Weissenbühl (Tram) (1)', 'destination': '8576646:0:B: Bern, Bahnhof (7)', 'name': 'test', 'include_tomorrow': False}
2024-11-27 21:20:54.764 DEBUG (SyncWorker_61) [custom_components.gtfs2.gtfs_helper] Checking if extracting: gtfs_fp2025_2024-11-25
2024-11-27 21:20:54.773 DEBUG (SyncWorker_62) [custom_components.gtfs2.gtfs_helper] Check datasource index for file: gtfs_fp2025_2024-11-25
2024-11-27 21:20:54.773 DEBUG (SyncWorker_62) [custom_components.gtfs2.gtfs_helper] Checking if extracting: gtfs_fp2025_2024-11-25
2024-11-27 21:20:54.774 DEBUG (SyncWorker_62) [custom_components.gtfs2.gtfs_helper] IDX result1: {'checkidx': 1}
2024-11-27 21:20:54.776 DEBUG (SyncWorker_62) [custom_components.gtfs2.gtfs_helper] IDX result2: {'checkidx': 1}
2024-11-27 21:20:54.778 DEBUG (SyncWorker_62) [custom_components.gtfs2.gtfs_helper] IDX result3: {'checkidx': 1}
2024-11-27 21:20:54.780 DEBUG (SyncWorker_62) [custom_components.gtfs2.gtfs_helper] IDX result4: {'checkidx': 1}
2024-11-27 21:20:54.783 DEBUG (SyncWorker_62) [custom_components.gtfs2.gtfs_helper] IDX result5: {'checkidx': 1}
2024-11-27 21:20:54.784 DEBUG (SyncWorker_0) [custom_components.gtfs2.gtfs_helper] Get next departure with data: {'schedule': <pygtfs.schedule.Schedule object at 0x7fe4a2263980>, 'origin': '8595142:0:10000: Bern, Weissenbühl (Tram) (1)', 'destination': '8576646:0:B: Bern, Bahnhof (7)', 'offset': 0, 'include_tomorrow': True, 'gtfs_dir': 'gtfs2', 'name': 'test', 'next_departure': None, 'file': 'gtfs_fp2025_2024-11-25', 'route_type': '99'}
2024-11-27 21:20:54.784 DEBUG (SyncWorker_0) [custom_components.gtfs2.gtfs_helper] Checking if extracting: gtfs_fp2025_2024-11-25
2024-11-27 21:20:54.784 DEBUG (SyncWorker_0) [custom_components.gtfs2.gtfs_helper] Setting up Route for start/end : 8595142:0:10000 / 8576646:0:B 
2024-11-27 21:20:54.784 DEBUG (SyncWorker_0) [custom_components.gtfs2.gtfs_helper] Include Tomorrow
2024-11-27 21:20:56.590 DEBUG (SyncWorker_0) [custom_components.gtfs2.gtfs_helper] item: {}
2024-11-27 21:20:56.590 INFO (SyncWorker_0) [custom_components.gtfs2.gtfs_helper] No items found in gtfs
2024-11-27 21:20:56.590 DEBUG (MainThread) [custom_components.gtfs2.gtfs_helper] Getting stops list for route: 91-3-A-j25-1
2024-11-27 21:20:56.958 DEBUG (MainThread) [custom_components.gtfs2.gtfs_helper] stops: ['8595142:0:10000: Bern, Weissenbühl (Tram) (1)', '8590016:0:10001: Bern, Beaumont (2)', '8571393:0:A: Bern, Eigerplatz (3)', '8590015:0:A: Bern, Hasler (4)', '8579897:0:A: Bern, Kocherpark (5)', '8579896:0:B: Bern, Hirschengraben (6)', '8576646:0:J: Bern, Bahnhof (7)', '8576646:0:B: Bern, Bahnhof (7)']
2024-11-27 21:21:05.007 DEBUG (MainThread) [custom_components.gtfs2.config_flow] UserInputs Stops: {'file': 'gtfs_fp2025_2024-11-25', 'url': 'na', 'extract_from': 'zip', 'agency': '827: Städtische Verkehrsbetriebe Bern', 'route_type': '99', 'route': '91-3-A-j25-1: 3 (None) - Städtische Verkehrsbetriebe Bern', 'direction': '0', 'origin': '8595142:0:10000: Bern, Weissenbühl (Tram) (1)', 'destination': '8576646:0:B: Bern, Bahnhof (7)', 'name': 'test', 'include_tomorrow': False}
2024-11-27 21:21:05.009 DEBUG (SyncWorker_60) [custom_components.gtfs2.gtfs_helper] Getting gtfs with data: {'file': 'gtfs_fp2025_2024-11-25', 'url': 'na', 'extract_from': 'zip', 'agency': '827: Städtische Verkehrsbetriebe Bern', 'route_type': '99', 'route': '91-3-A-j25-1: 3 (None) - Städtische Verkehrsbetriebe Bern', 'direction': '0', 'origin': '8595142:0:10000: Bern, Weissenbühl (Tram) (1)', 'destination': '8576646:0:B: Bern, Bahnhof (7)', 'name': 'test', 'include_tomorrow': False}
2024-11-27 21:21:05.009 DEBUG (SyncWorker_60) [custom_components.gtfs2.gtfs_helper] Checking if extracting: gtfs_fp2025_2024-11-25
2024-11-27 21:21:05.015 DEBUG (SyncWorker_31) [custom_components.gtfs2.gtfs_helper] Check datasource index for file: gtfs_fp2025_2024-11-25
2024-11-27 21:21:05.015 DEBUG (SyncWorker_31) [custom_components.gtfs2.gtfs_helper] Checking if extracting: gtfs_fp2025_2024-11-25
2024-11-27 21:21:05.017 DEBUG (SyncWorker_31) [custom_components.gtfs2.gtfs_helper] IDX result1: {'checkidx': 1}
2024-11-27 21:21:05.018 DEBUG (SyncWorker_31) [custom_components.gtfs2.gtfs_helper] IDX result2: {'checkidx': 1}
2024-11-27 21:21:05.019 DEBUG (SyncWorker_31) [custom_components.gtfs2.gtfs_helper] IDX result3: {'checkidx': 1}
2024-11-27 21:21:05.020 DEBUG (SyncWorker_31) [custom_components.gtfs2.gtfs_helper] IDX result4: {'checkidx': 1}
2024-11-27 21:21:05.021 DEBUG (SyncWorker_31) [custom_components.gtfs2.gtfs_helper] IDX result5: {'checkidx': 1}
2024-11-27 21:21:05.022 DEBUG (SyncWorker_28) [custom_components.gtfs2.gtfs_helper] Get next departure with data: {'schedule': <pygtfs.schedule.Schedule object at 0x7fe47d1cd3a0>, 'origin': '8595142:0:10000: Bern, Weissenbühl (Tram) (1)', 'destination': '8576646:0:B: Bern, Bahnhof (7)', 'offset': 0, 'include_tomorrow': True, 'gtfs_dir': 'gtfs2', 'name': 'test', 'next_departure': None, 'file': 'gtfs_fp2025_2024-11-25', 'route_type': '99'}
2024-11-27 21:21:05.022 DEBUG (SyncWorker_28) [custom_components.gtfs2.gtfs_helper] Checking if extracting: gtfs_fp2025_2024-11-25
2024-11-27 21:21:05.022 DEBUG (SyncWorker_28) [custom_components.gtfs2.gtfs_helper] Setting up Route for start/end : 8595142:0:10000 / 8576646:0:B 
2024-11-27 21:21:05.022 DEBUG (SyncWorker_28) [custom_components.gtfs2.gtfs_helper] Include Tomorrow
2024-11-27 21:21:05.688 DEBUG (SyncWorker_28) [custom_components.gtfs2.gtfs_helper] item: {}
2024-11-27 21:21:05.688 INFO (SyncWorker_28) [custom_components.gtfs2.gtfs_helper] No items found in gtfs
2024-11-27 21:21:05.689 DEBUG (MainThread) [custom_components.gtfs2.gtfs_helper] Getting stops list for route: 91-3-A-j25-1
2024-11-27 21:21:06.009 DEBUG (MainThread) [custom_components.gtfs2.gtfs_helper] stops: ['8595142:0:10000: Bern, Weissenbühl (Tram) (1)', '8590016:0:10001: Bern, Beaumont (2)', '8571393:0:A: Bern, Eigerplatz (3)', '8590015:0:A: Bern, Hasler (4)', '8579897:0:A: Bern, Kocherpark (5)', '8579896:0:B: Bern, Hirschengraben (6)', '8576646:0:J: Bern, Bahnhof (7)', '8576646:0:B: Bern, Bahnhof (7)']

### Config in case of setup using location based departures

```shell
If i try to create a departure list i get a "Success! Created configuration for Home Departure."
But No Sensors, the data source is working fine there are also stations around:

2024-11-27 21:09:37.418 DEBUG (MainThread) [custom_components.gtfs2.coordinator] Previous data: None
2024-11-27 21:09:37.418 DEBUG (MainThread) [custom_components.gtfs2.gtfs_helper] Getting gtfs with data: {'file': 'gtfs_fp2025_2024-11-25', 'device_tracker_id': 'zone.home', 'name': 'Home Departure', 'url': 'na', 'extract_from': 'zip'}
2024-11-27 21:09:37.418 DEBUG (MainThread) [custom_components.gtfs2.gtfs_helper] Checking if extracting: gtfs_fp2025_2024-11-25
2024-11-27 21:09:37.426 DEBUG (MainThread) [custom_components.gtfs2.gtfs_helper] Checking if extracting: gtfs_fp2025_2024-11-25
2024-11-27 21:09:37.427 DEBUG (SyncWorker_40) [custom_components.gtfs2.gtfs_helper] Get local stop departure with data: {'schedule': <pygtfs.schedule.Schedule object at 0x7fe4863efa10>, 'include_tomorrow': True, 'gtfs_dir': 'gtfs2', 'name': 'Home Departure', 'file': 'gtfs_fp2025_2024-11-25', 'offset': 0, 'timerange': 30, 'radius': 200, 'device_tracker_id': 'zone.home', 'extracting': False, 'gtfs_updated_at': '2024-11-27T20:09:37.426465+00:00'}
2024-11-27 21:09:37.427 DEBUG (SyncWorker_40) [custom_components.gtfs2.gtfs_helper] Checking if extracting: gtfs_fp2025_2024-11-25
2024-11-27 21:09:37.427 DEBUG (SyncWorker_40) [custom_components.gtfs2.gtfs_helper] Includes Tomorrow
2024-11-27 21:09:37.474 DEBUG (SyncWorker_40) [custom_components.gtfs2.gtfs_helper] Local timezone: Europe/Zurich
2024-11-27 21:09:37.474 DEBUG (SyncWorker_40) [custom_components.gtfs2.gtfs_helper] Default 'now' on local timezone, incl. offset (if configured): 2024-11-27 21:09:37.474760+01:00
2024-11-27 21:09:37.474 DEBUG (SyncWorker_40) [custom_components.gtfs2.gtfs_helper] Stop data returned: []
2024-11-27 21:09:37.475 DEBUG (MainThread) [custom_components.gtfs2.coordinator] Data from coordinator: {'schedule': <pygtfs.schedule.Schedule object at 0x7fe4863efa10>, 'include_tomorrow': True, 'gtfs_dir': 'gtfs2', 'name': 'Home Departure', 'file': 'gtfs_fp2025_2024-11-25', 'offset': 0, 'timerange': 30, 'radius': 200, 'device_tracker_id': 'zone.home', 'extracting': False, 'gtfs_updated_at': '2024-11-27T20:09:37.426465+00:00', 'local_stops_next_departures': []}
2024-11-27 21:09:37.476 DEBUG (MainThread) [custom_components.gtfs2.coordinator] Finished fetching 01JDQKQT2DBMNCHQKTQSKK8F46 data in 0.058 seconds (success: True)
2024-11-27 21:10:26.318 DEBUG (MainThread) [custom_components.gtfs2.config_flow] Checkstops option with data: {'local_stop_refresh_interval': 15, 'radius': 250, 'timerange': 30, 'offset': 0, 'real_time': False, 'file': 'gtfs_fp2025_2024-11-25', 'url': 'na', 'extract_from': 'zip', 'device_tracker_id': 'zone.home'}
2024-11-27 21:10:26.320 DEBUG (SyncWorker_55) [custom_components.gtfs2.gtfs_helper] Getting gtfs with data: {'local_stop_refresh_interval': 15, 'radius': 250, 'timerange': 30, 'offset': 0, 'real_time': False, 'file': 'gtfs_fp2025_2024-11-25', 'url': 'na', 'extract_from': 'zip', 'device_tracker_id': 'zone.home'}
2024-11-27 21:10:26.322 DEBUG (SyncWorker_55) [custom_components.gtfs2.gtfs_helper] Checking if extracting: gtfs_fp2025_2024-11-25
2024-11-27 21:10:26.338 DEBUG (SyncWorker_25) [custom_components.gtfs2.gtfs_helper] Getting local stops list with data: {'local_stop_refresh_interval': 15, 'radius': 250, 'timerange': 30, 'offset': 0, 'real_time': False, 'file': 'gtfs_fp2025_2024-11-25', 'url': 'na', 'extract_from': 'zip', 'device_tracker_id': 'zone.home'}
2024-11-27 21:10:26.360 DEBUG (SyncWorker_25) [custom_components.gtfs2.gtfs_helper] Local stops list output: 9
2024-11-27 21:10:26.361 DEBUG (MainThread) [custom_components.gtfs2.config_flow] UserInputs Options Init without realtime: {'local_stop_refresh_interval': 15, 'radius': 250, 'timerange': 30, 'offset': 0, 'real_time': False, 'file': 'gtfs_fp2025_2024-11-25', 'url': 'na', 'extract_from': 'zip', 'device_tracker_id': 'zone.home'}


### Info on your installed version

GTFS2  From HACS Latest version:  0.5.4
HA Docker Container Version: 2024.2.4

### Relevant log output

_No response_
vingerha commented 1 day ago

This one says it all..

024-11-27 21:09:37.474 DEBUG (SyncWorker_40) [custom_components.gtfs2.gtfs_helper] Stop data returned: []

Meaning that the selection you chose, does not return any matching data. Increase range or timeframe or... in not too odd cases... the db may not have that stop data (happend to me). To verify that it works, try to find local_stop around your busiest bus/tram station, for Bern likely the railway station