vingerha / gtfs2

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

Sensor becomes unavailable upon receiving RT update with parsing error #63

Closed jebissell closed 2 months ago

jebissell commented 2 months ago

Describe the bug Though all was working in 0.4.4.4 until 8 days ago, upon updating to 0.4.5 I see the behavior from the Rome, Italy, system that as soon as an RT update is requested, and generates an error, the entities configured for RT become unavailable. If I turn off the real time slider, the entity becomes available again after the next update of the feed.

Steps/data to reproduce the behavior, e.g.

Rome Atac's real time feeds are just as inconsistent as the buses themselves are unreliable. Line 360 rarely shows RT data (echoed by other apps) while line 85 is a major one and usually is updating. The operator obviously is not going to fix their feed immediately, but it would be nice if the sensor can fail gracefully in the absence of an update. It could behave like before and simply not show any real time departures.

The error thrown after fetching the real time feed appears to be 'dict' object has no attribute 'HasField'

Release used HAOS 12.2, Core 2024.4.4 (also same problem on other server using Supervised install)

Additional

1. Expected, normal response for Bus Line 360 never enabled for RT:

2024-04-23 22:34:05.128 DEBUG (MainThread) [custom_components.gtfs2.coordinator] Previous data: {'schedule': <pygtfs.schedule.Schedule object at 0x542f3ee8>, 'origin': '70466: MUSE (1)', 'destination': '10209: TERMINI (MA-MB-FS) (15)', 'offset': 0, 'include_tomorrow': False, 'gtfs_dir': 'gtfs2', 'name': '360 to Termini', 'file': 'Atac', 'route_type': '99', 'extracting': False, 'next_departure': {'trip_id': '0#4701-18', 'route_id': '360', 'day': 'today', 'first': False, 'last': False, 'origin_stop_id': '70466', 'origin_stop_name': 'MUSE', 'departure_time': datetime.datetime(2024, 4, 23, 22, 42, tzinfo=zoneinfo.ZoneInfo(key='America/New_York')), 'arrival_time': datetime.datetime(2024, 4, 23, 22, 59, 16, tzinfo=zoneinfo.ZoneInfo(key='America/New_York')), 'origin_stop_time': {'Arrival Time': '2024-04-24T02:42:00+00:00', 'Departure Time': '2024-04-24T02:42:00+00:00', 'Drop Off Type': None, 'Pickup Type': None, 'Shape Dist Traveled': 0, 'Headsign': None, 'Sequence': 1, 'Timepoint': 1}, 'destination_stop_time': {'Arrival Time': '2024-04-24T02:59:16+00:00', 'Departure Time': '2024-04-24T02:59:16+00:00', 'Drop Off Type': None, 'Pickup Type': None, 'Shape Dist Traveled': 4244, 'Headsign': None, 'Sequence': 13, 'Timepoint': 0}, 'destination_stop_name': 'TERMINI (MA-MB-FS)', 'next_departures': ['2024-04-24T02:42:00+00:00', '2024-04-24T03:01:00+00:00', '2024-04-24T03:20:00+00:00', '2024-04-24T03:40:00+00:00', '2024-04-24T04:00:00+00:00'], 'next_departures_lines': ['2024-04-24T02:42:00+00:00 (360)', '2024-04-24T03:01:00+00:00 (360)', '2024-04-24T03:20:00+00:00 (360)', '2024-04-24T03:40:00+00:00 (360)', '2024-04-24T04:00:00+00:00 (360)'], 'next_departures_headsign': ['2024-04-24T02:42:00+00:00 (ZAMA)', '2024-04-24T03:01:00+00:00 (ZAMA)', '2024-04-24T03:20:00+00:00 (ZAMA)', '2024-04-24T03:40:00+00:00 (ZAMA)', '2024-04-24T04:00:00+00:00 (ZAMA)']}, 'next_departure_realtime_attr': {}, 'alert': {}, 'gtfs_updated_at': '2024-04-24T02:23:05.747779+00:00'} 2024-04-23 22:34:05.129 DEBUG (MainThread) [custom_components.gtfs2.gtfs_helper] Getting gtfs with data: {'file': 'Atac', 'url': 'na', 'extract_from': 'zip', 'agency': 'OP1: Atac', 'route_type': '99', 'route': '360: 360 (None) - Atac', 'direction': '0', 'origin': '70466: MUSE (1)', 'destination': '10209: TERMINI (MA-MB-FS) (15)', 'name': '360 to Termini', 'include_tomorrow': False} 2024-04-23 22:34:05.132 DEBUG (MainThread) [custom_components.gtfs2.gtfs_helper] Checking if extracting: Atac 2024-04-23 22:34:05.166 DEBUG (MainThread) [custom_components.gtfs2.gtfs_helper] Checking if extracting: Atac 2024-04-23 22:34:05.169 DEBUG (MainThread) [custom_components.gtfs2.coordinator] No run static refresh: sensor exists but not yet refresh for name: 360 to Termini 2024-04-23 22:34:05.169 DEBUG (MainThread) [custom_components.gtfs2.coordinator] GTFS RT: RealTime not selected in entity options 2024-04-23 22:34:05.169 DEBUG (MainThread) [custom_components.gtfs2.coordinator] Finished fetching 07cda265958b49cfbca18322d0755943 data in 0.041 seconds (success: True) 2024-04-23 22:34:05.170 DEBUG (MainThread) [custom_components.gtfs2.sensor] SENSOR update attr data: {'schedule': <pygtfs.schedule.Schedule object at 0x542f3ee8>, 'origin': '70466: MUSE (1)', 'destination': '10209: TERMINI (MA-MB-FS) (15)', 'offset': 0, 'include_tomorrow': False, 'gtfs_dir': 'gtfs2', 'name': '360 to Termini', 'file': 'Atac', 'route_type': '99', 'extracting': False, 'next_departure': {'trip_id': '0#4701-18', 'route_id': '360', 'day': 'today', 'first': False, 'last': False, 'origin_stop_id': '70466', 'origin_stop_name': 'MUSE', 'departure_time': datetime.datetime(2024, 4, 23, 22, 42, tzinfo=zoneinfo.ZoneInfo(key='America/New_York')), 'arrival_time': datetime.datetime(2024, 4, 23, 22, 59, 16, tzinfo=zoneinfo.ZoneInfo(key='America/New_York')), 'origin_stop_time': {'Arrival Time': '2024-04-24T02:42:00+00:00', 'Departure Time': '2024-04-24T02:42:00+00:00', 'Drop Off Type': None, 'Pickup Type': None, 'Shape Dist Traveled': 0, 'Headsign': None, 'Sequence': 1, 'Timepoint': 1}, 'destination_stop_time': {'Arrival Time': '2024-04-24T02:59:16+00:00', 'Departure Time': '2024-04-24T02:59:16+00:00', 'Drop Off Type': None, 'Pickup Type': None, 'Shape Dist Traveled': 4244, 'Headsign': None, 'Sequence': 13, 'Timepoint': 0}, 'destination_stop_name': 'TERMINI (MA-MB-FS)', 'next_departures': ['2024-04-24T02:42:00+00:00', '2024-04-24T03:01:00+00:00', '2024-04-24T03:20:00+00:00', '2024-04-24T03:40:00+00:00', '2024-04-24T04:00:00+00:00'], 'next_departures_lines': ['2024-04-24T02:42:00+00:00 (360)', '2024-04-24T03:01:00+00:00 (360)', '2024-04-24T03:20:00+00:00 (360)', '2024-04-24T03:40:00+00:00 (360)', '2024-04-24T04:00:00+00:00 (360)'], 'next_departures_headsign': ['2024-04-24T02:42:00+00:00 (ZAMA)', '2024-04-24T03:01:00+00:00 (ZAMA)', '2024-04-24T03:20:00+00:00 (ZAMA)', '2024-04-24T03:40:00+00:00 (ZAMA)', '2024-04-24T04:00:00+00:00 (ZAMA)']}, 'next_departure_realtime_attr': {}, 'alert': {}, 'gtfs_updated_at': '2024-04-24T02:23:05.747779+00:00'} 2024-04-23 22:34:05.180 DEBUG (MainThread) [custom_components.gtfs2.sensor] Fetching trip details for 0#4701-18 2024-04-23 22:34:05.185 DEBUG (MainThread) [custom_components.gtfs2.sensor] Fetching route details for 360 2024-04-23 22:34:05.190 DEBUG (MainThread) [custom_components.gtfs2.sensor] Fetching agency details for OP1 2024-04-23 22:34:05.195 DEBUG (MainThread) [custom_components.gtfs2.sensor] Self._departure time for state value TZ: {datetime.datetime(2024, 4, 23, 22, 42, tzinfo=zoneinfo.ZoneInfo(key='America/New_York'))} 2024-04-23 22:34:05.200 DEBUG (MainThread) [custom_components.gtfs2.sensor] Destination_stop_time {'Arrival Time': '2024-04-24T02:59:16+00:00', 'Departure Time': '2024-04-24T02:59:16+00:00', 'Drop Off Type': None, 'Pickup Type': None, 'Shape Dist Traveled': 4244, 'Headsign': None, 'Sequence': 13, 'Timepoint': 0} 2024-04-23 22:34:05.201 DEBUG (MainThread) [custom_components.gtfs2.sensor] No next departure realtime attributes '

2. Error when Bus Line 85 has RT enabled--sensor becomes unavailable after this error

2024-04-23 22:34:18.141 DEBUG (MainThread) [custom_components.gtfs2.coordinator] Previous data: {'schedule': <pygtfs.schedule.Schedule object at 0x5bb38870>, 'origin': '81908: ARCO DI TRAVERTINO (MA) (1)', 'destination': '80746: TERMINI (MA-MB-FS) (36)', 'offset': 0, 'include_tomorrow': False, 'gtfs_dir': 'gtfs2', 'name': '85 to Termini', 'file': 'Atac', 'route_type': '99', 'extracting': False, 'next_departure': {'trip_id': '0#5945-19', 'route_id': '85', 'day': 'today', 'first': False, 'last': False, 'origin_stop_id': '81908', 'origin_stop_name': 'ARCO DI TRAVERTINO (MA)', 'departure_time': datetime.datetime(2024, 4, 23, 22, 25, tzinfo=zoneinfo.ZoneInfo(key='America/New_York')), 'arrival_time': datetime.datetime(2024, 4, 23, 23, 9, tzinfo=zoneinfo.ZoneInfo(key='America/New_York')), 'origin_stop_time': {'Arrival Time': '2024-04-24T02:25:00+00:00', 'Departure Time': '2024-04-24T02:25:00+00:00', 'Drop Off Type': None, 'Pickup Type': None, 'Shape Dist Traveled': 0, 'Headsign': None, 'Sequence': 1, 'Timepoint': 1}, 'destination_stop_time': {'Arrival Time': '2024-04-24T03:09:00+00:00', 'Departure Time': '2024-04-24T03:09:00+00:00', 'Drop Off Type': None, 'Pickup Type': None, 'Shape Dist Traveled': 10012, 'Headsign': None, 'Sequence': 33, 'Timepoint': 1}, 'destination_stop_name': 'TERMINI (MA-MB-FS)', 'next_departures': ['2024-04-24T02:25:00+00:00', '2024-04-24T02:42:00+00:00', '2024-04-24T02:58:00+00:00', '2024-04-24T03:14:00+00:00', '2024-04-24T03:29:00+00:00', '2024-04-24T03:45:00+00:00', '2024-04-24T04:00:00+00:00'], 'next_departures_lines': ['2024-04-24T02:25:00+00:00 (85)', '2024-04-24T02:42:00+00:00 (85)', '2024-04-24T02:58:00+00:00 (85)', '2024-04-24T03:14:00+00:00 (85)', '2024-04-24T03:29:00+00:00 (85)', '2024-04-24T03:45:00+00:00 (85)', '2024-04-24T04:00:00+00:00 (85)'], 'next_departures_headsign': ['2024-04-24T02:25:00+00:00 (TERMINI (MA-MB-FS))', '2024-04-24T02:42:00+00:00 (TERMINI (MA-MB-FS))', '2024-04-24T02:58:00+00:00 (TERMINI (MA-MB-FS))', '2024-04-24T03:14:00+00:00 (TERMINI (MA-MB-FS))', '2024-04-24T03:29:00+00:00 (TERMINI (MA-MB-FS))', '2024-04-24T03:45:00+00:00 (TERMINI (MA-MB-FS))', '2024-04-24T04:00:00+00:00 (TERMINI (MA-MB-FS))']}, 'next_departure_realtime_attr': {}, 'alert': {}, 'gtfs_updated_at': '2024-04-24T02:21:56.923457+00:00'} 2024-04-23 22:34:18.142 DEBUG (MainThread) [custom_components.gtfs2.gtfs_helper] Getting gtfs with data: {'file': 'Atac', 'url': 'na', 'extract_from': 'zip', 'agency': 'OP1: Atac', 'route_type': '99', 'route': '85: 85 (None) - Atac', 'direction': '0', 'origin': '81908: ARCO DI TRAVERTINO (MA) (1)', 'destination': '80746: TERMINI (MA-MB-FS) (36)', 'name': '85 to Termini', 'include_tomorrow': False} 2024-04-23 22:34:18.144 DEBUG (MainThread) [custom_components.gtfs2.gtfs_helper] Checking if extracting: Atac 2024-04-23 22:34:18.193 DEBUG (MainThread) [custom_components.gtfs2.gtfs_helper] Checking if extracting: Atac 2024-04-23 22:34:18.195 DEBUG (MainThread) [custom_components.gtfs2.coordinator] No run static refresh: sensor exists but not yet refresh for name: 85 to Termini 2024-04-23 22:34:18.196 DEBUG (SyncWorker_7) [custom_components.gtfs2.gtfs_rt_helper] GTFS RT get_feed_entities for url: https://romamobilita.it/sites/default/files/rome_rtgtfs_service_alerts_feed.pb , headers: None, label: alerts 2024-04-23 22:34:25.384 DEBUG (SyncWorker_7) [custom_components.gtfs2.gtfs_rt_helper] Successfully updated alerts 2024-04-23 22:34:25.385 DEBUG (SyncWorker_7) [custom_components.gtfs2.gtfs_rt_helper] Feed : 2024-04-23 22:34:25.415 ERROR (MainThread) [custom_components.gtfs2.coordinator] Error getting gtfs realtime data, for origin: 81908: ARCO DI TRAVERTINO (MA) (1) with error: 'dict' object has no attribute 'HasField' 2024-04-23 22:34:25.416 ERROR (MainThread) [custom_components.gtfs2.coordinator] Unexpected error fetching bd74bfe0a6f429bb51e171b648da77c7 data: name 'err' is not defined Traceback (most recent call last): File "/config/custom_components/gtfs2/coordinator.py", line 159, in _async_update_data self._get_rt_alerts = await self.hass.async_add_executor_job(get_rt_alerts, self) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/concurrent/futures/thread.py", line 58, in run result = self.fn(*self.args, **self.kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/gtfs2/gtfs_rt_helper.py", line 309, in get_rt_alerts if entity.HasField("alert"): ^^^^^^^^^^^^^^^ AttributeError: 'dict' object has no attribute 'HasField'

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 315, in _async_refresh self.data = await self._async_update_data() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/gtfs2/coordinator.py", line 166, in _async_update_data raise UpdateFailed(f"Error in getting start/end stop data: {err}") ^^^ NameError: name 'err' is not defined 2024-04-23 22:34:25.462 DEBUG (MainThread) [custom_components.gtfs2.coordinator] Finished fetching bd74bfe0a6f429bb51e171b648da77c7 data in 7.321 seconds (success: False)

3 Normal response for Bus Line 85 after disabling RT

