Closed Huniku closed 2 days ago
Note that it appears a workaround is to add an offset of desired offset + Timezone offset.
In my case that would be 180 (3*60) + desired offset.
Looking into this further:
Removed previous comment as I mis-read the issue, I thought your train was travelling over multiple timezones but it isn't, it is just taking the wrong TZ from the 'agency' I have worked on a better solution now, are you able to test it using 'master' release?
resolved with 0.5.2-beta2
Sorry, I've been out of town for the last bit so couldn't test until this weekend. Tested 0.5.2-beta2 (just redownloaded via HACS), this appears to be much better, but I think there is still a minor issue.
Theory: I think the current time in the agency TZ is being compared to the departure time in the local TZ.
Offset configured: 60 Time of testing: 14:30 America/Los_Angeles or 17:30 America/New_York or 21:30 UTC Next three trips (confirmed via SQL (note times are in America/New_York):
feed_id | trip_id | arrival_time | departure_time | stop_id | stop_sequence | stop_headsign | pickup_type | drop_off_type | shape_dist_traveled | timepoint |
---|---|---|---|---|---|---|---|---|---|---|
1 | 105104 | 1970-01-01 19:48:00.000000 | 1970-01-01 20:10:00.000000 | LAX | 15 | 0 | 0 | 1 | ||
1 | 106133 | 1970-01-01 21:10:00.000000 | 1970-01-01 21:10:00.000000 | LAX | 1 | 0 | 0 | 1 | ||
1 | 105927 | 1970-01-01 22:40:00.000000 | 1970-01-01 23:10:00.000000 | LAX | 13 | 0 | 0 | 1 |
Note: above is from the sqlite file generated by GTFS2 - 0.4. If the fix was to modify the import process let me know and I can re-create the service/sensor.
Output from sensor is next time: origin_stop_departure_time: 2024-10-21T01:10:00+00:00
(18:10 Amer/LA).
In other words it skipped trip 105104 despite it being nearly 3 hours away.
Logs:
2024-10-20 14:30:41.375 DEBUG (MainThread) [custom_components.gtfs2.coordinator] Previous data: None
2024-10-20 14:30:41.375 DEBUG (MainThread) [custom_components.gtfs2.gtfs_helper] Getting gtfs with data: {'file': 'Amtrak', 'url': 'na', 'extract_from': 'zip', 'agency': '0: ALL', 'route_type': '2', 'origin': 'Los Angeles', 'destination': 'Anaheim', 'name': 'LA Union Station -> Anaheim', 'include_tomorrow': True, 'direction': 0, 'route': 'train'}
2024-10-20 14:30:41.375 DEBUG (MainThread) [custom_components.gtfs2.gtfs_helper] Checking if extracting: Amtrak
2024-10-20 14:30:41.392 DEBUG (MainThread) [custom_components.gtfs2.gtfs_helper] Checking if extracting: Amtrak
2024-10-20 14:30:41.392 DEBUG (MainThread) [custom_components.gtfs2.coordinator] Run static refresh: sensor without gtfs data OR refresh for name: LA Union Station -> Anaheim
2024-10-20 14:30:41.393 DEBUG (SyncWorker_1) [custom_components.gtfs2.gtfs_helper] Check datasource index for file: Amtrak
2024-10-20 14:30:41.393 DEBUG (SyncWorker_1) [custom_components.gtfs2.gtfs_helper] Checking if extracting: Amtrak
2024-10-20 14:30:41.398 DEBUG (SyncWorker_1) [custom_components.gtfs2.gtfs_helper] IDX result1: {'checkidx': 1}
2024-10-20 14:30:41.399 DEBUG (SyncWorker_1) [custom_components.gtfs2.gtfs_helper] IDX result2: {'checkidx': 1}
2024-10-20 14:30:41.402 DEBUG (SyncWorker_1) [custom_components.gtfs2.gtfs_helper] IDX result3: {'checkidx': 1}
2024-10-20 14:30:41.404 DEBUG (SyncWorker_1) [custom_components.gtfs2.gtfs_helper] IDX result4: {'checkidx': 1}
2024-10-20 14:30:41.410 DEBUG (SyncWorker_1) [custom_components.gtfs2.gtfs_helper] IDX result5: {'checkidx': 1}
2024-10-20 14:30:41.410 DEBUG (SyncWorker_3) [custom_components.gtfs2.gtfs_helper] Get next departure with data: {'schedule': <pygtfs.schedule.Schedule object at 0x73a54d4ffaa0>, 'origin': 'Los Angeles', 'destination': 'Anaheim', 'offset': 60, 'include_tomorrow': True, 'gtfs_dir': 'gtfs2', 'name': 'LA Union Station -> Anaheim', 'file': 'Amtrak', 'route_type': '2', 'extracting': False, 'next_departure': {}, 'next_departure_realtime_attr': {}, 'alert': {}}
2024-10-20 14:30:41.410 DEBUG (SyncWorker_3) [custom_components.gtfs2.gtfs_helper] Checking if extracting: Amtrak
2024-10-20 14:30:41.410 DEBUG (SyncWorker_3) [custom_components.gtfs2.gtfs_helper] Setting up TRAIN Route for start/end : Los Angeles% / Anaheim%
2024-10-20 14:30:41.411 DEBUG (SyncWorker_3) [custom_components.gtfs2.gtfs_helper] Include Tomorrow
2024-10-20 14:30:41.416 INFO (SyncWorker_3) [custom_components.gtfs2.gtfs_helper] Departure found for station Los Angeles% @ 2024-10-20 18:10:00 -> {'trip_id': '105080', 'route_id': '78', 'trip_headsign': 'San Diego', 'route_long_name': 'Pacific Surfliner', 'route_short_name': None, 'origin_stop_id': 'LAX', 'origin_stop_name': 'Los Angeles', 'origin_stop_timezone': 'America/Los_Angeles', 'origin_arrival_time': '18:10:00', 'origin_depart_time': '18:10:00', 'origin_depart_date': '1970-01-01', 'origin_drop_off_type': 0, 'origin_pickup_type': 0, 'origin_dist_traveled': None, 'origin_stop_headsign': None, 'origin_stop_sequence': 1, 'origin_stop_timepoint': 1, 'dest_stop_name': 'Anaheim', 'dest_stop_timezone': 'America/Los_Angeles', 'dest_arrival_time': '18:48:00', 'dest_depart_time': '18:49:00', 'dest_drop_off_type': 0, 'dest_pickup_type': 0, 'dest_dist_traveled': None, 'dest_stop_headsign': None, 'dest_stop_sequence': 3, 'dest_stop_timepoint': 1, 'yesterday': 1, 'today': 1, 'tomorrow': 1, 'start_date': '2024-10-14', 'end_date': '2025-09-29', 'calendar_date': '', 'today_cd': 0, 'day': 'today', 'first': False, 'last': False}
2024-10-20 14:30:41.416 DEBUG (SyncWorker_3) [custom_components.gtfs2.gtfs_helper] item: {'trip_id': '105080', 'route_id': '78', 'trip_headsign': 'San Diego', 'route_long_name': 'Pacific Surfliner', 'route_short_name': None, 'origin_stop_id': 'LAX', 'origin_stop_name': 'Los Angeles', 'origin_stop_timezone': 'America/Los_Angeles', 'origin_arrival_time': '18:10:00', 'origin_depart_time': '18:10:00', 'origin_depart_date': '1970-01-01', 'origin_drop_off_type': 0, 'origin_pickup_type': 0, 'origin_dist_traveled': None, 'origin_stop_headsign': None, 'origin_stop_sequence': 1, 'origin_stop_timepoint': 1, 'dest_stop_name': 'Anaheim', 'dest_stop_timezone': 'America/Los_Angeles', 'dest_arrival_time': '18:48:00', 'dest_depart_time': '18:49:00', 'dest_drop_off_type': 0, 'dest_pickup_type': 0, 'dest_dist_traveled': None, 'dest_stop_headsign': None, 'dest_stop_sequence': 3, 'dest_stop_timepoint': 1, 'yesterday': 1, 'today': 1, 'tomorrow': 1, 'start_date': '2024-10-14', 'end_date': '2025-09-29', 'calendar_date': '', 'today_cd': 0, 'day': 'today', 'first': False, 'last': False}
2024-10-20 14:30:41.416 DEBUG (SyncWorker_3) [custom_components.gtfs2.gtfs_helper] Timetable Remaining Departures on this Start/Stop: ['2024-10-21T01:10:00+00:00', '2024-10-21T03:10:00+00:00', '2024-10-21T04:10:00+00:00', '2024-10-21T06:10:00+00:00', '2024-10-21T08:10:00+00:00', '2024-10-21T16:10:00+00:00', '2024-10-21T17:10:00+00:00', '2024-10-21T20:10:00+00:00', '2024-10-21T21:10:00+00:00', '2024-10-21T22:10:00+00:00', '2024-10-22T01:10:00+00:00', '2024-10-22T03:10:00+00:00', '2024-10-22T04:10:00+00:00', '2024-10-22T06:10:00+00:00']
2024-10-20 14:30:41.417 DEBUG (SyncWorker_3) [custom_components.gtfs2.gtfs_helper] Timetable Remaining Departures on this Start/Stop, per line: ['2024-10-21T01:10:00+00:00 (None/Pacific Surfliner)', '2024-10-21T03:10:00+00:00 (None/Pacific Surfliner)', '2024-10-21T04:10:00+00:00 (None/Pacific Surfliner)', '2024-10-21T06:10:00+00:00 (None/Pacific Surfliner)', '2024-10-21T08:10:00+00:00 (None/Pacific Surfliner)', '2024-10-21T16:10:00+00:00 (None/Pacific Surfliner)', '2024-10-21T17:10:00+00:00 (None/Pacific Surfliner)', '2024-10-21T20:10:00+00:00 (None/Pacific Surfliner)', '2024-10-21T21:10:00+00:00 (None/Pacific Surfliner)', '2024-10-21T22:10:00+00:00 (None/Pacific Surfliner)', '2024-10-22T01:10:00+00:00 (None/Pacific Surfliner)', '2024-10-22T03:10:00+00:00 (None/Pacific Surfliner)', '2024-10-22T04:10:00+00:00 (None/Pacific Surfliner)', '2024-10-22T06:10:00+00:00 (None/Pacific Surfliner)']
2024-10-20 14:30:41.417 DEBUG (SyncWorker_3) [custom_components.gtfs2.gtfs_helper] Timetable Remaining Departures on this Start/Stop, with headsign: ['2024-10-21T01:10:00+00:00 (San Diego)', '2024-10-21T03:10:00+00:00 (San Diego)', '2024-10-21T04:10:00+00:00 (San Diego)', '2024-10-21T06:10:00+00:00 (San Diego)', '2024-10-21T08:10:00+00:00 (San Diego)', '2024-10-21T16:10:00+00:00 (San Diego)', '2024-10-21T17:10:00+00:00 (San Diego)', '2024-10-21T20:10:00+00:00 (San Diego)', '2024-10-21T21:10:00+00:00 (San Diego)', '2024-10-21T22:10:00+00:00 (San Diego)', '2024-10-22T01:10:00+00:00 (San Diego)', '2024-10-22T03:10:00+00:00 (San Diego)', '2024-10-22T04:10:00+00:00 (San Diego)', '2024-10-22T06:10:00+00:00 (San Diego)']
2024-10-20 14:30:41.417 DEBUG (SyncWorker_3) [custom_components.gtfs2.gtfs_helper] Time is 'tomorrow': True ,based on -> tomorrow_val: 1, calendar_date val: , now_date val: 2024-10-20
2024-10-20 14:30:41.417 DEBUG (SyncWorker_3) [custom_components.gtfs2.gtfs_helper] Timezone HA: America/Los_Angeles
2024-10-20 14:30:41.417 DEBUG (SyncWorker_3) [custom_components.gtfs2.gtfs_helper] Default timezone: America/Los_Angeles
2024-10-20 14:30:41.417 DEBUG (SyncWorker_3) [custom_components.gtfs2.gtfs_helper] Origin stop timezone: America/Los_Angeles
2024-10-20 14:30:41.417 DEBUG (SyncWorker_3) [custom_components.gtfs2.gtfs_helper] Dest stop timezone: America/Los_Angeles
2024-10-20 14:30:41.418 DEBUG (SyncWorker_3) [custom_components.gtfs2.gtfs_helper] Setting Orig TZ based on origin stop: America/Los_Angeles
2024-10-20 14:30:41.418 DEBUG (SyncWorker_3) [custom_components.gtfs2.gtfs_helper] Setting Dest TZ based on dest stop: America/Los_Angeles
2024-10-20 14:30:41.418 DEBUG (SyncWorker_3) [custom_components.gtfs2.gtfs_helper] Used orig timezone: America/Los_Angeles
2024-10-20 14:30:41.418 DEBUG (SyncWorker_3) [custom_components.gtfs2.gtfs_helper] Used dest timezone: America/Los_Angeles
2024-10-20 14:30:41.418 DEBUG (MainThread) [custom_components.gtfs2.coordinator] GTFS coordinator data from helper: {'trip_id': '105080', 'route_id': '78', 'day': 'today', 'first': False, 'last': False, 'origin_stop_id': 'LAX', 'origin_stop_name': 'Los Angeles', 'departure_time': datetime.datetime(2024, 10, 20, 18, 10, tzinfo=zoneinfo.ZoneInfo(key='America/Los_Angeles')), 'arrival_time': datetime.datetime(2024, 10, 20, 18, 48, tzinfo=zoneinfo.ZoneInfo(key='America/Los_Angeles')), 'origin_stop_time': {'Arrival Time': '2024-10-21T01:10:00+00:00', 'Departure Time': '2024-10-21T01:10:00+00:00', 'Drop Off Type': 0, 'Pickup Type': 0, 'Shape Dist Traveled': None, 'Headsign': None, 'Sequence': 1, 'Timepoint': 1}, 'origin_stop_timezone': 'America/Los_Angeles', 'destination_stop_time': {'Arrival Time': '2024-10-21T01:48:00+00:00', 'Departure Time': '2024-10-21T01:49:00+00:00', 'Drop Off Type': 0, 'Pickup Type': 0, 'Shape Dist Traveled': None, 'Headsign': None, 'Sequence': 3, 'Timepoint': 1}, 'destination_stop_timezone': 'America/Los_Angeles', 'destination_stop_name': 'Anaheim', 'next_departures': ['2024-10-21T01:10:00+00:00', '2024-10-21T03:10:00+00:00', '2024-10-21T04:10:00+00:00', '2024-10-21T06:10:00+00:00', '2024-10-21T08:10:00+00:00', '2024-10-21T16:10:00+00:00', '2024-10-21T17:10:00+00:00', '2024-10-21T20:10:00+00:00', '2024-10-21T21:10:00+00:00', '2024-10-21T22:10:00+00:00', '2024-10-22T01:10:00+00:00', '2024-10-22T03:10:00+00:00', '2024-10-22T04:10:00+00:00', '2024-10-22T06:10:00+00:00'], 'next_departures_lines': ['2024-10-21T01:10:00+00:00 (None/Pacific Surfliner)', '2024-10-21T03:10:00+00:00 (None/Pacific Surfliner)', '2024-10-21T04:10:00+00:00 (None/Pacific Surfliner)', '2024-10-21T06:10:00+00:00 (None/Pacific Surfliner)', '2024-10-21T08:10:00+00:00 (None/Pacific Surfliner)', '2024-10-21T16:10:00+00:00 (None/Pacific Surfliner)', '2024-10-21T17:10:00+00:00 (None/Pacific Surfliner)', '2024-10-21T20:10:00+00:00 (None/Pacific Surfliner)', '2024-10-21T21:10:00+00:00 (None/Pacific Surfliner)', '2024-10-21T22:10:00+00:00 (None/Pacific Surfliner)', '2024-10-22T01:10:00+00:00 (None/Pacific Surfliner)', '2024-10-22T03:10:00+00:00 (None/Pacific Surfliner)', '2024-10-22T04:10:00+00:00 (None/Pacific Surfliner)', '2024-10-22T06:10:00+00:00 (None/Pacific Surfliner)'], 'next_departures_headsign': ['2024-10-21T01:10:00+00:00 (San Diego)', '2024-10-21T03:10:00+00:00 (San Diego)', '2024-10-21T04:10:00+00:00 (San Diego)', '2024-10-21T06:10:00+00:00 (San Diego)', '2024-10-21T08:10:00+00:00 (San Diego)', '2024-10-21T16:10:00+00:00 (San Diego)', '2024-10-21T17:10:00+00:00 (San Diego)', '2024-10-21T20:10:00+00:00 (San Diego)', '2024-10-21T21:10:00+00:00 (San Diego)', '2024-10-21T22:10:00+00:00 (San Diego)', '2024-10-22T01:10:00+00:00 (San Diego)', '2024-10-22T03:10:00+00:00 (San Diego)', '2024-10-22T04:10:00+00:00 (San Diego)', '2024-10-22T06:10:00+00:00 (San Diego)']}
2024-10-20 14:30:41.418 DEBUG (MainThread) [custom_components.gtfs2.coordinator] GTFS RT: RealTime = false, selected in entity options
2024-10-20 14:30:41.418 DEBUG (MainThread) [custom_components.gtfs2.coordinator] Finished fetching 01J9GAEQGHF6Q888NM0XHF6XKQ data in 0.043 seconds (success: True)
2024-10-20 14:30:41.418 DEBUG (MainThread) [custom_components.gtfs2.sensor] SENSOR update attr data: {'schedule': <pygtfs.schedule.Schedule object at 0x73a54d4ffaa0>, 'origin': 'Los Angeles', 'destination': 'Anaheim', 'offset': 60, 'include_tomorrow': True, 'gtfs_dir': 'gtfs2', 'name': 'LA Union Station -> Anaheim', 'file': 'Amtrak', 'route_type': '2', 'extracting': False, 'next_departure': {'trip_id': '105080', 'route_id': '78', 'day': 'today', 'first': False, 'last': False, 'origin_stop_id': 'LAX', 'origin_stop_name': 'Los Angeles', 'departure_time': datetime.datetime(2024, 10, 20, 18, 10, tzinfo=zoneinfo.ZoneInfo(key='America/Los_Angeles')), 'arrival_time': datetime.datetime(2024, 10, 20, 18, 48, tzinfo=zoneinfo.ZoneInfo(key='America/Los_Angeles')), 'origin_stop_time': {'Arrival Time': '2024-10-21T01:10:00+00:00', 'Departure Time': '2024-10-21T01:10:00+00:00', 'Drop Off Type': 0, 'Pickup Type': 0, 'Shape Dist Traveled': None, 'Headsign': None, 'Sequence': 1, 'Timepoint': 1}, 'origin_stop_timezone': 'America/Los_Angeles', 'destination_stop_time': {'Arrival Time': '2024-10-21T01:48:00+00:00', 'Departure Time': '2024-10-21T01:49:00+00:00', 'Drop Off Type': 0, 'Pickup Type': 0, 'Shape Dist Traveled': None, 'Headsign': None, 'Sequence': 3, 'Timepoint': 1}, 'destination_stop_timezone': 'America/Los_Angeles', 'destination_stop_name': 'Anaheim', 'next_departures': ['2024-10-21T01:10:00+00:00', '2024-10-21T03:10:00+00:00', '2024-10-21T04:10:00+00:00', '2024-10-21T06:10:00+00:00', '2024-10-21T08:10:00+00:00', '2024-10-21T16:10:00+00:00', '2024-10-21T17:10:00+00:00', '2024-10-21T20:10:00+00:00', '2024-10-21T21:10:00+00:00', '2024-10-21T22:10:00+00:00', '2024-10-22T01:10:00+00:00', '2024-10-22T03:10:00+00:00', '2024-10-22T04:10:00+00:00', '2024-10-22T06:10:00+00:00'], 'next_departures_lines': ['2024-10-21T01:10:00+00:00 (None/Pacific Surfliner)', '2024-10-21T03:10:00+00:00 (None/Pacific Surfliner)', '2024-10-21T04:10:00+00:00 (None/Pacific Surfliner)', '2024-10-21T06:10:00+00:00 (None/Pacific Surfliner)', '2024-10-21T08:10:00+00:00 (None/Pacific Surfliner)', '2024-10-21T16:10:00+00:00 (None/Pacific Surfliner)', '2024-10-21T17:10:00+00:00 (None/Pacific Surfliner)', '2024-10-21T20:10:00+00:00 (None/Pacific Surfliner)', '2024-10-21T21:10:00+00:00 (None/Pacific Surfliner)', '2024-10-21T22:10:00+00:00 (None/Pacific Surfliner)', '2024-10-22T01:10:00+00:00 (None/Pacific Surfliner)', '2024-10-22T03:10:00+00:00 (None/Pacific Surfliner)', '2024-10-22T04:10:00+00:00 (None/Pacific Surfliner)', '2024-10-22T06:10:00+00:00 (None/Pacific Surfliner)'], 'next_departures_headsign': ['2024-10-21T01:10:00+00:00 (San Diego)', '2024-10-21T03:10:00+00:00 (San Diego)', '2024-10-21T04:10:00+00:00 (San Diego)', '2024-10-21T06:10:00+00:00 (San Diego)', '2024-10-21T08:10:00+00:00 (San Diego)', '2024-10-21T16:10:00+00:00 (San Diego)', '2024-10-21T17:10:00+00:00 (San Diego)', '2024-10-21T20:10:00+00:00 (San Diego)', '2024-10-21T21:10:00+00:00 (San Diego)', '2024-10-21T22:10:00+00:00 (San Diego)', '2024-10-22T01:10:00+00:00 (San Diego)', '2024-10-22T03:10:00+00:00 (San Diego)', '2024-10-22T04:10:00+00:00 (San Diego)', '2024-10-22T06:10:00+00:00 (San Diego)']}, 'next_departure_realtime_attr': {}, 'alert': {}, 'gtfs_updated_at': '2024-10-20T21:30:41.418482+00:00'}
2024-10-20 14:30:41.418 DEBUG (MainThread) [custom_components.gtfs2.sensor] Fetching trip details for 105080
2024-10-20 14:30:41.421 DEBUG (MainThread) [custom_components.gtfs2.sensor] Fetching route details for 78
2024-10-20 14:30:41.423 DEBUG (MainThread) [custom_components.gtfs2.sensor] Fetching agency details for 51
2024-10-20 14:30:41.424 DEBUG (MainThread) [custom_components.gtfs2.sensor] Self._departure time from helper: {datetime.datetime(2024, 10, 20, 18, 10, tzinfo=zoneinfo.ZoneInfo(key='America/Los_Angeles'))}
2024-10-20 14:30:41.425 DEBUG (MainThread) [custom_components.gtfs2.sensor] Destination_stop_time {'Arrival Time': '2024-10-21T01:48:00+00:00', 'Departure Time': '2024-10-21T01:49:00+00:00', 'Drop Off Type': 0, 'Pickup Type': 0, 'Shape Dist Traveled': None, 'Headsign': None, 'Sequence': 3, 'Timepoint': 1}
2024-10-20 14:30:41.425 DEBUG (MainThread) [custom_components.gtfs2.sensor] No next departure realtime attributes
2024-10-20 14:31:41.166 DEBUG (MainThread) [custom_components.gtfs2.coordinator] Previous data: {'schedule': <pygtfs.schedule.Schedule object at 0x73a54d4ffaa0>, 'origin': 'Los Angeles', 'destination': 'Anaheim', 'offset': 60, 'include_tomorrow': True, 'gtfs_dir': 'gtfs2', 'name': 'LA Union Station -> Anaheim', 'file': 'Amtrak', 'route_type': '2', 'extracting': False, 'next_departure': {'trip_id': '105080', 'route_id': '78', 'day': 'today', 'first': False, 'last': False, 'origin_stop_id': 'LAX', 'origin_stop_name': 'Los Angeles', 'departure_time': datetime.datetime(2024, 10, 20, 18, 10, tzinfo=zoneinfo.ZoneInfo(key='America/Los_Angeles')), 'arrival_time': datetime.datetime(2024, 10, 20, 18, 48, tzinfo=zoneinfo.ZoneInfo(key='America/Los_Angeles')), 'origin_stop_time': {'Arrival Time': '2024-10-21T01:10:00+00:00', 'Departure Time': '2024-10-21T01:10:00+00:00', 'Drop Off Type': 0, 'Pickup Type': 0, 'Shape Dist Traveled': None, 'Headsign': None, 'Sequence': 1, 'Timepoint': 1}, 'origin_stop_timezone': 'America/Los_Angeles', 'destination_stop_time': {'Arrival Time': '2024-10-21T01:48:00+00:00', 'Departure Time': '2024-10-21T01:49:00+00:00', 'Drop Off Type': 0, 'Pickup Type': 0, 'Shape Dist Traveled': None, 'Headsign': None, 'Sequence': 3, 'Timepoint': 1}, 'destination_stop_timezone': 'America/Los_Angeles', 'destination_stop_name': 'Anaheim', 'next_departures': ['2024-10-21T01:10:00+00:00', '2024-10-21T03:10:00+00:00', '2024-10-21T04:10:00+00:00', '2024-10-21T06:10:00+00:00', '2024-10-21T08:10:00+00:00', '2024-10-21T16:10:00+00:00', '2024-10-21T17:10:00+00:00', '2024-10-21T20:10:00+00:00', '2024-10-21T21:10:00+00:00', '2024-10-21T22:10:00+00:00', '2024-10-22T01:10:00+00:00', '2024-10-22T03:10:00+00:00', '2024-10-22T04:10:00+00:00', '2024-10-22T06:10:00+00:00'], 'next_departures_lines': ['2024-10-21T01:10:00+00:00 (None/Pacific Surfliner)', '2024-10-21T03:10:00+00:00 (None/Pacific Surfliner)', '2024-10-21T04:10:00+00:00 (None/Pacific Surfliner)', '2024-10-21T06:10:00+00:00 (None/Pacific Surfliner)', '2024-10-21T08:10:00+00:00 (None/Pacific Surfliner)', '2024-10-21T16:10:00+00:00 (None/Pacific Surfliner)', '2024-10-21T17:10:00+00:00 (None/Pacific Surfliner)', '2024-10-21T20:10:00+00:00 (None/Pacific Surfliner)', '2024-10-21T21:10:00+00:00 (None/Pacific Surfliner)', '2024-10-21T22:10:00+00:00 (None/Pacific Surfliner)', '2024-10-22T01:10:00+00:00 (None/Pacific Surfliner)', '2024-10-22T03:10:00+00:00 (None/Pacific Surfliner)', '2024-10-22T04:10:00+00:00 (None/Pacific Surfliner)', '2024-10-22T06:10:00+00:00 (None/Pacific Surfliner)'], 'next_departures_headsign': ['2024-10-21T01:10:00+00:00 (San Diego)', '2024-10-21T03:10:00+00:00 (San Diego)', '2024-10-21T04:10:00+00:00 (San Diego)', '2024-10-21T06:10:00+00:00 (San Diego)', '2024-10-21T08:10:00+00:00 (San Diego)', '2024-10-21T16:10:00+00:00 (San Diego)', '2024-10-21T17:10:00+00:00 (San Diego)', '2024-10-21T20:10:00+00:00 (San Diego)', '2024-10-21T21:10:00+00:00 (San Diego)', '2024-10-21T22:10:00+00:00 (San Diego)', '2024-10-22T01:10:00+00:00 (San Diego)', '2024-10-22T03:10:00+00:00 (San Diego)', '2024-10-22T04:10:00+00:00 (San Diego)', '2024-10-22T06:10:00+00:00 (San Diego)']}, 'next_departure_realtime_attr': {}, 'alert': {}, 'gtfs_updated_at': '2024-10-20T21:30:41.418482+00:00'}
2024-10-20 14:31:41.166 DEBUG (MainThread) [custom_components.gtfs2.gtfs_helper] Getting gtfs with data: {'file': 'Amtrak', 'url': 'na', 'extract_from': 'zip', 'agency': '0: ALL', 'route_type': '2', 'origin': 'Los Angeles', 'destination': 'Anaheim', 'name': 'LA Union Station -> Anaheim', 'include_tomorrow': True, 'direction': 0, 'route': 'train'}
2024-10-20 14:31:41.167 DEBUG (MainThread) [custom_components.gtfs2.gtfs_helper] Checking if extracting: Amtrak
2024-10-20 14:31:41.172 DEBUG (MainThread) [custom_components.gtfs2.gtfs_helper] Checking if extracting: Amtrak
2024-10-20 14:31:41.172 DEBUG (MainThread) [custom_components.gtfs2.coordinator] No run static refresh: sensor exists but not yet refresh for name: LA Union Station -> Anaheim
2024-10-20 14:31:41.172 DEBUG (MainThread) [custom_components.gtfs2.coordinator] GTFS RT: RealTime = false, selected in entity options
2024-10-20 14:31:41.173 DEBUG (MainThread) [custom_components.gtfs2.coordinator] Finished fetching 01J9GAEQGHF6Q888NM0XHF6XKQ data in 0.006 seconds (success: True)
2024-10-20 14:31:41.173 DEBUG (MainThread) [custom_components.gtfs2.sensor] SENSOR update attr data: {'schedule': <pygtfs.schedule.Schedule object at 0x73a54d4ffaa0>, 'origin': 'Los Angeles', 'destination': 'Anaheim', 'offset': 60, 'include_tomorrow': True, 'gtfs_dir': 'gtfs2', 'name': 'LA Union Station -> Anaheim', 'file': 'Amtrak', 'route_type': '2', 'extracting': False, 'next_departure': {'trip_id': '105080', 'route_id': '78', 'day': 'today', 'first': False, 'last': False, 'origin_stop_id': 'LAX', 'origin_stop_name': 'Los Angeles', 'departure_time': datetime.datetime(2024, 10, 20, 18, 10, tzinfo=zoneinfo.ZoneInfo(key='America/Los_Angeles')), 'arrival_time': datetime.datetime(2024, 10, 20, 18, 48, tzinfo=zoneinfo.ZoneInfo(key='America/Los_Angeles')), 'origin_stop_time': {'Arrival Time': '2024-10-21T01:10:00+00:00', 'Departure Time': '2024-10-21T01:10:00+00:00', 'Drop Off Type': 0, 'Pickup Type': 0, 'Shape Dist Traveled': None, 'Headsign': None, 'Sequence': 1, 'Timepoint': 1}, 'origin_stop_timezone': 'America/Los_Angeles', 'destination_stop_time': {'Arrival Time': '2024-10-21T01:48:00+00:00', 'Departure Time': '2024-10-21T01:49:00+00:00', 'Drop Off Type': 0, 'Pickup Type': 0, 'Shape Dist Traveled': None, 'Headsign': None, 'Sequence': 3, 'Timepoint': 1}, 'destination_stop_timezone': 'America/Los_Angeles', 'destination_stop_name': 'Anaheim', 'next_departures': ['2024-10-21T01:10:00+00:00', '2024-10-21T03:10:00+00:00', '2024-10-21T04:10:00+00:00', '2024-10-21T06:10:00+00:00', '2024-10-21T08:10:00+00:00', '2024-10-21T16:10:00+00:00', '2024-10-21T17:10:00+00:00', '2024-10-21T20:10:00+00:00', '2024-10-21T21:10:00+00:00', '2024-10-21T22:10:00+00:00', '2024-10-22T01:10:00+00:00', '2024-10-22T03:10:00+00:00', '2024-10-22T04:10:00+00:00', '2024-10-22T06:10:00+00:00'], 'next_departures_lines': ['2024-10-21T01:10:00+00:00 (None/Pacific Surfliner)', '2024-10-21T03:10:00+00:00 (None/Pacific Surfliner)', '2024-10-21T04:10:00+00:00 (None/Pacific Surfliner)', '2024-10-21T06:10:00+00:00 (None/Pacific Surfliner)', '2024-10-21T08:10:00+00:00 (None/Pacific Surfliner)', '2024-10-21T16:10:00+00:00 (None/Pacific Surfliner)', '2024-10-21T17:10:00+00:00 (None/Pacific Surfliner)', '2024-10-21T20:10:00+00:00 (None/Pacific Surfliner)', '2024-10-21T21:10:00+00:00 (None/Pacific Surfliner)', '2024-10-21T22:10:00+00:00 (None/Pacific Surfliner)', '2024-10-22T01:10:00+00:00 (None/Pacific Surfliner)', '2024-10-22T03:10:00+00:00 (None/Pacific Surfliner)', '2024-10-22T04:10:00+00:00 (None/Pacific Surfliner)', '2024-10-22T06:10:00+00:00 (None/Pacific Surfliner)'], 'next_departures_headsign': ['2024-10-21T01:10:00+00:00 (San Diego)', '2024-10-21T03:10:00+00:00 (San Diego)', '2024-10-21T04:10:00+00:00 (San Diego)', '2024-10-21T06:10:00+00:00 (San Diego)', '2024-10-21T08:10:00+00:00 (San Diego)', '2024-10-21T16:10:00+00:00 (San Diego)', '2024-10-21T17:10:00+00:00 (San Diego)', '2024-10-21T20:10:00+00:00 (San Diego)', '2024-10-21T21:10:00+00:00 (San Diego)', '2024-10-21T22:10:00+00:00 (San Diego)', '2024-10-22T01:10:00+00:00 (San Diego)', '2024-10-22T03:10:00+00:00 (San Diego)', '2024-10-22T04:10:00+00:00 (San Diego)', '2024-10-22T06:10:00+00:00 (San Diego)']}, 'next_departure_realtime_attr': {}, 'alert': {}, 'gtfs_updated_at': '2024-10-20T21:30:41.418482+00:00'}
2024-10-20 14:31:41.173 DEBUG (MainThread) [custom_components.gtfs2.sensor] Fetching trip details for 105080
2024-10-20 14:31:41.174 DEBUG (MainThread) [custom_components.gtfs2.sensor] Fetching route details for 78
2024-10-20 14:31:41.175 DEBUG (MainThread) [custom_components.gtfs2.sensor] Fetching agency details for 51
2024-10-20 14:31:41.175 DEBUG (MainThread) [custom_components.gtfs2.sensor] Self._departure time from helper: {datetime.datetime(2024, 10, 20, 18, 10, tzinfo=zoneinfo.ZoneInfo(key='America/Los_Angeles'))}
2024-10-20 14:31:41.176 DEBUG (MainThread) [custom_components.gtfs2.sensor] Destination_stop_time {'Arrival Time': '2024-10-21T01:48:00+00:00', 'Departure Time': '2024-10-21T01:49:00+00:00', 'Drop Off Type': 0, 'Pickup Type': 0, 'Shape Dist Traveled': None, 'Headsign': None, 'Sequence': 3, 'Timepoint': 1}
2024-10-20 14:31:41.176 DEBUG (MainThread) [custom_components.gtfs2.sensor] No next departure realtime attributes
Update: Theory from my previous comment appears to be incorrect. At 17:10 the sensor correctly updated from 18:10 to 20:10 (offset = 60, all times Amer/LA).
The issue appears to be specific to trip 105104 (at least in my testing this afternoon).
I don't see an obvious reason for this behavior based on the stop time data (maybe because origin arrival is on a different day?)
I have removed any influence of the agency, not sure if that was a good idea though as this whole setup is odd. My expectations are that the times are local and that is defined by the stop timezone.
From the log you see what TZ is being used for orig and dest stop (not stop-time as this is TZ-free), these are both America/Los_Angeles What I see is that it finds a first departure time of 18:10 and arrival 18:48 ...are these correct now? And please remove the offset, I am confused already by what it should be and adding offset is not helping (me) :)
And then, yes... I missed reworking the 'next departures', will have a look
I am closing in on things but got some unexpected data whilst checking gtfs data from file Run at 01:53 PST, I have below (all in UTC) indicating two trains 02:25 and 03:00 that (along my code) stop in Anaheim and they donot...this is another thing I need to look at. The third stop is at 6:10 which is along the amtrak website. In the end, the logic is : If agency TZ then use that, else use stop TZ else use HA (server) TZ Published all in the next release 052-beta3
next_departures_lines: 2024-10-21T09:25:00+00:00 (None/Amtrak Thruway Connecting Service), 2024-10-21T10:00:00+00:00 (None/Amtrak Thruway Connecting Service), 2024-10-21T13:10:00+00:00 (None/Pacific Surfliner), 2024-10-21T14:10:00+00:00 (None/Pacific Surfliner), 2024-10-21T17:10:00+00:00 (None/Pacific Surfliner), 2024-10-21T18:10:00+00:00 (None/Pacific Surfliner), 2024-10-21T19:10:00+00:00 (None/Pacific Surfliner), 2024-10-21T22:10:00+00:00 (None/Pacific Surfliner), 2024-10-22T00:10:00+00:00 (None/Pacific Surfliner), 2024-10-22T01:10:00+00:00 (None/Pacific Surfliner)
next_departures_headsign: 2024-10-21T09:25:00+00:00 (San Diego), 2024-10-21T10:00:00+00:00 (San Diego), 2024-10-21T13:10:00+00:00 (San Diego), 2024-10-21T14:10:00+00:00 (San Diego), 2024-10-21T17:10:00+00:00 (San Diego), 2024-10-21T18:10:00+00:00 (San Diego), 2024-10-21T19:10:00+00:00 (San Diego), 2024-10-21T22:10:00+00:00 (San Diego), 2024-10-22T00:10:00+00:00 (San Diego), 2024-10-22T01:10:00+00:00 (San Diego)
EDIT ... found the thing..... I noticed the first two are Amtrak Thruway Connecting Service, being a bus service on the same line. I was not expecting to get Buses too
Please test further
Just went to bed but I can test tomorrow.Idk if it’ll help, but the pdf schedule is here: https://www.pacificsurfliner.com/globalassets/pdfs/schedules/1489433461_pacific-surfliner-timetable_9-9-24_del-mar-phase-5_a.pdfMight be easier to grok as there is some funky bus coverage for some trips.On Oct 21, 2024, at 2:07 AM, Arjan @.***> wrote: I noticed the first two are Amtrak Thruway Connecting Service, I cannot find either of them on the Amstrak site, i.e. LAX to San Diego does not give me anything before 6:10 local time
—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you authored the thread.Message ID: @.***>
Link does not work but imo it is fine now. The sensor clearly shows the BUS too Still... please review / re-test
Sorry fatfingered the pdf link when pasting from my phone. Link should be: https://www.pacificsurfliner.com/globalassets/pdfs/schedules/1489433461_pacific-surfliner-timetable_9-9-24_del-mar-phase-5_a.pdf
Just downloaded 0.5.2-beta3
Offset: 60 Current time: 12:42 Amer/LA Output: 11:10 Amer/LA
Offset: 0 Current time: 12:49 Amer/LA Output: 10:10 Amer/LA
10:10 and 11:10 correspond to real trains, but departed in the past (1.5-2.5h ago).
I think I'll have some time this evening, I'll see if I can dive into the code then.
Logs (from the first test w/ offset 60):
2024-10-21 12:42:49.962 WARNING (SyncWorker_0) [homeassistant.loader] We found a custom integration hacs which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant
2024-10-21 12:42:49.962 WARNING (SyncWorker_0) [homeassistant.loader] We found a custom integration gtfs2 which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant
2024-10-21 12:42:52.638 DEBUG (MainThread) [custom_components.gtfs2.coordinator] Previous data: None
2024-10-21 12:42:52.639 DEBUG (MainThread) [custom_components.gtfs2.gtfs_helper] Getting gtfs with data: {'file': 'Amtrak', 'url': 'na', 'extract_from': 'zip', 'agency': '0: ALL', 'route_type': '2', 'origin': 'Los Angeles', 'destination': 'Anaheim', 'name': 'LA Union Station -> Anaheim', 'include_tomorrow': True, 'direction': 0, 'route': 'train'}
2024-10-21 12:42:52.639 DEBUG (MainThread) [custom_components.gtfs2.gtfs_helper] Checking if extracting: Amtrak
2024-10-21 12:42:52.645 DEBUG (MainThread) [custom_components.gtfs2.gtfs_helper] Checking if extracting: Amtrak
2024-10-21 12:42:52.645 DEBUG (MainThread) [custom_components.gtfs2.coordinator] Run static refresh: sensor without gtfs data OR refresh for name: LA Union Station -> Anaheim
2024-10-21 12:42:52.646 DEBUG (SyncWorker_1) [custom_components.gtfs2.gtfs_helper] Check datasource index for file: Amtrak
2024-10-21 12:42:52.646 DEBUG (SyncWorker_1) [custom_components.gtfs2.gtfs_helper] Checking if extracting: Amtrak
2024-10-21 12:42:52.647 DEBUG (SyncWorker_1) [custom_components.gtfs2.gtfs_helper] IDX result1: {'checkidx': 1}
2024-10-21 12:42:52.648 DEBUG (SyncWorker_1) [custom_components.gtfs2.gtfs_helper] IDX result2: {'checkidx': 1}
2024-10-21 12:42:52.649 DEBUG (SyncWorker_1) [custom_components.gtfs2.gtfs_helper] IDX result3: {'checkidx': 1}
2024-10-21 12:42:52.649 DEBUG (SyncWorker_1) [custom_components.gtfs2.gtfs_helper] IDX result4: {'checkidx': 1}
2024-10-21 12:42:52.650 DEBUG (SyncWorker_1) [custom_components.gtfs2.gtfs_helper] IDX result5: {'checkidx': 1}
2024-10-21 12:42:52.651 DEBUG (SyncWorker_5) [custom_components.gtfs2.gtfs_helper] Get next departure with data: {'schedule': <pygtfs.schedule.Schedule object at 0x758816d33bf0>, 'origin': 'Los Angeles', 'destination': 'Anaheim', 'offset': 60, 'include_tomorrow': True, 'gtfs_dir': 'gtfs2', 'name': 'LA Union Station -> Anaheim', 'file': 'Amtrak', 'route_type': '2', 'extracting': False, 'next_departure': {}, 'next_departure_realtime_attr': {}, 'alert': {}}
2024-10-21 12:42:52.651 DEBUG (SyncWorker_5) [custom_components.gtfs2.gtfs_helper] Checking if extracting: Amtrak
2024-10-21 12:42:52.651 DEBUG (SyncWorker_5) [custom_components.gtfs2.gtfs_helper] Setting up TRAIN Route for start/end : Los Angeles% / Anaheim%
2024-10-21 12:42:52.651 DEBUG (SyncWorker_5) [custom_components.gtfs2.gtfs_helper] Include Tomorrow
2024-10-21 12:42:52.659 INFO (SyncWorker_5) [custom_components.gtfs2.gtfs_helper] Departure found for station Los Angeles% @ 2024-10-21 14:10:00 -> {'trip_id': '103093', 'route_id': '78', 'trip_headsign': 'San Diego', 'route_long_name': 'Pacific Surfliner', 'route_short_name': None, 'origin_stop_id': 'LAX', 'origin_stop_name': 'Los Angeles', 'origin_stop_timezone': 'America/Los_Angeles', 'agency_timezone': 'America/New_York', 'origin_arrival_time': '14:10:00', 'origin_depart_time': '14:10:00', 'origin_depart_date': '1970-01-01', 'origin_drop_off_type': 0, 'origin_pickup_type': 0, 'origin_dist_traveled': None, 'origin_stop_headsign': None, 'origin_stop_sequence': 1, 'origin_stop_timepoint': 1, 'dest_stop_name': 'Anaheim', 'dest_stop_timezone': 'America/Los_Angeles', 'dest_arrival_time': '14:48:00', 'dest_depart_time': '14:49:00', 'dest_drop_off_type': 0, 'dest_pickup_type': 0, 'dest_dist_traveled': None, 'dest_stop_headsign': None, 'dest_stop_sequence': 3, 'dest_stop_timepoint': 1, 'yesterday': 1, 'today': 1, 'tomorrow': 1, 'start_date': '2024-10-14', 'end_date': '2025-09-29', 'calendar_date': '', 'today_cd': 0, 'day': 'today', 'first': False, 'last': False}
2024-10-21 12:42:52.659 DEBUG (SyncWorker_5) [custom_components.gtfs2.gtfs_helper] item: {'trip_id': '103093', 'route_id': '78', 'trip_headsign': 'San Diego', 'route_long_name': 'Pacific Surfliner', 'route_short_name': None, 'origin_stop_id': 'LAX', 'origin_stop_name': 'Los Angeles', 'origin_stop_timezone': 'America/Los_Angeles', 'agency_timezone': 'America/New_York', 'origin_arrival_time': '14:10:00', 'origin_depart_time': '14:10:00', 'origin_depart_date': '1970-01-01', 'origin_drop_off_type': 0, 'origin_pickup_type': 0, 'origin_dist_traveled': None, 'origin_stop_headsign': None, 'origin_stop_sequence': 1, 'origin_stop_timepoint': 1, 'dest_stop_name': 'Anaheim', 'dest_stop_timezone': 'America/Los_Angeles', 'dest_arrival_time': '14:48:00', 'dest_depart_time': '14:49:00', 'dest_drop_off_type': 0, 'dest_pickup_type': 0, 'dest_dist_traveled': None, 'dest_stop_headsign': None, 'dest_stop_sequence': 3, 'dest_stop_timepoint': 1, 'yesterday': 1, 'today': 1, 'tomorrow': 1, 'start_date': '2024-10-14', 'end_date': '2025-09-29', 'calendar_date': '', 'today_cd': 0, 'day': 'today', 'first': False, 'last': False}
2024-10-21 12:42:52.659 DEBUG (SyncWorker_5) [custom_components.gtfs2.gtfs_helper] Timezone HA: America/Los_Angeles
2024-10-21 12:42:52.660 DEBUG (SyncWorker_5) [custom_components.gtfs2.gtfs_helper] Default timezone: America/Los_Angeles
2024-10-21 12:42:52.660 DEBUG (SyncWorker_5) [custom_components.gtfs2.gtfs_helper] Agency timezone: America/New_York
2024-10-21 12:42:52.660 DEBUG (SyncWorker_5) [custom_components.gtfs2.gtfs_helper] Origin stop timezone: America/Los_Angeles
2024-10-21 12:42:52.660 DEBUG (SyncWorker_5) [custom_components.gtfs2.gtfs_helper] Dest stop timezone: America/Los_Angeles
2024-10-21 12:42:52.660 DEBUG (SyncWorker_5) [custom_components.gtfs2.gtfs_helper] Setting Orig & Dest TZ based on Agency: America/New_York
2024-10-21 12:42:52.660 DEBUG (SyncWorker_5) [custom_components.gtfs2.gtfs_helper] Defined orig timezone: America/New_York
2024-10-21 12:42:52.660 DEBUG (SyncWorker_5) [custom_components.gtfs2.gtfs_helper] Defined dest timezone: America/New_York
2024-10-21 12:42:52.660 DEBUG (SyncWorker_5) [custom_components.gtfs2.gtfs_helper] Upcoming_departure_in_defined_timezone: 2024-10-21 01:10:00-04:00, Now_in_defined_timezone: 2024-10-21 12:42:52.660496-04:00
2024-10-21 12:42:52.660 DEBUG (SyncWorker_5) [custom_components.gtfs2.gtfs_helper] Upcoming_departure_in_defined_timezone: 2024-10-21 09:10:00-04:00, Now_in_defined_timezone: 2024-10-21 12:42:52.660555-04:00
2024-10-21 12:42:52.660 DEBUG (SyncWorker_5) [custom_components.gtfs2.gtfs_helper] Upcoming_departure_in_defined_timezone: 2024-10-21 10:10:00-04:00, Now_in_defined_timezone: 2024-10-21 12:42:52.660621-04:00
2024-10-21 12:42:52.660 DEBUG (SyncWorker_5) [custom_components.gtfs2.gtfs_helper] Upcoming_departure_in_defined_timezone: 2024-10-21 13:10:00-04:00, Now_in_defined_timezone: 2024-10-21 12:42:52.660675-04:00
2024-10-21 12:42:52.660 DEBUG (SyncWorker_5) [custom_components.gtfs2.gtfs_helper] Upcoming_departure_in_defined_timezone: 2024-10-21 14:10:00-04:00, Now_in_defined_timezone: 2024-10-21 12:42:52.660729-04:00
2024-10-21 12:42:52.660 DEBUG (SyncWorker_5) [custom_components.gtfs2.gtfs_helper] Upcoming_departure_in_defined_timezone: 2024-10-21 15:10:00-04:00, Now_in_defined_timezone: 2024-10-21 12:42:52.660780-04:00
2024-10-21 12:42:52.660 DEBUG (SyncWorker_5) [custom_components.gtfs2.gtfs_helper] Upcoming_departure_in_defined_timezone: 2024-10-21 18:10:00-04:00, Now_in_defined_timezone: 2024-10-21 12:42:52.660829-04:00
2024-10-21 12:42:52.660 DEBUG (SyncWorker_5) [custom_components.gtfs2.gtfs_helper] Upcoming_departure_in_defined_timezone: 2024-10-21 20:10:00-04:00, Now_in_defined_timezone: 2024-10-21 12:42:52.660876-04:00
2024-10-21 12:42:52.660 DEBUG (SyncWorker_5) [custom_components.gtfs2.gtfs_helper] Upcoming_departure_in_defined_timezone: 2024-10-21 21:10:00-04:00, Now_in_defined_timezone: 2024-10-21 12:42:52.660930-04:00
2024-10-21 12:42:52.660 DEBUG (SyncWorker_5) [custom_components.gtfs2.gtfs_helper] Upcoming_departure_in_defined_timezone: 2024-10-21 23:10:00-04:00, Now_in_defined_timezone: 2024-10-21 12:42:52.660979-04:00
2024-10-21 12:42:52.661 DEBUG (SyncWorker_5) [custom_components.gtfs2.gtfs_helper] Upcoming_departure_in_defined_timezone: 2024-10-22 01:10:00-04:00, Now_in_defined_timezone: 2024-10-21 12:42:52.661027-04:00
2024-10-21 12:42:52.661 DEBUG (SyncWorker_5) [custom_components.gtfs2.gtfs_helper] Upcoming_departure_in_defined_timezone: 2024-10-22 09:10:00-04:00, Now_in_defined_timezone: 2024-10-21 12:42:52.661074-04:00
2024-10-21 12:42:52.661 DEBUG (SyncWorker_5) [custom_components.gtfs2.gtfs_helper] Upcoming_departure_in_defined_timezone: 2024-10-22 10:10:00-04:00, Now_in_defined_timezone: 2024-10-21 12:42:52.661121-04:00
2024-10-21 12:42:52.661 DEBUG (SyncWorker_5) [custom_components.gtfs2.gtfs_helper] Upcoming_departure_in_defined_timezone: 2024-10-22 13:10:00-04:00, Now_in_defined_timezone: 2024-10-21 12:42:52.661169-04:00
2024-10-21 12:42:52.661 DEBUG (SyncWorker_5) [custom_components.gtfs2.gtfs_helper] Upcoming_departure_in_defined_timezone: 2024-10-22 14:10:00-04:00, Now_in_defined_timezone: 2024-10-21 12:42:52.661216-04:00
2024-10-21 12:42:52.661 DEBUG (SyncWorker_5) [custom_components.gtfs2.gtfs_helper] Upcoming_departure_in_defined_timezone: 2024-10-22 15:10:00-04:00, Now_in_defined_timezone: 2024-10-21 12:42:52.661266-04:00
2024-10-21 12:42:52.661 DEBUG (SyncWorker_5) [custom_components.gtfs2.gtfs_helper] Upcoming_departure_in_defined_timezone: 2024-10-22 18:10:00-04:00, Now_in_defined_timezone: 2024-10-21 12:42:52.661313-04:00
2024-10-21 12:42:52.661 DEBUG (SyncWorker_5) [custom_components.gtfs2.gtfs_helper] Upcoming_departure_in_defined_timezone: 2024-10-22 20:10:00-04:00, Now_in_defined_timezone: 2024-10-21 12:42:52.661360-04:00
2024-10-21 12:42:52.661 DEBUG (SyncWorker_5) [custom_components.gtfs2.gtfs_helper] Upcoming_departure_in_defined_timezone: 2024-10-22 21:10:00-04:00, Now_in_defined_timezone: 2024-10-21 12:42:52.661405-04:00
2024-10-21 12:42:52.661 DEBUG (SyncWorker_5) [custom_components.gtfs2.gtfs_helper] Upcoming_departure_in_defined_timezone: 2024-10-22 23:10:00-04:00, Now_in_defined_timezone: 2024-10-21 12:42:52.661456-04:00
2024-10-21 12:42:52.661 DEBUG (SyncWorker_5) [custom_components.gtfs2.gtfs_helper] Timetable Remaining Departures on this Start/Stop: ['2024-10-21T17:10:00+00:00', '2024-10-21T18:10:00+00:00', '2024-10-21T19:10:00+00:00', '2024-10-21T22:10:00+00:00', '2024-10-22T00:10:00+00:00', '2024-10-22T01:10:00+00:00', '2024-10-22T03:10:00+00:00', '2024-10-22T05:10:00+00:00', '2024-10-22T13:10:00+00:00', '2024-10-22T14:10:00+00:00', '2024-10-22T17:10:00+00:00', '2024-10-22T18:10:00+00:00', '2024-10-22T19:10:00+00:00', '2024-10-22T22:10:00+00:00', '2024-10-23T00:10:00+00:00', '2024-10-23T01:10:00+00:00', '2024-10-23T03:10:00+00:00']
2024-10-21 12:42:52.661 DEBUG (SyncWorker_5) [custom_components.gtfs2.gtfs_helper] Timetable Remaining Departures on this Start/Stop, per line: ['2024-10-21T22:10:00+00:00 (None/Pacific Surfliner)', '2024-10-22T00:10:00+00:00 (None/Pacific Surfliner)', '2024-10-22T01:10:00+00:00 (None/Pacific Surfliner)', '2024-10-22T03:10:00+00:00 (None/Pacific Surfliner)', '2024-10-22T05:10:00+00:00 (None/Pacific Surfliner)', '2024-10-22T13:10:00+00:00 (None/Pacific Surfliner)', '2024-10-22T14:10:00+00:00 (None/Pacific Surfliner)', '2024-10-22T17:10:00+00:00 (None/Pacific Surfliner)', '2024-10-22T18:10:00+00:00 (None/Pacific Surfliner)', '2024-10-22T19:10:00+00:00 (None/Pacific Surfliner)', '2024-10-22T22:10:00+00:00 (None/Pacific Surfliner)', '2024-10-23T00:10:00+00:00 (None/Pacific Surfliner)', '2024-10-23T01:10:00+00:00 (None/Pacific Surfliner)', '2024-10-23T03:10:00+00:00 (None/Pacific Surfliner)']
2024-10-21 12:42:52.661 DEBUG (SyncWorker_5) [custom_components.gtfs2.gtfs_helper] Timetable Remaining Departures on this Start/Stop, with headsign: ['2024-10-21T22:10:00+00:00 (San Diego)', '2024-10-22T00:10:00+00:00 (San Diego)', '2024-10-22T01:10:00+00:00 (San Diego)', '2024-10-22T03:10:00+00:00 (San Diego)', '2024-10-22T05:10:00+00:00 (San Diego)', '2024-10-22T13:10:00+00:00 (San Diego)', '2024-10-22T14:10:00+00:00 (San Diego)', '2024-10-22T17:10:00+00:00 (San Diego)', '2024-10-22T18:10:00+00:00 (San Diego)', '2024-10-22T19:10:00+00:00 (San Diego)', '2024-10-22T22:10:00+00:00 (San Diego)', '2024-10-23T00:10:00+00:00 (San Diego)', '2024-10-23T01:10:00+00:00 (San Diego)', '2024-10-23T03:10:00+00:00 (San Diego)']
2024-10-21 12:42:52.661 DEBUG (SyncWorker_5) [custom_components.gtfs2.gtfs_helper] Time is 'tomorrow': True ,based on -> tomorrow_val: 1, calendar_date val: , now_date val: 2024-10-21
2024-10-21 12:42:52.664 DEBUG (MainThread) [custom_components.gtfs2.coordinator] GTFS coordinator data from helper: {'trip_id': '103093', 'route_id': '78', 'day': 'today', 'first': False, 'last': False, 'origin_stop_id': 'LAX', 'origin_stop_name': 'Los Angeles', 'departure_time': datetime.datetime(2024, 10, 21, 14, 10, tzinfo=zoneinfo.ZoneInfo(key='America/New_York')), 'arrival_time': datetime.datetime(2024, 10, 21, 14, 48, tzinfo=zoneinfo.ZoneInfo(key='America/New_York')), 'origin_stop_time': {'Arrival Time': '2024-10-21T21:10:00+00:00', 'Departure Time': '2024-10-21T21:10:00+00:00', 'Drop Off Type': 0, 'Pickup Type': 0, 'Shape Dist Traveled': None, 'Headsign': None, 'Sequence': 1, 'Timepoint': 1}, 'origin_stop_timezone': 'America/Los_Angeles', 'destination_stop_time': {'Arrival Time': '2024-10-21T21:48:00+00:00', 'Departure Time': '2024-10-21T21:49:00+00:00', 'Drop Off Type': 0, 'Pickup Type': 0, 'Shape Dist Traveled': None, 'Headsign': None, 'Sequence': 3, 'Timepoint': 1}, 'destination_stop_timezone': 'America/Los_Angeles', 'destination_stop_name': 'Anaheim', 'next_departures': ['2024-10-21T17:10:00+00:00', '2024-10-21T18:10:00+00:00', '2024-10-21T19:10:00+00:00', '2024-10-21T22:10:00+00:00', '2024-10-22T00:10:00+00:00', '2024-10-22T01:10:00+00:00', '2024-10-22T03:10:00+00:00', '2024-10-22T05:10:00+00:00', '2024-10-22T13:10:00+00:00', '2024-10-22T14:10:00+00:00', '2024-10-22T17:10:00+00:00', '2024-10-22T18:10:00+00:00', '2024-10-22T19:10:00+00:00', '2024-10-22T22:10:00+00:00', '2024-10-23T00:10:00+00:00', '2024-10-23T01:10:00+00:00', '2024-10-23T03:10:00+00:00'], 'next_departures_lines': ['2024-10-21T22:10:00+00:00 (None/Pacific Surfliner)', '2024-10-22T00:10:00+00:00 (None/Pacific Surfliner)', '2024-10-22T01:10:00+00:00 (None/Pacific Surfliner)', '2024-10-22T03:10:00+00:00 (None/Pacific Surfliner)', '2024-10-22T05:10:00+00:00 (None/Pacific Surfliner)', '2024-10-22T13:10:00+00:00 (None/Pacific Surfliner)', '2024-10-22T14:10:00+00:00 (None/Pacific Surfliner)', '2024-10-22T17:10:00+00:00 (None/Pacific Surfliner)', '2024-10-22T18:10:00+00:00 (None/Pacific Surfliner)', '2024-10-22T19:10:00+00:00 (None/Pacific Surfliner)', '2024-10-22T22:10:00+00:00 (None/Pacific Surfliner)', '2024-10-23T00:10:00+00:00 (None/Pacific Surfliner)', '2024-10-23T01:10:00+00:00 (None/Pacific Surfliner)', '2024-10-23T03:10:00+00:00 (None/Pacific Surfliner)'], 'next_departures_headsign': ['2024-10-21T22:10:00+00:00 (San Diego)', '2024-10-22T00:10:00+00:00 (San Diego)', '2024-10-22T01:10:00+00:00 (San Diego)', '2024-10-22T03:10:00+00:00 (San Diego)', '2024-10-22T05:10:00+00:00 (San Diego)', '2024-10-22T13:10:00+00:00 (San Diego)', '2024-10-22T14:10:00+00:00 (San Diego)', '2024-10-22T17:10:00+00:00 (San Diego)', '2024-10-22T18:10:00+00:00 (San Diego)', '2024-10-22T19:10:00+00:00 (San Diego)', '2024-10-22T22:10:00+00:00 (San Diego)', '2024-10-23T00:10:00+00:00 (San Diego)', '2024-10-23T01:10:00+00:00 (San Diego)', '2024-10-23T03:10:00+00:00 (San Diego)']}
2024-10-21 12:42:52.664 DEBUG (MainThread) [custom_components.gtfs2.coordinator] GTFS RT: RealTime = false, selected in entity options
2024-10-21 12:42:52.664 DEBUG (MainThread) [custom_components.gtfs2.coordinator] Finished fetching 01J9GAEQGHF6Q888NM0XHF6XKQ data in 0.026 seconds (success: True)
2024-10-21 12:42:52.664 DEBUG (MainThread) [custom_components.gtfs2.sensor] SENSOR update attr data: {'schedule': <pygtfs.schedule.Schedule object at 0x758816d33bf0>, 'origin': 'Los Angeles', 'destination': 'Anaheim', 'offset': 60, 'include_tomorrow': True, 'gtfs_dir': 'gtfs2', 'name': 'LA Union Station -> Anaheim', 'file': 'Amtrak', 'route_type': '2', 'extracting': False, 'next_departure': {'trip_id': '103093', 'route_id': '78', 'day': 'today', 'first': False, 'last': False, 'origin_stop_id': 'LAX', 'origin_stop_name': 'Los Angeles', 'departure_time': datetime.datetime(2024, 10, 21, 14, 10, tzinfo=zoneinfo.ZoneInfo(key='America/New_York')), 'arrival_time': datetime.datetime(2024, 10, 21, 14, 48, tzinfo=zoneinfo.ZoneInfo(key='America/New_York')), 'origin_stop_time': {'Arrival Time': '2024-10-21T21:10:00+00:00', 'Departure Time': '2024-10-21T21:10:00+00:00', 'Drop Off Type': 0, 'Pickup Type': 0, 'Shape Dist Traveled': None, 'Headsign': None, 'Sequence': 1, 'Timepoint': 1}, 'origin_stop_timezone': 'America/Los_Angeles', 'destination_stop_time': {'Arrival Time': '2024-10-21T21:48:00+00:00', 'Departure Time': '2024-10-21T21:49:00+00:00', 'Drop Off Type': 0, 'Pickup Type': 0, 'Shape Dist Traveled': None, 'Headsign': None, 'Sequence': 3, 'Timepoint': 1}, 'destination_stop_timezone': 'America/Los_Angeles', 'destination_stop_name': 'Anaheim', 'next_departures': ['2024-10-21T17:10:00+00:00', '2024-10-21T18:10:00+00:00', '2024-10-21T19:10:00+00:00', '2024-10-21T22:10:00+00:00', '2024-10-22T00:10:00+00:00', '2024-10-22T01:10:00+00:00', '2024-10-22T03:10:00+00:00', '2024-10-22T05:10:00+00:00', '2024-10-22T13:10:00+00:00', '2024-10-22T14:10:00+00:00', '2024-10-22T17:10:00+00:00', '2024-10-22T18:10:00+00:00', '2024-10-22T19:10:00+00:00', '2024-10-22T22:10:00+00:00', '2024-10-23T00:10:00+00:00', '2024-10-23T01:10:00+00:00', '2024-10-23T03:10:00+00:00'], 'next_departures_lines': ['2024-10-21T22:10:00+00:00 (None/Pacific Surfliner)', '2024-10-22T00:10:00+00:00 (None/Pacific Surfliner)', '2024-10-22T01:10:00+00:00 (None/Pacific Surfliner)', '2024-10-22T03:10:00+00:00 (None/Pacific Surfliner)', '2024-10-22T05:10:00+00:00 (None/Pacific Surfliner)', '2024-10-22T13:10:00+00:00 (None/Pacific Surfliner)', '2024-10-22T14:10:00+00:00 (None/Pacific Surfliner)', '2024-10-22T17:10:00+00:00 (None/Pacific Surfliner)', '2024-10-22T18:10:00+00:00 (None/Pacific Surfliner)', '2024-10-22T19:10:00+00:00 (None/Pacific Surfliner)', '2024-10-22T22:10:00+00:00 (None/Pacific Surfliner)', '2024-10-23T00:10:00+00:00 (None/Pacific Surfliner)', '2024-10-23T01:10:00+00:00 (None/Pacific Surfliner)', '2024-10-23T03:10:00+00:00 (None/Pacific Surfliner)'], 'next_departures_headsign': ['2024-10-21T22:10:00+00:00 (San Diego)', '2024-10-22T00:10:00+00:00 (San Diego)', '2024-10-22T01:10:00+00:00 (San Diego)', '2024-10-22T03:10:00+00:00 (San Diego)', '2024-10-22T05:10:00+00:00 (San Diego)', '2024-10-22T13:10:00+00:00 (San Diego)', '2024-10-22T14:10:00+00:00 (San Diego)', '2024-10-22T17:10:00+00:00 (San Diego)', '2024-10-22T18:10:00+00:00 (San Diego)', '2024-10-22T19:10:00+00:00 (San Diego)', '2024-10-22T22:10:00+00:00 (San Diego)', '2024-10-23T00:10:00+00:00 (San Diego)', '2024-10-23T01:10:00+00:00 (San Diego)', '2024-10-23T03:10:00+00:00 (San Diego)']}, 'next_departure_realtime_attr': {}, 'alert': {}, 'gtfs_updated_at': '2024-10-21T19:42:52.664500+00:00'}
2024-10-21 12:42:52.664 DEBUG (MainThread) [custom_components.gtfs2.sensor] Fetching trip details for 103093
2024-10-21 12:42:52.666 DEBUG (MainThread) [custom_components.gtfs2.sensor] Fetching route details for 78
2024-10-21 12:42:52.668 DEBUG (MainThread) [custom_components.gtfs2.sensor] Fetching agency details for 51
2024-10-21 12:42:52.670 DEBUG (MainThread) [custom_components.gtfs2.sensor] Self._departure time from helper: {datetime.datetime(2024, 10, 21, 14, 10, tzinfo=zoneinfo.ZoneInfo(key='America/New_York'))}
2024-10-21 12:42:52.671 DEBUG (MainThread) [custom_components.gtfs2.sensor] Destination_stop_time {'Arrival Time': '2024-10-21T21:48:00+00:00', 'Departure Time': '2024-10-21T21:49:00+00:00', 'Drop Off Type': 0, 'Pickup Type': 0, 'Shape Dist Traveled': None, 'Headsign': None, 'Sequence': 3, 'Timepoint': 1}
2024-10-21 12:42:52.671 DEBUG (MainThread) [custom_components.gtfs2.sensor] No next departure realtime attributes
Interestingly, just reverted to beta2, and it's outputting 13:10 Amer/LA
There is no train at that time.
It appears that beta2 has the same issue (in terms of identifying the wrong train due to inconsistent TZ between "now" and the schedule) as beta3, just that it then sets the arrival/departure time forward after finding the train. This is backed up as despite the value being sensor value being 13:10, it's indicating train# 770 (i.e. train departing at 10:10 Amer/LA).
My testing last night didn't catch this as I was just looking at the times not the train numbers.
So beta2/beta3 have the same underlying train selection issue, but beta3 outputs the times of the selected trains correctly.
Working through the issue adding logs and doing some minor refactoring. Will open a PR in a day or two.
I am on it, I may reject your PR so advice is to not spend time. Reason: often PR are viewed from single use case and I donot have the time to test if others have been taken into account
I aligned the other next_departure elements now. The sensor shows this and that is fine for what what I see on amtrak.com Will post on b4 later
next_departures: 2024-10-22T22:10:00+00:00, 2024-10-23T00:10:00+00:00, 2024-10-23T01:10:00+00:00, 2024-10-23T03:10:00+00:00, 2024-10-23T05:10:00+00:00
next_departures_lines: 2024-10-22T22:10:00+00:00 (None/Pacific Surfliner), 2024-10-23T00:10:00+00:00 (None/Pacific Surfliner), 2024-10-23T01:10:00+00:00 (None/Pacific Surfliner), 2024-10-23T03:10:00+00:00 (None/Pacific Surfliner), 2024-10-23T05:10:00+00:00 (None/Pacific Surfliner)
next_departures_headsign: 2024-10-22T22:10:00+00:00 (San Diego), 2024-10-23T00:10:00+00:00 (San Diego), 2024-10-23T01:10:00+00:00 (San Diego), 2024-10-23T03:10:00+00:00 (San Diego), 2024-10-23T05:10:00+00:00 (San Diego)
The local-stop setup is more complex as the sensor shows only the time in local TZ but without any TZ so I am still working on that.
beta4 seems fine for my 3 different countries/sources and your amtrak. EDIT: no it does not...sorry, back to the drawing board, it extracts the correct (!) departures but fails to skip the ones in the past EDIT2: I am running into more issues due to inherited code from HA gtfs. Need to revise a bit more, luckily I have more time The local-stop is giving me a headache :(
Am in the right directoin now but is taking time as it also has to cover for times that are shown as next day (01:00) but with timezone are in fact today. The big challenge here is that the code has to extract data to find out stop-timezone and agency-timezone to THEN rework that and re-apply, meaning that a initially found next departure time may not be the next due to the timezone correction. I will have to do some more tests with sensors that also extract times for 'tomorrow' and then I will post a new release for you to look at.
Try this please https://github.com/vingerha/gtfs2/releases/tag/0.5.2-beta4 Start/stop seems fine now, esp. the cross-midnight ones were challenging Then I spent a lot of time finding out a similar solution for the local-stop but since this works differently, I have to appl a new configurable 'option' to correct the TZ of the source. Tested it with Union station and a correction of 3 hours (between NY and LA), which seems to work fine too. The thing I have not tested is effects of real-time / delays on the local-stop.... maybe near future
Closing as no further feedback
Describe the bug For each of the questions below add you data
Note that clairvoyancy does not exist ... no details = no response
Ex. Amtrak agency.txt specifies TZ = America/New_York (EDT UTC-4) I live on the west coast in America/Los_Angeles (PDT UTC-7)
When identifying the next train, at say 15:15 PDT, GTFS2 returns these for the next trains: October 6, 2024 at 18:10:00 (trip 105078), October 6, 2024 at 20:10:00, October 6, 2024 at 21:10:00, October 6, 2024 at 23:10:00 October 7, 2024 at 01:10:00
The actual next trains are: 17:10 PDT / 20:10 EDT 18:10 PDT / 21:10 EDT 20:10 PDT / 23:10 EDT 22:10 PDT / 01:10 EDT
The train returned that departs at 18:10 is a real train, but it left at 15:10 PDT
Result is that GTFS2 sensor says the next train was 5 minutes ago.
Datasource(s). https://content.amtrak.com/content/gtfs/GTFS.zip
In case of setup using start / stop station
In case of location based setup
Release used
Additional Please add logs