Vasttrafik

Hello,

Is anyone else having this issue when trying to add the vasttrafik sensor to HA?

2017-07-19 11:48:00 ERROR (MainThread) [homeassistant.components.sensor] Error while setting up platform vasttrafik
Traceback (most recent call last):
File “/srv/homeassistant/lib/python3.4/site-packages/homeassistant/helpers/entity_component.py”, line 164, in _async_setup_platform
SLOW_SETUP_MAX_WAIT, loop=self.hass.loop)
File “/usr/lib/python3.4/asyncio/tasks.py”, line 372, in wait_for
return fut.result()
File “/usr/lib/python3.4/asyncio/futures.py”, line 277, in result
raise self._exception
File “/usr/lib/python3.4/concurrent/futures/thread.py”, line 54, in run
result = self.fn(*self.args, **self.kwargs)
File “/srv/homeassistant/lib/python3.4/site-packages/homeassistant/components/sensor/vasttrafik.py”, line 58, in setup_platform
departure.get(CONF_DELAY)))
File “/srv/homeassistant/lib/python3.4/site-packages/homeassistant/components/sensor/vasttrafik.py”, line 70, in init
self._departure = planner.location_name(departure)[0]
File “/home/homeassistant/.homeassistant/deps/vasttrafik/journy_planner.py”, line 84, in location_name
input=name)
File “/home/homeassistant/.homeassistant/deps/vasttrafik/journy_planner.py”, line 151, in _request
str(res.content))
vasttrafik.journy_planner.Error: Error: 403b’{“fault”:{“code”:900908,“message”:"Resource forbidden ",“description”:“Access failure for API: /bin/rest.exe/v2, version: v2”}}’

I’ve added the correct key and secret.

Regards,

I had the same error 1 or 2 day ago when, apparently, there was a problem on the Västraffik side. At least, I couldn’t log in my console either. Now everything is ok.

Hello,

I’m still seeing this error and it doesn’t work :frowning_face:

2017-08-21 21:16:48 ERROR (MainThread) [homeassistant.components.sensor] Error while setting up platform vasttrafik
Traceback (most recent call last):
  File "/srv/homeassistant/lib/python3.4/site-packages/homeassistant/helpers/entity_component.py", line 164, in _async_setup_platform
    SLOW_SETUP_MAX_WAIT, loop=self.hass.loop)
  File "/usr/lib/python3.4/asyncio/tasks.py", line 372, in wait_for
    return fut.result()
  File "/usr/lib/python3.4/asyncio/futures.py", line 277, in result
    raise self._exception
  File "/usr/lib/python3.4/concurrent/futures/thread.py", line 54, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/srv/homeassistant/lib/python3.4/site-packages/homeassistant/components/sensor/vasttrafik.py", line 64, in setup_platform
    departure.get(CONF_DELAY)))
  File "/srv/homeassistant/lib/python3.4/site-packages/homeassistant/components/sensor/vasttrafik.py", line 76, in __init__
    self._departure = planner.location_name(departure)[0]
  File "/srv/homeassistant/lib/python3.4/site-packages/vasttrafik/journy_planner.py", line 84, in location_name
    input=name)
  File "/srv/homeassistant/lib/python3.4/site-packages/vasttrafik/journy_planner.py", line 151, in _request
    str(res.content))
vasttrafik.journy_planner.Error: Error: 403b'{"fault":{"code":900908,"message":"Resource forbidden ","description":"Access failure for API: /bin/rest.exe/v2, version: v2"}}'

Got any clues?

Solution is found here: https://community.home-assistant.io/t/anyone-using-vasttrafik-component/9989/3

You need to also add a prenumeration of the Reseplanerar API for your application.

Best regards / Erik Laneborg

I actually fount it! Awesome. Thanks

For whomever still have this problem, try;

  1. Create new API Application
  2. Add Subscription (Prenumerationer) to the Application.
  3. Generate key and secret.

Not sure if this is will add any value, but I found that key and secret containing underscore (_) would fail.

Hi,

I’ve tried creating a new application and subscribing to reseplanerare v2 before setting it up in hass.io 0.56.1 but it seems like it still struggles.

I’m using the key and secret created at Västtrafik along with the default configuration example:

  - platform: vasttrafik
    key: xxxxx
    secret: xxxx
    departures:
      - from: Musikvägen

The api key and secret don’t contain any underscores (_).

When restarting home-assistant it just throws a couple of errors…

2017-10-24 12:13:19 ERROR (MainThread) [homeassistant.components.sensor] Error while setting up platform vasttrafik
Traceback (most recent call last):
  File "/usr/lib/python3.6/site-packages/requests/packages/urllib3/connectionpool.py", line 600, in urlopen
    chunked=chunked)
  File "/usr/lib/python3.6/site-packages/requests/packages/urllib3/connectionpool.py", line 345, in _make_request
    self._validate_conn(conn)
  File "/usr/lib/python3.6/site-packages/requests/packages/urllib3/connectionpool.py", line 844, in _validate_conn
    conn.connect()
  File "/usr/lib/python3.6/site-packages/requests/packages/urllib3/connection.py", line 337, in connect
    cert = self.sock.getpeercert()
  File "/usr/lib/python3.6/ssl.py", line 891, in getpeercert
    self._check_connected()
  File "/usr/lib/python3.6/ssl.py", line 855, in _check_connected
    self.getpeername()