2024-04-23 22:55:18.140 DEBUG (MainThread) [custom_components.gtfs2.gtfs_helper] Getting gtfs with data: {'file': 'Atac', 'url': 'na', 'extract_from': 'zip', 'agency': 'OP1: Atac', 'route_type': '99', 'route': '85: 85 (None) - Atac', 'direction': '0', 'origin': '81908: ARCO DI TRAVERTINO (MA) (1)', 'destination': '80746: TERMINI (MA-MB-FS) (36)', 'name': '85 to Termini', 'include_tomorrow': False} 2024-04-23 22:55:18.142 DEBUG (MainThread) [custom_components.gtfs2.gtfs_helper] Checking if extracting: Atac 2024-04-23 22:55:18.178 DEBUG (MainThread) [custom_components.gtfs2.gtfs_helper] Checking if extracting: Atac 2024-04-23 22:55:18.180 DEBUG (MainThread) [custom_components.gtfs2.coordinator] No run static refresh: sensor exists but not yet refresh for name: 85 to Termini 2024-04-23 22:55:18.180 DEBUG (MainThread) [custom_components.gtfs2.coordinator] GTFS RT: RealTime = false, selected in entity options 2024-04-23 22:55:18.180 DEBUG (MainThread) [custom_components.gtfs2.coordinator] Finished fetching bd74bfe0a6f429bb51e171b648da77c7 data in 0.041 seconds (success: True) 2024-04-23 22:55:18.181 DEBUG (MainThread) [custom_components.gtfs2.sensor] SENSOR update attr data: {'schedule': <pygtfs.schedule.Schedule object at 0x56b97750>, 'origin': '81908: ARCO DI TRAVERTINO (MA) (1)', 'destination': '80746: TERMINI (MA-MB-FS) (36)', 'offset': 0, 'include_tomorrow': False, 'gtfs_dir': 'gtfs2', 'name': '85 to Termini', 'file': 'Atac', 'route_type': '99', 'extracting': False, 'next_departure': {'trip_id': '0#5951-18', 'route_id': '85', 'day': 'today', 'first': False, 'last': False, 'origin_stop_id': '81908', 'origin_stop_name': 'ARCO DI TRAVERTINO (MA)', 'departure_time': datetime.datetime(2024, 4, 23, 22, 58, tzinfo=zoneinfo.ZoneInfo(key='America/New_York')), 'arrival_time': datetime.datetime(2024, 4, 23, 23, 40, tzinfo=zoneinfo.ZoneInfo(key='America/New_York')), 'origin_stop_time': {'Arrival Time': '2024-04-24T02:58:00+00:00', 'Departure Time': '2024-04-24T02:58:00+00:00', 'Drop Off Type': None, 'Pickup Type': None, 'Shape Dist Traveled': 0, 'Headsign': None, 'Sequence': 1, 'Timepoint': 1}, 'destination_stop_time': {'Arrival Time': '2024-04-24T03:40:00+00:00', 'Departure Time': '2024-04-24T03:40:00+00:00', 'Drop Off Type': None, 'Pickup Type': None, 'Shape Dist Traveled': 10012, 'Headsign': None, 'Sequence': 33, 'Timepoint': 1}, 'destination_stop_name': 'TERMINI (MA-MB-FS)', 'next_departures': ['2024-04-24T02:58:00+00:00', '2024-04-24T03:14:00+00:00', '2024-04-24T03:29:00+00:00', '2024-04-24T03:45:00+00:00', '2024-04-24T04:00:00+00:00'], 'next_departures_lines': ['2024-04-24T02:58:00+00:00 (85)', '2024-04-24T03:14:00+00:00 (85)', '2024-04-24T03:29:00+00:00 (85)', '2024-04-24T03:45:00+00:00 (85)', '2024-04-24T04:00:00+00:00 (85)'], 'next_departures_headsign': ['2024-04-24T02:58:00+00:00 (TERMINI (MA-MB-FS))', '2024-04-24T03:14:00+00:00 (TERMINI (MA-MB-FS))', '2024-04-24T03:29:00+00:00 (TERMINI (MA-MB-FS))', '2024-04-24T03:45:00+00:00 (TERMINI (MA-MB-FS))', '2024-04-24T04:00:00+00:00 (TERMINI (MA-MB-FS))']}, 'next_departure_realtime_attr': {}, 'alert': {}, 'gtfs_updated_at': '2024-04-24T02:45:18.418493+00:00'} 2024-04-23 22:55:18.190 DEBUG (MainThread) [custom_components.gtfs2.sensor] Fetching trip details for 0#5951-18 2024-04-23 22:55:18.194 DEBUG (MainThread) [custom_components.gtfs2.sensor] Fetching route details for 85 2024-04-23 22:55:18.199 DEBUG (MainThread) [custom_components.gtfs2.sensor] Fetching agency details for OP1 2024-04-23 22:55:18.203 DEBUG (MainThread) [custom_components.gtfs2.sensor] Self._departure time for state value TZ: {datetime.datetime(2024, 4, 23, 22, 58, tzinfo=zoneinfo.ZoneInfo(key='America/New_York'))} 2024-04-23 22:55:18.207 DEBUG (MainThread) [custom_components.gtfs2.sensor] Destination_stop_time {'Arrival Time': '2024-04-24T03:40:00+00:00', 'Departure Time': '2024-04-24T03:40:00+00:00', 'Drop Off Type': None, 'Pickup Type': None, 'Shape Dist Traveled': 10012, 'Headsign': None, 'Sequence': 33, 'Timepoint': 1} 2024-04-23 22:55:18.209 DEBUG (MainThread) [custom_components.gtfs2.sensor] No next departure realtime attributes

jebissell commented 2 months ago

I downgraded to 0.4.4.7 and received this HasField error for bus line 85, but the entity was not disabled:

