diff --git a/custom_components/gtfs2/coordinator.py b/custom_components/gtfs2/coordinator.py index 9248204..2067b1c 100644 --- a/custom_components/gtfs2/coordinator.py +++ b/custom_components/gtfs2/coordinator.py @@ -141,7 +141,7 @@ async def _async_update_data(self) -> dict[str, str]: self._data["next_departure_realtime_attr"]["gtfs_rt_updated_at"] = dt_util.utcnow() self._data["alert"] = self._get_rt_alerts except Exception as ex: # pylint: disable=broad-except - _LOGGER.error("Error getting gtfs realtime data, for origin: %s with error: %s", data["origin"], ex) + _LOGGER.error("Error getting gtfs realtime data, for origin: %s with error: %s", data["origin"], ex) else: _LOGGER.debug("GTFS RT: RealTime = false, selected in entity options") else: diff --git a/custom_components/gtfs2/gtfs_rt_helper.py b/custom_components/gtfs2/gtfs_rt_helper.py index 302763c..f58bf9f 100644 --- a/custom_components/gtfs2/gtfs_rt_helper.py +++ b/custom_components/gtfs2/gtfs_rt_helper.py @@ -396,10 +396,13 @@ def get_rt_alerts(self): label="alerts", ) for entity in feed_entities: + _LOGGER.debug("RT Alert entity: %s", entity) if entity.HasField("alert"): for x in entity.alert.informed_entity: if x.HasField("stop_id"): stop_id = x.stop_id + else: + stop_id = "unknown" if x.HasField("stop_id"): route_id = x.route_id else: @@ -410,6 +413,10 @@ def get_rt_alerts(self): if stop_id == self._destination_id and (route_id == "unknown" or route_id == self._route_id): _LOGGER.debug("RT Alert for route: %s, stop: %s, alert: %s", route_id, stop_id, entity.alert.header_text) rt_alerts["destination_stop_alert"] = (str(entity.alert.header_text).split('text: "')[1]).split('"',1)[0].replace(':','').replace('\n','') + if stop_id == "unknown" and route_id == self._route_id: + _LOGGER.debug("RT Alert for route: %s, stop: %s, alert: %s", route_id, stop_id, entity.alert.header_text) + rt_alerts["origin_stop_alert"] = (str(entity.alert.header_text).split('text: "')[1]).split('"',1)[0].replace(':','').replace('\n','') + rt_alerts["destination_stop_alert"] = (str(entity.alert.header_text).split('text: "')[1]).split('"',1)[0].replace(':','').replace('\n','') return rt_alerts