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:
- 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.
- 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.
- Java protobuf (
protobuf-java)
- Attempting to use generated classes like
transit_realtime.FeedMessageresults 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:
- What is the best way to decode GTFS-Realtime feeds inside OpenHAB rules (JS or Java)?
- 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?
- 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!