2024-04-24 00:25:37.144 DEBUG (MainThread) [custom_components.gtfs2.gtfs_helper] Getting gtfs with data: {'file': 'Atac', 'url': 'na', 'extract_from': 'zip', 'agency': 'OP1: Atac', 'route_type': '99', 'route': '85: 85 (None) - Atac', 'direction': '0', 'origin': '81908: ARCO DI TRAVERTINO (MA) (1)', 'destination': '80746: TERMINI (MA-MB-FS) (36)', 'name': '85 to Termini', 'include_tomorrow': False} 2024-04-24 00:25:37.147 DEBUG (MainThread) [custom_components.gtfs2.gtfs_helper] Checking if extracting: Atac 2024-04-24 00:25:37.183 DEBUG (MainThread) [custom_components.gtfs2.gtfs_helper] Checking if extracting: Atac 2024-04-24 00:25:37.185 DEBUG (MainThread) [custom_components.gtfs2.coordinator] No run static refresh: sensor exists but not yet refresh for name: 85 to Termini 2024-04-24 00:25:37.186 DEBUG (SyncWorker_5) [custom_components.gtfs2.gtfs_rt_helper] GTFS RT get_feed_entities for url: https://romamobilita.it/sites/default/files/rome_rtgtfs_service_alerts_feed.pb , headers: None, label: alerts 2024-04-24 00:25:39.143 DEBUG (SyncWorker_5) [custom_components.gtfs2.gtfs_rt_helper] Successfully updated alerts 2024-04-24 00:25:39.143 DEBUG (SyncWorker_5) [custom_components.gtfs2.gtfs_rt_helper] Feed : 2024-04-24 00:25:39.185 ERROR (MainThread) [custom_components.gtfs2.coordinator] Error getting gtfs realtime data, for origin: 81908: ARCO DI TRAVERTINO (MA) (1) with error: 'dict' object has no attribute 'HasField' 2024-04-24 00:25:39.186 DEBUG (MainThread) [custom_components.gtfs2.coordinator] Finished fetching bd74bfe0a6f429bb51e171b648da77c7 data in 2.043 seconds (success: True) 2024-04-24 00:25:39.186 DEBUG (MainThread) [custom_components.gtfs2.sensor] SENSOR update attr data: {'schedule': <pygtfs.schedule.Schedule object at 0x5c2cbd98>, 'origin': '81908: ARCO DI TRAVERTINO (MA) (1)', 'destination': '80746: TERMINI (MA-MB-FS) (36)', 'offset': 0, 'include_tomorrow': False, 'gtfs_dir': 'gtfs2', 'name': '85 to Termini', 'file': 'Atac', 'route_type': '99', 'extracting': False, 'next_departure': {'trip_id': '0#5937-3', 'route_id': '85', 'day': 'today', 'first': True, 'last': False, 'origin_stop_id': '81908', 'origin_stop_name': 'ARCO DI TRAVERTINO (MA)', 'departure_time': datetime.datetime(2024, 4, 24, 5, 30, tzinfo=zoneinfo.ZoneInfo(key='America/New_York')), 'arrival_time': datetime.datetime(2024, 4, 24, 6, 15, tzinfo=zoneinfo.ZoneInfo(key='America/New_York')), 'origin_stop_time': {'Arrival Time': '2024-04-24T09:30:00+00:00', 'Departure Time': '2024-04-24T09:30:00+00:00', 'Drop Off Type': None, 'Pickup Type': None, 'Shape Dist Traveled': 0, 'Headsign': None, 'Sequence': 1, 'Timepoint': 1}, 'destination_stop_time': {'Arrival Time': '2024-04-24T10:15:00+00:00', 'Departure Time': '2024-04-24T10:15:00+00:00', 'Drop Off Type': None, 'Pickup Type': None, 'Shape Dist Traveled': 10012, 'Headsign': None, 'Sequence': 33, 'Timepoint': 1}, 'destination_stop_name': 'TERMINI (MA-MB-FS)', 'next_departures': ['2024-04-24T09:30:00+00:00', '2024-04-24T09:42:00+00:00', '2024-04-24T09:54:00+00:00', '2024-04-24T10:06:00+00:00', '2024-04-24T10:18:00+00:00', '2024-04-24T10:30:00+00:00', '2024-04-24T10:41:00+00:00', '2024-04-24T10:50:00+00:00', '2024-04-24T10:59:00+00:00', '2024-04-24T11:08:00+00:00', '2024-04-24T11:17:00+00:00', '2024-04-24T11:25:00+00:00', '2024-04-24T11:34:00+00:00', '2024-04-24T11:43:00+00:00', '2024-04-24T11:52:00+00:00', '2024-04-24T12:01:00+00:00', '2024-04-24T12:10:00+00:00', '2024-04-24T12:19:00+00:00', '2024-04-24T12:28:00+00:00', '2024-04-24T12:37:00+00:00', '2024-04-24T12:46:00+00:00', '2024-04-24T12:54:00+00:00', '2024-04-24T13:03:00+00:00', '2024-04-24T13:12:00+00:00', '2024-04-24T13:21:00+00:00', '2024-04-24T13:30:00+00:00', '2024-04-24T13:39:00+00:00', '2024-04-24T13:48:00+00:00', '2024-04-24T13:57:00+00:00', '2024-04-24T14:06:00+00:00', '2024-04-24T14:15:00+00:00', '2024-04-24T14:24:00+00:00', '2024-04-24T14:33:00+00:00', '2024-04-24T14:42:00+00:00', '2024-04-24T14:52:00+00:00', '2024-04-24T15:02:00+00:00', '2024-04-24T15:12:00+00:00', '2024-04-24T15:22:00+00:00', '2024-04-24T15:32:00+00:00', '2024-04-24T15:42:00+00:00', '2024-04-24T15:52:00+00:00', '2024-04-24T16:02:00+00:00', '2024-04-24T16:12:00+00:00', '2024-04-24T16:22:00+00:00', '2024-04-24T16:31:00+00:00', '2024-04-24T16:40:00+00:00', '2024-04-24T16:52:00+00:00', '2024-04-24T17:05:00+00:00', '2024-04-24T17:17:00+00:00', '2024-04-24T17:30:00+00:00', '2024-04-24T17:42:00+00:00', '2024-04-24T17:54:00+00:00', '2024-04-24T18:07:00+00:00', '2024-04-24T18:20:00+00:00', '2024-04-24T18:33:00+00:00', '2024-04-24T18:45:00+00:00', '2024-04-24T18:58:00+00:00', '2024-04-24T19:10:00+00:00', '2024-04-24T19:22:00+00:00', '2024-04-24T19:34:00+00:00', '2024-04-24T19:46:00+00:00', '2024-04-24T19:58:00+00:00', '2024-04-24T20:09:00+00:00', '2024-04-24T20:20:00+00:00', '2024-04-24T20:31:00+00:00', '2024-04-24T20:42:00+00:00', '2024-04-24T20:53:00+00:00', '2024-04-24T21:04:00+00:00', '2024-04-24T21:16:00+00:00', '2024-04-24T21:27:00+00:00', '2024-04-24T21:38:00+00:00', '2024-04-24T21:50:00+00:00', '2024-04-24T22:02:00+00:00', '2024-04-24T22:13:00+00:00', '2024-04-24T22:24:00+00:00', '2024-04-24T22:35:00+00:00', '2024-04-24T22:46:00+00:00', '2024-04-24T22:57:00+00:00', '2024-04-24T23:09:00+00:00', '2024-04-24T23:20:00+00:00', '2024-04-24T23:32:00+00:00', '2024-04-24T23:43:00+00:00', '2024-04-24T23:55:00+00:00', '2024-04-25T00:07:00+00:00', '2024-04-25T00:19:00+00:00', '2024-04-25T00:31:00+00:00', '2024-04-25T00:43:00+00:00', '2024-04-25T00:54:00+00:00', '2024-04-25T01:05:00+00:00', '2024-04-25T01:18:00+00:00', '2024-04-25T01:29:00+00:00', '2024-04-25T01:44:00+00:00', '2024-04-25T01:58:00+00:00', '2024-04-25T02:12:00+00:00', '2024-04-25T02:25:00+00:00', '2024-04-25T02:42:00+00:00', '2024-04-25T02:58:00+00:00', '2024-04-25T03:14:00+00:00', '2024-04-25T03:29:00+00:00', '2024-04-25T03:45:00+00:00', '2024-04-25T04:00:00+00:00'], 'next_departures_lines': ['2024-04-24T09:30:00+00:00 (85)', '2024-04-24T09:42:00+00:00 (85)', '2024-04-24T09:54:00+00:00 (85)', '2024-04-24T10:06:00+00:00 (85)', '2024-04-24T10:18:00+00:00 (85)', '2024-04-24T10:30:00+00:00 (85)', '2024-04-24T10:41:00+00:00 (85)', '2024-04-24T10:50:00+00:00 (85)', '2024-04-24T10:59:00+00:00 (85)', '2024-04-24T11:08:00+00:00 (85)', '2024-04-24T11:17:00+00:00 (85)', '2024-04-24T11:25:00+00:00 (85)', '2024-04-24T11:34:00+00:00 (85)', '2024-04-24T11:43:00+00:00 (85)', '2024-04-24T11:52:00+00:00 (85)', '2024-04-24T12:01:00+00:00 (85)', '2024-04-24T12:10:00+00:00 (85)', '2024-04-24T12:19:00+00:00 (85)', '2024-04-24T12:28:00+00:00 (85)', '2024-04-24T12:37:00+00:00 (85)', '2024-04-24T12:46:00+00:00 (85)', '2024-04-24T12:54:00+00:00 (85)', '2024-04-24T13:03:00+00:00 (85)', '2024-04-24T13:12:00+00:00 (85)', '2024-04-24T13:21:00+00:00 (85)', '2024-04-24T13:30:00+00:00 (85)', '2024-04-24T13:39:00+00:00 (85)', '2024-04-24T13:48:00+00:00 (85)', '2024-04-24T13:57:00+00:00 (85)', '2024-04-24T14:06:00+00:00 (85)', '2024-04-24T14:15:00+00:00 (85)', '2024-04-24T14:24:00+00:00 (85)', '2024-04-24T14:33:00+00:00 (85)', '2024-04-24T14:42:00+00:00 (85)', '2024-04-24T14:52:00+00:00 (85)', '2024-04-24T15:02:00+00:00 (85)', '2024-04-24T15:12:00+00:00 (85)', '2024-04-24T15:22:00+00:00 (85)', '2024-04-24T15:32:00+00:00 (85)', '2024-04-24T15:42:00+00:00 (85)', '2024-04-24T15:52:00+00:00 (85)', '2024-04-24T16:02:00+00:00 (85)', '2024-04-24T16:12:00+00:00 (85)', '2024-04-24T16:22:00+00:00 (85)', '2024-04-24T16:31:00+00:00 (85)', '2024-04-24T16:40:00+00:00 (85)', '2024-04-24T16:52:00+00:00 (85)', '2024-04-24T17:05:00+00:00 (85)', '2024-04-24T17:17:00+00:00 (85)', '2024-04-24T17:30:00+00:00 (85)', '2024-04-24T17:42:00+00:00 (85)', '2024-04-24T17:54:00+00:00 (85)', '2024-04-24T18:07:00+00:00 (85)', '2024-04-24T18:20:00+00:00 (85)', '2024-04-24T18:33:00+00:00 (85)', '2024-04-24T18:45:00+00:00 (85)', '2024-04-24T18:58:00+00:00 (85)', '2024-04-24T19:10:00+00:00 (85)', '2024-04-24T19:22:00+00:00 (85)', '2024-04-24T19:34:00+00:00 (85)', '2024-04-24T19:46:00+00:00 (85)', '2024-04-24T19:58:00+00:00 (85)', '2024-04-24T20:09:00+00:00 (85)', '2024-04-24T20:20:00+00:00 (85)', '2024-04-24T20:31:00+00:00 (85)', '2024-04-24T20:42:00+00:00 (85)', '2024-04-24T20:53:00+00:00 (85)', '2024-04-24T21:04:00+00:00 (85)', '2024-04-24T21:16:00+00:00 (85)', '2024-04-24T21:27:00+00:00 (85)', '2024-04-24T21:38:00+00:00 (85)', '2024-04-24T21:50:00+00:00 (85)', '2024-04-24T22:02:00+00:00 (85)', '2024-04-24T22:13:00+00:00 (85)', '2024-04-24T22:24:00+00:00 (85)', '2024-04-24T22:35:00+00:00 (85)', '2024-04-24T22:46:00+00:00 (85)', '2024-04-24T22:57:00+00:00 (85)', '2024-04-24T23:09:00+00:00 (85)', '2024-04-24T23:20:00+00:00 (85)', '2024-04-24T23:32:00+00:00 (85)', '2024-04-24T23:43:00+00:00 (85)', '2024-04-24T23:55:00+00:00 (85)', '2024-04-25T00:07:00+00:00 (85)', '2024-04-25T00:19:00+00:00 (85)', '2024-04-25T00:31:00+00:00 (85)', '2024-04-25T00:43:00+00:00 (85)', '2024-04-25T00:54:00+00:00 (85)', '2024-04-25T01:05:00+00:00 (85)', '2024-04-25T01:18:00+00:00 (85)', '2024-04-25T01:29:00+00:00 (85)', '2024-04-25T01:44:00+00:00 (85)', '2024-04-25T01:58:00+00:00 (85)', '2024-04-25T02:12:00+00:00 (85)', '2024-04-25T02:25:00+00:00 (85)', '2024-04-25T02:42:00+00:00 (85)', '2024-04-25T02:58:00+00:00 (85)', '2024-04-25T03:14:00+00:00 (85)', '2024-04-25T03:29:00+00:00 (85)', '2024-04-25T03:45:00+00:00 (85)', '2024-04-25T04:00:00+00:00 (85)'], 'next_departures_headsign': ['2024-04-24T09:30:00+00:00 (TERMINI (MA-MB-FS))', '2024-04-24T09:42:00+00:00 (TERMINI (MA-MB-FS))', '2024-04-24T09:54:00+00:00 (TERMINI (MA-MB-FS))', '2024-04-24T10:06:00+00:00 (TERMINI (MA-MB-FS))', '2024-04-24T10:18:00+00:00 (TERMINI (MA-MB-FS))', '2024-04-24T10:30:00+00:00 (TERMINI (MA-MB-FS))', '2024-04-24T10:41:00+00:00 (TERMINI (MA-MB-FS))', '2024-04-24T10:50:00+00:00 (TERMINI (MA-MB-FS))', '2024-04-24T10:59:00+00:00 (TERMINI (MA-MB-FS))', '2024-04-24T11:08:00+00:00 (TERMINI (MA-MB-FS))', '2024-04-24T11:17:00+00:00 (TERMINI (MA-MB-FS))', '2024-04-24T11:25:00+00:00 (TERMINI (MA-MB-FS))', '2024-04-24T11:34:00+00:00 (TERMINI (MA-MB-FS))', '2024-04-24T11:43:00+00:00 (TERMINI (MA-MB-FS))', '2024-04-24T11:52:00+00:00 (TERMINI (MA-MB-FS))', '2024-04-24T12:01:00+00:00 (TERMINI (MA-MB-FS))', '2024-04-24T12:10:00+00:00 (TERMINI (MA-MB-FS))', '2024-04-24T12:19:00+00:00 (TERMINI (MA-MB-FS))', '2024-04-24T12:28:00+00:00 (TERMINI (MA-MB-FS))', '2024-04-24T12:37:00+00:00 (TERMINI (MA-MB-FS))', '2024-04-24T12:46:00+00:00 (TERMINI (MA-MB-FS))', '2024-04-24T12:54:00+00:00 (TERMINI (MA-MB-FS))', '2024-04-24T13:03:00+00:00 (TERMINI (MA-MB-FS))', '2024-04-24T13:12:00+00:00 (TERMINI (MA-MB-FS))', '2024-04-24T13:21:00+00:00 (TERMINI (MA-MB-FS))', '2024-04-24T13:30:00+00:00 (TERMINI (MA-MB-FS))', '2024-04-24T13:39:00+00:00 (TERMINI (MA-MB-FS))', '2024-04-24T13:48:00+00:00 (TERMINI (MA-MB-FS))', '2024-04-24T13:57:00+00:00 (TERMINI (MA-MB-FS))', '2024-04-24T14:06:00+00:00 (TERMINI (MA-MB-FS))', '2024-04-24T14:15:00+00:00 (TERMINI (MA-MB-FS))', '2024-04-24T14:24:00+00:00 (TERMINI (MA-MB-FS))', '2024-04-24T14:33:00+00:00 (TERMINI (MA-MB-FS))', '2024-04-24T14:42:00+00:00 (TERMINI (MA-MB-FS))', '2024-04-24T14:52:00+00:00 (TERMINI (MA-MB-FS))', '2024-04-24T15:02:00+00:00 (TERMINI (MA-MB-FS))', '2024-04-24T15:12:00+00:00 (TERMINI (MA-MB-FS))', '2024-04-24T15:22:00+00:00 (TERMINI (MA-MB-FS))', '2024-04-24T15:32:00+00:00 (TERMINI (MA-MB-FS))', '2024-04-24T15:42:00+00:00 (TERMINI (MA-MB-FS))', '2024-04-24T15:52:00+00:00 (TERMINI (MA-MB-FS))', '2024-04-24T16:02:00+00:00 (TERMINI (MA-MB-FS))', '2024-04-24T16:12:00+00:00 (TERMINI (MA-MB-FS))', '2024-04-24T16:22:00+00:00 (TERMINI (MA-MB-FS))', '2024-04-24T16:31:00+00:00 (TERMINI (MA-MB-FS))', '2024-04-24T16:40:00+00:00 (TERMINI (MA-MB-FS))', '2024-04-24T16:52:00+00:00 (TERMINI (MA-MB-FS))', '2024-04-24T17:05:00+00:00 (TERMINI (MA-MB-FS))', '2024-04-24T17:17:00+00:00 (TERMINI (MA-MB-FS))', '2024-04-24T17:30:00+00:00 (TERMINI (MA-MB-FS))', '2024-04-24T17:42:00+00:00 (TERMINI (MA-MB-FS))', '2024-04-24T17:54:00+00:00 (TERMINI (MA-MB-FS))', '2024-04-24T18:07:00+00:00 (TERMINI (MA-MB-FS))', '2024-04-24T18:20:00+00:00 (TERMINI (MA-MB-FS))', '2024-04-24T18:33:00+00:00 (TERMINI (MA-MB-FS))', '2024-04-24T18:45:00+00:00 (TERMINI (MA-MB-FS))', '2024-04-24T18:58:00+00:00 (TERMINI (MA-MB-FS))', '2024-04-24T19:10:00+00:00 (TERMINI (MA-MB-FS))', '2024-04-24T19:22:00+00:00 (TERMINI (MA-MB-FS))', '2024-04-24T19:34:00+00:00 (TERMINI (MA-MB-FS))', '2024-04-24T19:46:00+00:00 (TERMINI (MA-MB-FS))', '2024-04-24T19:58:00+00:00 (TERMINI (MA-MB-FS))', '2024-04-24T20:09:00+00:00 (TERMINI (MA-MB-FS))', '2024-04-24T20:20:00+00:00 (TERMINI (MA-MB-FS))', '2024-04-24T20:31:00+00:00 (TERMINI (MA-MB-FS))', '2024-04-24T20:42:00+00:00 (TERMINI (MA-MB-FS))', '2024-04-24T20:53:00+00:00 (TERMINI (MA-MB-FS))', '2024-04-24T21:04:00+00:00 (TERMINI (MA-MB-FS))', '2024-04-24T21:16:00+00:00 (TERMINI (MA-MB-FS))', '2024-04-24T21:27:00+00:00 (TERMINI (MA-MB-FS))', '2024-04-24T21:38:00+00:00 (TERMINI (MA-MB-FS))', '2024-04-24T21:50:00+00:00 (TERMINI (MA-MB-FS))', '2024-04-24T22:02:00+00:00 (TERMINI (MA-MB-FS))', '2024-04-24T22:13:00+00:00 (TERMINI (MA-MB-FS))', '2024-04-24T22:24:00+00:00 (TERMINI (MA-MB-FS))', '2024-04-24T22:35:00+00:00 (TERMINI (MA-MB-FS))', '2024-04-24T22:46:00+00:00 (TERMINI (MA-MB-FS))', '2024-04-24T22:57:00+00:00 (TERMINI (MA-MB-FS))', '2024-04-24T23:09:00+00:00 (TERMINI (MA-MB-FS))', '2024-04-24T23:20:00+00:00 (TERMINI (MA-MB-FS))', '2024-04-24T23:32:00+00:00 (TERMINI (MA-MB-FS))', '2024-04-24T23:43:00+00:00 (TERMINI (MA-MB-FS))', '2024-04-24T23:55:00+00:00 (TERMINI (MA-MB-FS))', '2024-04-25T00:07:00+00:00 (TERMINI (MA-MB-FS))', '2024-04-25T00:19:00+00:00 (TERMINI (MA-MB-FS))', '2024-04-25T00:31:00+00:00 (TERMINI (MA-MB-FS))', '2024-04-25T00:43:00+00:00 (TERMINI (MA-MB-FS))', '2024-04-25T00:54:00+00:00 (TERMINI (MA-MB-FS))', '2024-04-25T01:05:00+00:00 (TERMINI (MA-MB-FS))', '2024-04-25T01:18:00+00:00 (TERMINI (MA-MB-FS))', '2024-04-25T01:29:00+00:00 (TERMINI (MA-MB-FS))', '2024-04-25T01:44:00+00:00 (TERMINI (MA-MB-FS))', '2024-04-25T01:58:00+00:00 (TERMINI (MA-MB-FS))', '2024-04-25T02:12:00+00:00 (TERMINI (MA-MB-FS))', '2024-04-25T02:25:00+00:00 (TERMINI (MA-MB-FS))', '2024-04-25T02:42:00+00:00 (TERMINI (MA-MB-FS))', '2024-04-25T02:58:00+00:00 (TERMINI (MA-MB-FS))', '2024-04-25T03:14:00+00:00 (TERMINI (MA-MB-FS))', '2024-04-25T03:29:00+00:00 (TERMINI (MA-MB-FS))', '2024-04-25T03:45:00+00:00 (TERMINI (MA-MB-FS))', '2024-04-25T04:00:00+00:00 (TERMINI (MA-MB-FS))']}, 'next_departure_realtime_attr': {}, 'alert': {}, 'gtfs_updated_at': '2024-04-24T04:21:26.595336+00:00'} 2024-04-24 00:25:39.203 DEBUG (MainThread) [custom_components.gtfs2.sensor] Fetching trip details for 0#5937-3 2024-04-24 00:25:39.208 DEBUG (MainThread) [custom_components.gtfs2.sensor] Fetching route details for 85 2024-04-24 00:25:39.214 DEBUG (MainThread) [custom_components.gtfs2.sensor] Fetching agency details for OP1 2024-04-24 00:25:39.219 DEBUG (MainThread) [custom_components.gtfs2.sensor] Self._departure time for state value TZ: {datetime.datetime(2024, 4, 24, 5, 30, tzinfo=zoneinfo.ZoneInfo(key='America/New_York'))} 2024-04-24 00:25:39.227 DEBUG (MainThread) [custom_components.gtfs2.sensor] Destination_stop_time {'Arrival Time': '2024-04-24T10:15:00+00:00', 'Departure Time': '2024-04-24T10:15:00+00:00', 'Drop Off Type': None, 'Pickup Type': None, 'Shape Dist Traveled': 10012, 'Headsign': None, 'Sequence': 33, 'Timepoint': 1} 2024-04-24 00:25:39.229 DEBUG (MainThread) [custom_components.gtfs2.sensor] No next departure realtime attributes

