Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

entur_public_transport - fails if no "StopPlace" defined #19232

Closed
aherbjornsen opened this issue Dec 12, 2018 · 3 comments · Fixed by #19267
Closed

entur_public_transport - fails if no "StopPlace" defined #19232

aherbjornsen opened this issue Dec 12, 2018 · 3 comments · Fixed by #19267

Comments

@aherbjornsen
Copy link

Home Assistant release with the issue: 0.84.0b4

Last working Home Assistant release (if known):

Operating environment (Hass.io/Docker/Windows/etc.): Hass.io on Ubuntu

Component/platform: https://www.home-assistant.io/components/sensor.entur_public_transport/

Description of problem: Component fails if only "Quay" is defined, adding a "StopPlace" line resolves the problem

Problem-relevant configuration.yaml entries and (fill out even if it seems unimportant):

#This config fails
- platform: entur_public_transport
  name: Busstider
  expand_platforms: true
  show_on_map: true
  stop_ids:
    - 'NSR:Quay:12089'
    - 'NSR:Quay:11976'
#This config works
- platform: entur_public_transport
  name: Busstider
  expand_platforms: true
  show_on_map: true
  stop_ids:
    - 'NSR:StopPlace:548'
    - 'NSR:Quay:12089'
    - 'NSR:Quay:11976'

Traceback (if applicable):

2018-12-12 20:02:43 ERROR (MainThread) [homeassistant.components.sensor] Error while setting up platform entur_public_transport
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/homeassistant/helpers/entity_platform.py", line 128, in _async_setup_platform
    SLOW_SETUP_MAX_WAIT, loop=hass.loop)
  File "/usr/local/lib/python3.6/asyncio/tasks.py", line 358, in wait_for
    return fut.result()
  File "/usr/local/lib/python3.6/concurrent/futures/thread.py", line 56, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/local/lib/python3.6/site-packages/homeassistant/components/sensor/entur_public_transport.py", line 80, in setup_platform
    data = EnturPublicTransportData(API_CLIENT_NAME, stops, quays, expand)
  File "/usr/local/lib/python3.6/site-packages/enturclient/api.py", line 27, in __init__
    self._expand_all_quays()
  File "/usr/local/lib/python3.6/site-packages/enturclient/api.py", line 74, in _expand_all_quays
    if len(stop_place['quays']) > 1:
TypeError: 'NoneType' object is not subscriptable

Additional information:

@aherbjornsen aherbjornsen changed the title entur_public_transport - fails if no stations defined entur_public_transport - fails if no "StopPlace" defined Dec 12, 2018
@Danielhiversen
Copy link
Member

@hfurubotten Any idea ?

@hfurubotten
Copy link
Contributor

If you set expand_platforms: false it should work without the *:StopPlace:* in the configuration.
The *:Quay:* ids are the platforms coming from the stations found in EnTur's systems, so the expand_platforms would only be useful with a *:StopPlace:* in the config.
Throwing an exception is a bug, so I would have to fix that, but this should work for now, @aherbjornsen 😃

@aherbjornsen
Copy link
Author

Yes, I can confirm that when setting expand_platforms: false it does work.
I can live with that (I could even live with a "dummy" stop). @hfurubotten Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants