zacs / ha-gtfs-rt

Real-time transit information for Home Assistant
MIT License
69 stars 30 forks source link

Not working for (French based) region #24

Closed vingerha closed 1 year ago

vingerha commented 2 years ago

For the departures, I tried with/out quotes, error remains

HA 2022.09 gtfs_rt : latest Config:

  - platform: gtfs_rt
    trip_update_url: "https://www.data.gouv.fr/fr/datasets/r/0261a9ae-4874-4d87-8a92-6ae1c9fa68c7"
    departures:
    - name: Stop 530 Test RT
      route: LR530|20181213
      stopid: STOPPOINT:00812

Error without quotes in 'departures'

Error while setting up gtfs_rt platform for sensor
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 281, in _async_setup_platform
    await asyncio.shield(task)
  File "/usr/local/lib/python3.10/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/config/custom_components/gtfs_rt/sensor.py", line 78, in setup_platform
    sensors.append(PublicTransportSensor(
  File "/config/custom_components/gtfs_rt/sensor.py", line 97, in __init__
    self.update()
  File "/config/custom_components/gtfs_rt/sensor.py", line 145, in update
    self.data.update()
  File "/usr/src/homeassistant/homeassistant/util/__init__.py", line 192, in wrapper
    result = method(*args, **kwargs)
  File "/config/custom_components/gtfs_rt/sensor.py", line 168, in update
    self._update_route_statuses(positions, vehicles_trips, occupancy)
  File "/config/custom_components/gtfs_rt/sensor.py", line 184, in _update_route_statuses
    feed.ParseFromString(response.content)
  File "/usr/local/lib/python3.10/site-packages/google/protobuf/message.py", line 202, in ParseFromString
    return self.MergeFromString(serialized)
  File "/usr/local/lib/python3.10/site-packages/google/protobuf/internal/python_message.py", line 1128, in MergeFromString
    if self._InternalParse(serialized, 0, length) != length:
  File "/usr/local/lib/python3.10/site-packages/google/protobuf/internal/python_message.py", line 1181, in InternalParse
    (data, new_pos) = decoder._DecodeUnknownField(
  File "/usr/local/lib/python3.10/site-packages/google/protobuf/internal/decoder.py", line 961, in _DecodeUnknownField
    (data, pos) = _DecodeUnknownFieldSet(buffer, pos)
  File "/usr/local/lib/python3.10/site-packages/google/protobuf/internal/decoder.py", line 940, in _DecodeUnknownFieldSet
    (data, pos) = _DecodeUnknownField(buffer, pos, wire_type)
  File "/usr/local/lib/python3.10/site-packages/google/protobuf/internal/decoder.py", line 965, in _DecodeUnknownField
    raise _DecodeError('Wrong wire type in tag.')
google.protobuf.message.DecodeError: Wrong wire type in tag.

Error with quotes

Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 281, in _async_setup_platform
await asyncio.shield(task)
File "/usr/local/lib/python3.10/concurrent/futures/thread.py", line 58, in run
result = self.fn(*self.args, **self.kwargs)
File "/config/custom_components/gtfs_rt/sensor.py", line 78, in setup_platform
sensors.append(PublicTransportSensor(
File "/config/custom_components/gtfs_rt/sensor.py", line 97, in __init__
self.update()
File "/config/custom_components/gtfs_rt/sensor.py", line 145, in update
self.data.update()
File "/usr/src/homeassistant/homeassistant/util/__init__.py", line 192, in wrapper
result = method(*args, **kwargs)
File "/config/custom_components/gtfs_rt/sensor.py", line 168, in update
self._update_route_statuses(positions, vehicles_trips, occupancy)
File "/config/custom_components/gtfs_rt/sensor.py", line 184, in _update_route_statuses
feed.ParseFromString(response.content)
File "/usr/local/lib/python3.10/site-packages/google/protobuf/message.py", line 202, in ParseFromString
return self.MergeFromString(serialized)
File "/usr/local/lib/python3.10/site-packages/google/protobuf/internal/python_message.py", line 1131, in MergeFromString
raise message_mod.DecodeError('Unexpected end-group tag.')
google.protobuf.message.DecodeError: Unexpected end-group tag.
dregin commented 2 years ago

I was seeing this for api.nationaltransport.ie, but it was because I'd appended ?format=json to the end of my request URL.

It looks like your API returns JSON by default. You likely want to see if they offer format switching as a parameter.

vingerha commented 2 years ago

I am not sure if I follow you. I think it is different problem? The examples in this repo all download a format 'pb' which I guess is google protobuf ?? I have no idea how to get this (french/non-responsive/non-interested) governmental institute to change any format So, my hope is that this repo can take json directly, but I am not even sure which structure and then IF the one I am targeting matches that structure. For Homeassistant, I now wrote a lengthy jinja template with rest and this works too but that is mediocre as a solution

zacs commented 1 year ago

The URL is a 404 so I can't see it any more. But you are correct that the component only works with Protobuf.