vingerha commented 2 months ago

I did change a few things between 044 and 045... and I never (sorry) tested'alerts'...can you confirm that 045 has no errors when you leave out the 'alerts' realtime?

jebissell commented 2 months ago

On 0.4.5 I configured a different bus line which seemed to be live today with RT for several hours populating only vehicle positions and trip updates, and now get a different missing value ( 'vehicle' ) and as before the sensor goes unavailable, but returns after turning off RT and receiving the next update.

Is this Rome changing its update structure, meaning your fetch is looking for fields in the wrong order? The attributes for the sensor seem a bit different, for example previously I searched for a '-' in next_departures_realtime and now info_realtime will show that. Also, now next_departures display in attributes as a fulltext timestamp in local time, while next_departures_lines and ...headsign remaiin in UTC.

My application is an edge case, but if you're curious, I have a departures countdown panel for my wife while working in Rome (a different timezone from where our HA server is located). Traveling among her key work locations and residence, when leaving she can walk towards 2 or 3 relevant bus stops of slightly different distance (and some just over 500 m). But since in Rome at least one of the lines is a disaster, her best next bus departure might be a longer walk. When the realtime departure is available, that substitutes for the scheduled departure and brings the departure up or down in the countdown. Each work location and residence is a HA zone and the correct countdown is displayed for her location.

Error log from

2024-04-24 12:32:24.340 DEBUG (MainThread) [custom_components.gtfs2.sensor] Fetching trip details for 246036724604264+733039+0 2024-04-24 12:32:24.340 DEBUG (MainThread) [custom_components.gtfs2.sensor] Fetching route details for 3 2024-04-24 12:32:24.341 DEBUG (MainThread) [custom_components.gtfs2.sensor] Fetching agency details for 1 2024-04-24 12:32:24.342 DEBUG (MainThread) [custom_components.gtfs2.sensor] Self._departure time for state value TZ: {datetime.datetime(2024, 4, 24, 12, 37, tzinfo=zoneinfo.ZoneInfo(key='America/New_York'))} 2024-04-24 12:32:24.342 DEBUG (MainThread) [custom_components.gtfs2.sensor] Destination_stop_time {'Arrival Time': '2024-04-24T17:24:00+00:00', 'Departure Time': '2024-04-24T17:24:00+00:00', 'Drop Off Type': 0, 'Pickup Type': 0, 'Shape Dist Traveled': None, 'Headsign': None, 'Sequence': 16, 'Timepoint': None} 2024-04-24 12:32:24.343 DEBUG (MainThread) [custom_components.gtfs2.sensor] next dep realtime attr: {'Due in': datetime.datetime(2024, 4, 24, 16, 38, tzinfo=datetime.timezone.utc), 'Stop ID': '106', 'Route': '3', 'Trip': '246036724604264+733039+0', 'Direction ID': '0', 'Next Services RT': [datetime.datetime(2024, 4, 24, 16, 38, tzinfo=datetime.timezone.utc), datetime.datetime(2024, 4, 24, 16, 47, tzinfo=datetime.timezone.utc), datetime.datetime(2024, 4, 24, 17, 7, tzinfo=datetime.timezone.utc), datetime.datetime(2024, 4, 24, 17, 13, tzinfo=datetime.timezone.utc), datetime.datetime(2024, 4, 24, 17, 37, tzinfo=datetime.timezone.utc), datetime.datetime(2024, 4, 24, 17, 43, tzinfo=datetime.timezone.utc), datetime.datetime(2024, 4, 24, 18, 7, tzinfo=datetime.timezone.utc), datetime.datetime(2024, 4, 24, 18, 14, tzinfo=datetime.timezone.utc), datetime.datetime(2024, 4, 24, 18, 37, tzinfo=datetime.timezone.utc), datetime.datetime(2024, 4, 24, 18, 44, tzinfo=datetime.timezone.utc), datetime.datetime(2024, 4, 24, 19, 7, tzinfo=datetime.timezone.utc), datetime.datetime(2024, 4, 24, 19, 11, tzinfo=datetime.timezone.utc), datetime.datetime(2024, 4, 24, 19, 38, tzinfo=datetime.timezone.utc), datetime.datetime(2024, 4, 24, 19, 42, tzinfo=datetime.timezone.utc), datetime.datetime(2024, 4, 24, 20, 2, tzinfo=datetime.timezone.utc), datetime.datetime(2024, 4, 24, 20, 9, tzinfo=datetime.timezone.utc), datetime.datetime(2024, 4, 24, 20, 31, tzinfo=datetime.timezone.utc), datetime.datetime(2024, 4, 24, 20, 35, tzinfo=datetime.timezone.utc), datetime.datetime(2024, 4, 24, 20, 55, tzinfo=datetime.timezone.utc), datetime.datetime(2024, 4, 24, 21, 8, tzinfo=datetime.timezone.utc), datetime.datetime(2024, 4, 24, 21, 19, tzinfo=datetime.timezone.utc), datetime.datetime(2024, 4, 24, 21, 26, tzinfo=datetime.timezone.utc), datetime.datetime(2024, 4, 24, 21, 42, tzinfo=datetime.timezone.utc), datetime.datetime(2024, 4, 24, 21, 49, tzinfo=datetime.timezone.utc), datetime.datetime(2024, 4, 24, 22, 6, tzinfo=datetime.timezone.utc), datetime.datetime(2024, 4, 24, 22, 29, tzinfo=datetime.timezone.utc), datetime.datetime(2024, 4, 24, 22, 38, tzinfo=datetime.timezone.utc), datetime.datetime(2024, 4, 24, 22, 47, tzinfo=datetime.timezone.utc), datetime.datetime(2024, 4, 24, 22, 48, tzinfo=datetime.timezone.utc)], 'Due at': '16:38', 'Next Service': '16:47', 'device_class': 'timestamp', 'gtfs_rt_updated_at': datetime.datetime(2024, 4, 24, 16, 32, 24, 337239, tzinfo=datetime.timezone.utc)} 2024-04-24 12:32:25.249 DEBUG (MainThread) [custom_components.gtfs2.coordinator] Previous data: {'schedule': <pygtfs.schedule.Schedule object at 0x7f4086949550>, 'origin': '70439: TERMINI (MA-MB-FS) (1)', 'destination': '70466: MUSE (29)', 'offset': 0, 'include_tomorrow': False, 'gtfs_dir': 'gtfs2', 'name': '360 Muse verso Termini', 'file': 'Roma', 'route_type': '99', 'extracting': False, 'next_departure': {'trip_id': '1#1609-11', 'route_id': '360', 'day': 'today', 'first': False, 'last': False, 'origin_stop_id': '70439', 'origin_stop_name': 'TERMINI (MA-MB-FS)', 'departure_time': datetime.datetime(2024, 4, 24, 12, 32, 20, tzinfo=zoneinfo.ZoneInfo(key='America/New_York')), 'arrival_time': datetime.datetime(2024, 4, 24, 13, 1, tzinfo=zoneinfo.ZoneInfo(key='America/New_York')), 'origin_stop_time': {'Arrival Time': '2024-04-24T16:32:20+00:00', 'Departure Time': '2024-04-24T16:32:20+00:00', 'Drop Off Type': None, 'Pickup Type': None, 'Shape Dist Traveled': 4096, 'Headsign': None, 'Sequence': 14, 'Timepoint': 0}, 'destination_stop_time': {'Arrival Time': '2024-04-24T17:01:00+00:00', 'Departure Time': '2024-04-24T17:01:00+00:00', 'Drop Off Type': None, 'Pickup Type': None, 'Shape Dist Traveled': 8723, 'Headsign': None, 'Sequence': 29, 'Timepoint': 1}, 'destination_stop_name': 'MUSE', 'next_departures': ['2024-04-24T16:32:20+00:00', '2024-04-24T16:41:20+00:00', '2024-04-24T16:50:20+00:00', '2024-04-24T16:59:20+00:00', '2024-04-24T17:08:20+00:00', '2024-04-24T17:17:20+00:00', '2024-04-24T17:27:20+00:00', '2024-04-24T17:37:20+00:00', '2024-04-24T17:47:20+00:00', '2024-04-24T17:57:20+00:00', '2024-04-24T18:07:20+00:00', '2024-04-24T18:17:20+00:00', '2024-04-24T18:27:20+00:00', '2024-04-24T18:37:20+00:00', '2024-04-24T18:47:20+00:00', '2024-04-24T18:57:20+00:00', '2024-04-24T19:07:20+00:00', '2024-04-24T19:16:20+00:00', '2024-04-24T19:26:20+00:00', '2024-04-24T19:36:20+00:00', '2024-04-24T19:46:20+00:00', '2024-04-24T19:57:44+00:00', '2024-04-24T20:07:44+00:00', '2024-04-24T20:17:44+00:00', '2024-04-24T20:28:44+00:00', '2024-04-24T20:39:44+00:00', '2024-04-24T20:50:44+00:00', '2024-04-24T21:01:44+00:00', '2024-04-24T21:12:44+00:00', '2024-04-24T21:22:44+00:00', '2024-04-24T21:34:38+00:00', '2024-04-24T21:44:38+00:00', '2024-04-24T21:55:38+00:00', '2024-04-24T22:06:38+00:00', '2024-04-24T22:17:38+00:00', '2024-04-24T22:29:38+00:00', '2024-04-24T22:41:38+00:00', '2024-04-24T22:52:38+00:00', '2024-04-24T23:03:38+00:00', '2024-04-24T23:14:38+00:00', '2024-04-24T23:26:38+00:00', '2024-04-24T23:37:48+00:00', '2024-04-24T23:49:48+00:00', '2024-04-25T00:02:48+00:00', '2024-04-25T00:16:48+00:00', '2024-04-25T00:24:06+00:00', '2024-04-25T00:37:38+00:00', '2024-04-25T00:52:06+00:00', '2024-04-25T01:09:06+00:00', '2024-04-25T01:24:18+00:00', '2024-04-25T01:43:18+00:00', '2024-04-25T02:03:18+00:00', '2024-04-25T02:22:18+00:00', '2024-04-25T02:42:18+00:00', '2024-04-25T02:58:56+00:00', '2024-04-25T03:18:56+00:00', '2024-04-25T03:38:56+00:00', '2024-04-25T03:57:56+00:00', '2024-04-25T04:15:56+00:00'], 'next_departures_lines': ['2024-04-24T16:32:20+00:00 (360)', '2024-04-24T16:41:20+00:00 (360)', '2024-04-24T16:50:20+00:00 (360)', '2024-04-24T16:59:20+00:00 (360)', '2024-04-24T17:08:20+00:00 (360)', '2024-04-24T17:17:20+00:00 (360)', '2024-04-24T17:27:20+00:00 (360)', '2024-04-24T17:37:20+00:00 (360)', '2024-04-24T17:47:20+00:00 (360)', '2024-04-24T17:57:20+00:00 (360)', '2024-04-24T18:07:20+00:00 (360)', '2024-04-24T18:17:20+00:00 (360)', '2024-04-24T18:27:20+00:00 (360)', '2024-04-24T18:37:20+00:00 (360)', '2024-04-24T18:47:20+00:00 (360)', '2024-04-24T18:57:20+00:00 (360)', '2024-04-24T19:07:20+00:00 (360)', '2024-04-24T19:16:20+00:00 (360)', '2024-04-24T19:26:20+00:00 (360)', '2024-04-24T19:36:20+00:00 (360)', '2024-04-24T19:46:20+00:00 (360)', '2024-04-24T19:57:44+00:00 (360)', '2024-04-24T20:07:44+00:00 (360)', '2024-04-24T20:17:44+00:00 (360)', '2024-04-24T20:28:44+00:00 (360)', '2024-04-24T20:39:44+00:00 (360)', '2024-04-24T20:50:44+00:00 (360)', '2024-04-24T21:01:44+00:00 (360)', '2024-04-24T21:12:44+00:00 (360)', '2024-04-24T21:22:44+00:00 (360)', '2024-04-24T21:34:38+00:00 (360)', '2024-04-24T21:44:38+00:00 (360)', '2024-04-24T21:55:38+00:00 (360)', '2024-04-24T22:06:38+00:00 (360)', '2024-04-24T22:17:38+00:00 (360)', '2024-04-24T22:29:38+00:00 (360)', '2024-04-24T22:41:38+00:00 (360)', '2024-04-24T22:52:38+00:00 (360)', '2024-04-24T23:03:38+00:00 (360)', '2024-04-24T23:14:38+00:00 (360)', '2024-04-24T23:26:38+00:00 (360)', '2024-04-24T23:37:48+00:00 (360)', '2024-04-24T23:49:48+00:00 (360)', '2024-04-25T00:02:48+00:00 (360)', '2024-04-25T00:16:48+00:00 (360)', '2024-04-25T00:24:06+00:00 (360)', '2024-04-25T00:37:38+00:00 (360)', '2024-04-25T00:52:06+00:00 (360)', '2024-04-25T01:09:06+00:00 (360)', '2024-04-25T01:24:18+00:00 (360)', '2024-04-25T01:43:18+00:00 (360)', '2024-04-25T02:03:18+00:00 (360)', '2024-04-25T02:22:18+00:00 (360)', '2024-04-25T02:42:18+00:00 (360)', '2024-04-25T02:58:56+00:00 (360)', '2024-04-25T03:18:56+00:00 (360)', '2024-04-25T03:38:56+00:00 (360)', '2024-04-25T03:57:56+00:00 (360)', '2024-04-25T04:15:56+00:00 (360)'], 'next_departures_headsign': ['2024-04-24T16:32:20+00:00 (MUSE)', '2024-04-24T16:41:20+00:00 (MUSE)', '2024-04-24T16:50:20+00:00 (MUSE)', '2024-04-24T16:59:20+00:00 (MUSE)', '2024-04-24T17:08:20+00:00 (MUSE)', '2024-04-24T17:17:20+00:00 (MUSE)', '2024-04-24T17:27:20+00:00 (MUSE)', '2024-04-24T17:37:20+00:00 (MUSE)', '2024-04-24T17:47:20+00:00 (MUSE)', '2024-04-24T17:57:20+00:00 (MUSE)', '2024-04-24T18:07:20+00:00 (MUSE)', '2024-04-24T18:17:20+00:00 (MUSE)', '2024-04-24T18:27:20+00:00 (MUSE)', '2024-04-24T18:37:20+00:00 (MUSE)', '2024-04-24T18:47:20+00:00 (MUSE)', '2024-04-24T18:57:20+00:00 (MUSE)', '2024-04-24T19:07:20+00:00 (MUSE)', '2024-04-24T19:16:20+00:00 (MUSE)', '2024-04-24T19:26:20+00:00 (MUSE)', '2024-04-24T19:36:20+00:00 (MUSE)', '2024-04-24T19:46:20+00:00 (MUSE)', '2024-04-24T19:57:44+00:00 (MUSE)', '2024-04-24T20:07:44+00:00 (MUSE)', '2024-04-24T20:17:44+00:00 (MUSE)', '2024-04-24T20:28:44+00:00 (MUSE)', '2024-04-24T20:39:44+00:00 (MUSE)', '2024-04-24T20:50:44+00:00 (MUSE)', '2024-04-24T21:01:44+00:00 (MUSE)', '2024-04-24T21:12:44+00:00 (MUSE)', '2024-04-24T21:22:44+00:00 (MUSE)', '2024-04-24T21:34:38+00:00 (MUSE)', '2024-04-24T21:44:38+00:00 (MUSE)', '2024-04-24T21:55:38+00:00 (MUSE)', '2024-04-24T22:06:38+00:00 (MUSE)', '2024-04-24T22:17:38+00:00 (MUSE)', '2024-04-24T22:29:38+00:00 (MUSE)', '2024-04-24T22:41:38+00:00 (MUSE)', '2024-04-24T22:52:38+00:00 (MUSE)', '2024-04-24T23:03:38+00:00 (MUSE)', '2024-04-24T23:14:38+00:00 (MUSE)', '2024-04-24T23:26:38+00:00 (MUSE)', '2024-04-24T23:37:48+00:00 (MUSE)', '2024-04-24T23:49:48+00:00 (MUSE)', '2024-04-25T00:02:48+00:00 (MUSE)', '2024-04-25T00:16:48+00:00 (MUSE)', '2024-04-25T00:24:06+00:00 (MUSE)', '2024-04-25T00:37:38+00:00 (MUSE)', '2024-04-25T00:52:06+00:00 (MUSE)', '2024-04-25T01:09:06+00:00 (MUSE)', '2024-04-25T01:24:18+00:00 (MUSE)', '2024-04-25T01:43:18+00:00 (MUSE)', '2024-04-25T02:03:18+00:00 (MUSE)', '2024-04-25T02:22:18+00:00 (MUSE)', '2024-04-25T02:42:18+00:00 (MUSE)', '2024-04-25T02:58:56+00:00 (MUSE)', '2024-04-25T03:18:56+00:00 (MUSE)', '2024-04-25T03:38:56+00:00 (MUSE)', '2024-04-25T03:57:56+00:00 (MUSE)', '2024-04-25T04:15:56+00:00 (MUSE)']}, 'next_departure_realtime_attr': {}, 'alert': {}, 'gtfs_updated_at': '2024-04-24T16:26:23.537888+00:00'} 2024-04-24 12:32:25.250 DEBUG (MainThread) [custom_components.gtfs2.gtfs_helper] Getting gtfs with data: {'file': 'Roma', 'url': 'na', 'extract_from': 'zip', 'agency': 'OP1: Atac', 'route_type': '99', 'route': '360: 360 (None) - Atac', 'direction': '1', 'origin': '70439: TERMINI (MA-MB-FS) (1)', 'destination': '70466: MUSE (29)', 'name': '360 Muse verso Termini', 'include_tomorrow': False} 2024-04-24 12:32:25.250 DEBUG (MainThread) [custom_components.gtfs2.gtfs_helper] Checking if extracting: Roma 2024-04-24 12:32:25.258 DEBUG (MainThread) [custom_components.gtfs2.gtfs_helper] Checking if extracting: Roma 2024-04-24 12:32:25.258 DEBUG (MainThread) [custom_components.gtfs2.coordinator] No run static refresh: sensor exists but not yet refresh for name: 360 Muse verso Termini 2024-04-24 12:32:25.260 DEBUG (SyncWorker_11) [custom_components.gtfs2.gtfs_rt_helper] Configuration for RT route: 360, RT trip: 1#1609-11, RT stop: 70439, RT direction: 1 2024-04-24 12:32:25.260 DEBUG (SyncWorker_11) [custom_components.gtfs2.gtfs_rt_helper] GTFS RT get_feed_entities for url: https://romamobilita.it/sites/default/files/rome_rtgtfs_vehicle_positions_feed.pb , headers: None, label: vehicle positions 2024-04-24 12:32:27.354 DEBUG (SyncWorker_11) [custom_components.gtfs2.gtfs_rt_helper] Successfully updated vehicle positions 2024-04-24 12:32:27.374 ERROR (MainThread) [custom_components.gtfs2.coordinator] Error getting gtfs realtime data, for origin: 70439: TERMINI (MA-MB-FS) (1) with error: 'dict' object has no attribute 'vehicle' 2024-04-24 12:32:27.375 ERROR (MainThread) [custom_components.gtfs2.coordinator] Unexpected error fetching 8d4d4c781fe946a381d04f9beb89cf34 data: name 'err' is not defined Traceback (most recent call last): File "/config/custom_components/gtfs2/coordinator.py", line 160, in _async_update_data self._get_next_service = await self.hass.async_add_executor_job(get_next_services, self) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/concurrent/futures/thread.py", line 58, in run result = self.fn(*self.args, **self.kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/gtfs2/gtfs_rt_helper.py", line 99, in get_next_services next_services = get_rt_route_trip_statuses(self).get(self._route, {}).get(self._direction, {}).get(self._stop, {}).get("departures", []) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/gtfs2/gtfs_rt_helper.py", line 161, in get_rt_route_trip_statuses vehicle_positions = get_rt_vehicle_positions(self) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/gtfs2/gtfs_rt_helper.py", line 268, in get_rt_vehicle_positions vehicle = entity.vehicle ^^^^^^^^^^^^^^ AttributeError: 'dict' object has no attribute 'vehicle'

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 315, in _async_refresh self.data = await self._async_update_data() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/gtfs2/coordinator.py", line 166, in _async_update_data raise UpdateFailed(f"Error in getting start/end stop data: {err}") ^^^ NameError: name 'err' is not defined 2024-04-24 12:32:27.383 DEBUG (MainThread) [custom_components.gtfs2.coordinator] Finished fetching 8d4d4c781fe946a381d04f9beb89cf34 data in 2.134 seconds (success: False)

vingerha commented 2 months ago

Likely an execpetion that I have not yet been able to identify....so will try to work on it but will be next week as no (good) access to my backend whilst travelling

vingerha commented 2 months ago

Fixed in 0.4.5.2 ... please note that for Alerts I have only been able to do very basic testing as it is quite a job to first find one and then tie it to a stop-in-use....

jebissell commented 2 months ago

This update works perfectly, in particular performing gracefully when the RT feed becomes unavailable, as is often the case for Rome transit. For the same reason, testing Alerts with the Rome data will be difficult from the start given its poor quality. Furthermore, the alerts that do appear tend to be system-wide or area-wide (for example affecting the current remodeling of the Termini Station bus stop or rerouting for road construction) rather than affecting a single line. Thanks for your effort.

vingerha commented 2 months ago

Thx for the response, I was thinking on separating out 'Alerts' as separate sensors but not sure if that would make sense. E.g. all alerts on a specific route, not just per-stop.... At the moment I donot really know how many people use Alerts and if they have good data to make actual use of it so a bit hesitant to spend (more) time on it.... If you have an idea, do open an issue (feature)