zacs / ha-gtfs-rt

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

Error after upgrading to Release 2023.4.5 - Protocol Buffers Error? #27

Open christopherdopp opened 1 year ago

christopherdopp commented 1 year ago

After upgrading to 2023.4.5 I am getting the following error in my home-assistant.log file.

2023-04-18 11:56:23.726 ERROR (MainThread) [homeassistant.components.sensor] Error while setting up gtfs_rt platform for sensor
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 304, 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 190, in wrapper
    result = method(*args, **kwargs)
  File "/config/custom_components/gtfs_rt/sensor.py", line 167, in update
    positions, vehicles_trips, occupancy = self._get_vehicle_positions() if self._vehicle_position_url else [{}, {}, {}]
  File "/config/custom_components/gtfs_rt/sensor.py", line 220, in _get_vehicle_positions
    from google.transit import gtfs_realtime_pb2
  File "/usr/local/lib/python3.10/site-packages/google/transit/gtfs_realtime_pb2.py", line 50, in <module>
    _descriptor.EnumValueDescriptor(
  File "/usr/local/lib/python3.10/site-packages/google/protobuf/descriptor.py", line 796, in __new__
    _message.Message._CheckCalledFromGeneratedFile()
TypeError: Descriptors cannot not be created directly.
If this call came from a _pb2.py file, your generated code is out of date and must be regenerated with protoc >= 3.19.0.
If you cannot immediately regenerate your protos, some other possible workarounds are:
 1. Downgrade the protobuf package to 3.20.x or lower.
 2. Set PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=python (but this will use pure-Python parsing and will be much slower).

More information: https://developers.google.com/protocol-buffers/docs/news/2022-05-06#python-updates

Prior to this it has been working without issue. I have not changed my gtfs_rt configuration at all. I just noticed that sensors that normally are populated with realtime data do not exist.

Following the link at the bottom of the message indicates changes with Python Updates of Protocol Buffers.

christopherdopp commented 1 year ago

I switched to the latest release on the ha-gtfs-rt-v2 fork and my gtfs feeds are working again without any exceptions in the homeassistant.log file.