custom-components / sensor.ruter

A sensor platform that gives you information about next departures.
MIT License
2 stars 2 forks source link

Component doesn't start #3

Closed marcusramberg closed 5 years ago

marcusramberg commented 6 years ago

Version of the custom_component 3.0.0 Describe the bug Component errors out on start I have the following config:

  - platform: ruter
    stopid: 3011330

On startup I get this:

log

2018-10-20 19:53:44 ERROR (MainThread) [homeassistant.components.sensor] Error while setting up platform ruter
Traceback (most recent call last):
  File "/home/marcus/homeassistant/lib/python3.7/site-packages/homeassistant/helpers/entity_platform.py", line 128, in _async_setup_platform
    SLOW_SETUP_MAX_WAIT, loop=hass.loop)
  File "/usr/lib/python3.7/asyncio/tasks.py", line 412, in wait_for
    return fut.result()
  File "/usr/lib/python3.7/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/home/marcus/homeassistant/custom_components/sensor/ruter.py", line 43, in setup_platform
    add_devices([RuterSensor(stopid, destination)])
  File "/home/marcus/homeassistant/custom_components/sensor/ruter.py", line 56, in __init__
    self.update()
  File "/home/marcus/homeassistant/custom_components/sensor/ruter.py", line 61, in update
    self._defined_destination)
  File "/home/marcus/homeassistant/lib/python3.7/site-packages/pyruter/__init__.py", line 31, in getDepartureInfo
    departureResponse = departureRequest[count]['MonitoredVehicleJourney']
IndexError: list index out of range
marcusramberg commented 6 years ago

Realized I was one version behind on pyruter. After upgrading I still get the error but the stack trace is different:

2018-10-22 14:28:27 ERROR (MainThread) [homeassistant.components.sensor] Error while setting up platform ruter
Traceback (most recent call last):
  File "/home/marcus/homeassistant/lib/python3.7/site-packages/homeassistant/helpers/entity_platform.py", line 128, in _async_setup_platform
    SLOW_SETUP_MAX_WAIT, loop=hass.loop)
  File "/usr/lib/python3.7/asyncio/tasks.py", line 412, in wait_for
    return fut.result()
  File "/usr/lib/python3.7/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/home/marcus/homeassistant/custom_components/sensor/ruter.py", line 53, in setup_platform
    add_devices([RuterSensor(stopid, destination, numer_of_departures)])
  File "/home/marcus/homeassistant/custom_components/sensor/ruter.py", line 66, in __init__
    self.update()
  File "/home/marcus/homeassistant/custom_components/sensor/ruter.py", line 73, in update
    self._line = result[self._index]['line']
IndexError: list index out of range
ludeeus commented 6 years ago

That API call does not return expected values.. It looks like subway lines (stations) have a different response from the Ruter API :/ Will look into it

mkeeeey commented 5 years ago

Sorry for highjacking the same thread, but as the problem seems to be the same i'm writing here. I am experiencing the same problem with routes that are only trains. I get the same "IndexError: list index out of range". I tried from 7045100 to Oslo Sentralstasjon [tog] (Oslo).

ludeeus commented 5 years ago

Probably exactly the same error and reason, when I made this I only tested it with bus routes. I will probably have another version up soon (within a week or so)

ludeeus commented 5 years ago

@mkeeeey If you define a destination, that would have to be the final desination of the train, not where you are stepping off. for 7045100 I only see Eidsvoll and Skien

ludeeus commented 5 years ago

@marcusramberg I will not update this sensor, the current version is the last version, I'm working on getting this into Home Assistant now. When that happens your stop ID will be available to use.

Departures: [{'destination': 'Mortensrud', 'line': '3', 'time': '2018-11-05T18:55:36+01:00'}, {'destination': 'Kolsås', 'line': '3', 'time': '2018-11-05T18:56:46+01:00'}, {'destination': 'Avløs', 'line': '3', 'time': '2018-11-05T19:02:46+01:00'}, {'destination': 'Mortensrud', 'line': '3', 'time': '2018-11-05T19:03:29+01:00'}, {'destination': 'Mortensrud', 'line': '3', 'time': '2018-11-05T19:11:32+01:00'}]
ludeeus commented 5 years ago

https://github.com/home-assistant/home-assistant/pull/18237

stale[bot] commented 5 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.