OSError: [Errno 107] Socket not connected

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.6/site-packages/requests/adapters.py", line 438, in send
    timeout=timeout
  File "/usr/lib/python3.6/site-packages/requests/packages/urllib3/connectionpool.py", line 649, in urlopen
    _stacktrace=sys.exc_info()[2])
  File "/usr/lib/python3.6/site-packages/requests/packages/urllib3/util/retry.py", line 357, in increment
    raise six.reraise(type(error), error, _stacktrace)
  File "/usr/lib/python3.6/site-packages/requests/packages/urllib3/packages/six.py", line 685, in reraise
    raise value.with_traceback(tb)
  File "/usr/lib/python3.6/site-packages/requests/packages/urllib3/connectionpool.py", line 600, in urlopen
    chunked=chunked)
  File "/usr/lib/python3.6/site-packages/requests/packages/urllib3/connectionpool.py", line 345, in _make_request
    self._validate_conn(conn)
  File "/usr/lib/python3.6/site-packages/requests/packages/urllib3/connectionpool.py", line 844, in _validate_conn
    conn.connect()
  File "/usr/lib/python3.6/site-packages/requests/packages/urllib3/connection.py", line 337, in connect
    cert = self.sock.getpeercert()
  File "/usr/lib/python3.6/ssl.py", line 891, in getpeercert
    self._check_connected()
  File "/usr/lib/python3.6/ssl.py", line 855, in _check_connected
    self.getpeername()
requests.packages.urllib3.exceptions.ProtocolError: ('Connection aborted.', OSError(107, 'Socket not connected'))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.6/site-packages/homeassistant/helpers/entity_component.py", line 170, in _async_setup_platform
    SLOW_SETUP_MAX_WAIT, loop=self.hass.loop)
  File "/usr/lib/python3.6/asyncio/tasks.py", line 352, in wait_for
    return fut.result()
  File "/usr/lib/python3.6/asyncio/futures.py", line 244, in result
    raise self._exception
  File "/usr/lib/python3.6/concurrent/futures/thread.py", line 55, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/lib/python3.6/site-packages/homeassistant/components/sensor/vasttrafik.py", line 57, in setup_platform
    config.get(CONF_KEY), config.get(CONF_SECRET))
  File "/usr/lib/python3.6/site-packages/vasttrafik/journy_planner.py", line 38, in __init__
    self.update_token()
  File "/usr/lib/python3.6/site-packages/vasttrafik/journy_planner.py", line 49, in update_token
    response = requests.post(TOKEN_URL, data=data, headers=headers)
  File "/usr/lib/python3.6/site-packages/requests/api.py", line 112, in post
    return request('post', url, data=data, json=json, **kwargs)
  File "/usr/lib/python3.6/site-packages/requests/api.py", line 58, in request
    return session.request(method=method, url=url, **kwargs)
  File "/usr/lib/python3.6/site-packages/requests/sessions.py", line 518, in request
    resp = self.send(prep, **send_kwargs)
  File "/usr/lib/python3.6/site-packages/requests/sessions.py", line 639, in send
    r = adapter.send(request, **kwargs)
  File "/usr/lib/python3.6/site-packages/requests/adapters.py", line 488, in send
    raise ConnectionError(err, request=request)
requests.exceptions.ConnectionError: ('Connection aborted.', OSError(107, 'Socket not connected'))

Is there something that I might have forgotten?

Any help would be appreciated!

Also waiting 15 minutes after creating the application and subscribing might help as well, but it seems to work intermittently for me I’m afraid. Managed to get it work after one reboot, after the next, the same error appears.

Were you able to get Västtrafik to work? I haven’t been able to get it to work. I have tried 4 times over the last month or so. Getting this error:

Error while setting up platform vasttrafik

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 150, in _async_setup_platform
    await asyncio.wait_for(asyncio.shield(task), SLOW_SETUP_MAX_WAIT)
  File "/usr/local/lib/python3.7/asyncio/tasks.py", line 442, in wait_for
    return fut.result()
  File "/usr/local/lib/python3.7/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/src/homeassistant/homeassistant/components/vasttrafik/sensor.py", line 71, in setup_platform
    departure.get(CONF_DELAY),
  File "/usr/src/homeassistant/homeassistant/components/vasttrafik/sensor.py", line 86, in __init__
    self._heading = planner.location_name(heading)[0] if heading else None
KeyError: 0

Works fine for me most of the time. Sometimes it fails and usually comes back after a reboot.

It seems that it has something to do with åäö characters. The strange thing is that Musikvägen works, but not Blixås. Blixas works though. Well I finally got it working. Now I just need to figure out the best way to show this :slight_smile:

Hi, has anyone faced with this problem:

Mine did that too. All of a sudden, the sensors didn’t work. I didn’t have time at that moment to fix it, but later on, it started working all by itself again. Very wierd!