zacs / ha-gtfs-rt

Real-time transit information for Home Assistant

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Vehicle_position_url required or optional?

nrout-HA opened this issue · comments

Hi,
While experimenting with the example yamls, I noticed they will break with the following error if the vehicle_position_url is removed. The wiki states that this should be optional. Looking at the code, I'm not sure I'm following why it is breaking...

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 231, in _async_setup_platform
    await asyncio.shield(task)
  File "/usr/local/lib/python3.8/concurrent/futures/thread.py", line 57, 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 280, 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 {}
ValueError: not enough values to unpack (expected 3, got 0)

For example, this will load, but if removing the vehicle position line, it errors out.

  - platform: gtfs_rt
    trip_update_url: 'https://data.texas.gov/download/rmk2-acnw/application%2foctet-stream'
    vehicle_position_url: 'https://data.texas.gov/download/eiei-9rpf/application%2Foctet-stream'
    departures:
      - name: Downtown to airport
        route: 100
        stopid: 514
commented

Fixed in #19