Using GTFS-Realtime in OpenHAB JS Rules via Java protobuf

Hi all,

I’m trying to track real-time public transport (GTFS-Realtime) in OpenHAB using a JavaScript rule, but I keep running into issues with decoding the protobuf feed.

Currently, I tried multiple approaches:

  1. OpenHAB HTTP.sendHttpGetRequest + gtfs-realtime-bindings
  • Works in Node.js, but in OpenHAB JS rules it fails with:
Fatal transport error: java.util.concurrent.ExecutionException: java.lang.IllegalArgumentException: Buffering capacity 2097152 exceeded
  • Seems related to large feed size and string conversion.
  1. Java I/O + gtfs-realtime-bindings
  • Also fails with:
TypeError: execute on byte[] failed due to: Message not supported.
  • I think this is because the Node.js library expects Uint8Array/Buffer, which GraalJS cannot provide.
  1. Java protobuf (protobuf-java)
  • Attempting to use generated classes like transit_realtime.FeedMessage results in:
TypeError: Access to host class transit_realtime.FeedMessage is not allowed or does not exist
  • I realize now that the class is not on OpenHAB’s classpath, so JS cannot access it.

My questions:

  1. What is the best way to decode GTFS-Realtime feeds inside OpenHAB rules (JS or Java)?
  2. Can I use OneBusAway GTFS-Realtime JAR or MobilityData gtfs-realtime-bindings JAR in OpenHAB?
  • Where should I place the JAR to make it available to rules?
  1. Are there working examples of using Java protobuf to read GTFS-RT in OpenHAB JS rules or Java rules?

I want to avoid external Node.js scripts if possible and handle large feeds safely without hitting OpenHAB’s string/buffer limits.

Thanks in advance for any advice or example code!

Maybe @rlkoshak can you support with your knowledge?

As far as I know it’s not possible. At least it’s not possible without converting that library into an OSGI bundle and then deploying it in a way that it can be accessed through the OSGI APIs to pull in an instance of the classes and Objects you need.

I have no idea how to do that though.