mark1foley / ha-gtfs-rt-v2

Real-time transit information for Home Assistant
MIT License
45 stars 17 forks source link

Local service trip update doesn't provide routeId #23

Closed simontims closed 1 year ago

simontims commented 1 year ago

I'm working on a contribution to support my local service, which requires a header 'ocp-apim-subscription-key'. I've got it working OK, but the configured departure never updates. Looking in debug, I noticed the route_id is null:

Stop: 32919 Stop Sequence: 48 Stop Time: 1683096875
Adding route ID  trip ID 6931 direction ID 0 stop ID 32919 stop time 1683096875

Checking the feed contents, I see there's no route Id. Here's the contents of a feed entity, which compared with the Translink test feed, looks different and incomplete - there is no route_id in the trip.

id: "1683095191_3421"
trip_update {
  trip {
    trip_id: "3421"
    schedule_relationship: SCHEDULED
  }
  stop_time_update {
    stop_sequence: 10
    stop_id: "33348"
    arrival {
      time: 1683095137
    }
    departure {
      time: 1683095142
    }
  }
... etc

Could this be a different version or format of the data?

mark1foley commented 1 year ago

Hi Simon,

Looking at the Google GTFS Realtime reference (https://developers.google.com/transit/gtfs-realtime/reference) strictly speaking the route id is only required in the trip descriptor if a trip id is not provided. The logic being that you can lookup the route id in the GTFS Static trips.txt file using the trip id.

Unfortunately, this again highlights the deficiency in the way the integration is currently written, i.e. it does not make use of the GTFS static zip file. It looks like most operators provide both the trip id and route id – certainly this is the first time that I have heard of only the trip id being provided. But no doubt other operators do this as well. Unfortunately, the way the integration is currently written it does require the route id to be in the trip descriptor.

I do know of one guy that is looking a re-writing the integration to start with the scheduled data from the GTFS static files and enhance it the realtime feed. Last time I heard from him he was having performance problems. The Static GTFS file is huge and is frequently updated by the operators – sometime every few minutes. Every update is a completely new version with no incremental updates available. I have seen it take 15-20 minutes to load the files into a SQLite DB on a Raspberry Pi so there are certainly challenges. Personally, I think Google should change the specification to include more data in the realtime feed so we don’t have to worry about the static files but I haven’t heard of this happening.

Apologies as I know this is not the information you were looking for.

Regards,

Mark

From: Simon Tims @.> Sent: Wednesday, May 3, 2023 5:30 PM To: mark1foley/ha-gtfs-rt-v2 @.> Cc: Subscribed @.***> Subject: [mark1foley/ha-gtfs-rt-v2] Trip update doesn't seem to provide routeId (Issue #23)

I'm working on contribution to support my local service, which requires a header 'ocp-apim-subscription-key'.

I've got it working OK, but the configured departure never updates. Looking in debug, I noticed the route_id is null:

Stop: 32919 Stop Sequence: 48 Stop Time: 1683096875

Adding route ID trip ID 6931 direction ID 0 stop ID 32919 stop time 1683096875

Checking the feed contents, I see that there's no route Id where the parser expects it. Here's the contents of a feed entity, which compared with the Translink test feed, looks different and incomplete - there is no route_id in the trip.

id: "1683095191_3421"

trip_update {

trip {

trip_id: "3421"

schedule_relationship: SCHEDULED

}

stop_time_update {

stop_sequence: 10

stop_id: "33348"

arrival {

  time: 1683095137

}

departure {

  time: 1683095142

}

}

... etc

Could this be a different version or format of the data?

— Reply to this email directly, view it on GitHubhttps://github.com/mark1foley/ha-gtfs-rt-v2/issues/23, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AL6CAIDA5XN7RCKMDX7H5LLXEICQ5ANCNFSM6AAAAAAXUAPM3E. You are receiving this because you are subscribed to this thread.Message ID: @.**@.>>

simontims commented 1 year ago

Thanks! I wrote to the provider but there's no pending addition of the routeId. I'll have a look at the static files in more detail.

Cheers

m1r4c commented 9 months ago

Just adding on to this as I just ran into the same issue, my provider does not provide a routeid in the feed and feedback from provider is that they will never implement it either as they belive it would add unnecessary data to the payload. They figure that looking up the routeid from the trips.txt file should be a trivial matter on the client side.

What you are describing where some providers have huge static GTFS files which are frequently updated (which kindda goes against the naming scheme of 'GTFS Static' :)) sound unfortunate indeed!