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

OASA telematics unknown travel time #23542

Closed
sicutero opened this issue Apr 29, 2019 · 8 comments
Closed

OASA telematics unknown travel time #23542

sicutero opened this issue Apr 29, 2019 · 8 comments

Comments

@sicutero
Copy link

Home Assistant release with the issue:
0.92.1

Last working Home Assistant release (if known):

Operating environment (Hass.io/Docker/Windows/etc.):
Hass.io RPi3+

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

Description of problem:
The sensor will always show unknown as time of arrival.

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

  - platform: oasa_telematics
    name: 605
    route_id: 2509
    stop_id: '330115'

Traceback (if applicable):

Log Details (ERROR)
Mon Apr 29 2019 17:31:57 GMT+0300 (Eastern European Summer Time)
Update for sensor.605 fails
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/urllib3/connection.py", line 159, in _new_conn
    (self._dns_host, self.port), self.timeout, **extra_kw)
  File "/usr/local/lib/python3.7/site-packages/urllib3/util/connection.py", line 57, in create_connection
    for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM):
  File "/usr/local/lib/python3.7/socket.py", line 748, in getaddrinfo
    for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
socket.gaierror: [Errno -3] Try again

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/urllib3/connectionpool.py", line 600, in urlopen
    chunked=chunked)
  File "/usr/local/lib/python3.7/site-packages/urllib3/connectionpool.py", line 354, in _make_request
    conn.request(method, url, **httplib_request_kw)
  File "/usr/local/lib/python3.7/http/client.py", line 1229, in request
    self._send_request(method, url, body, headers, encode_chunked)
  File "/usr/local/lib/python3.7/http/client.py", line 1275, in _send_request
    self.endheaders(body, encode_chunked=encode_chunked)
  File "/usr/local/lib/python3.7/http/client.py", line 1224, in endheaders
    self._send_output(message_body, encode_chunked=encode_chunked)
  File "/usr/local/lib/python3.7/http/client.py", line 1016, in _send_output
    self.send(msg)
  File "/usr/local/lib/python3.7/http/client.py", line 956, in send
    self.connect()
  File "/usr/local/lib/python3.7/site-packages/urllib3/connection.py", line 181, in connect
    conn = self._new_conn()
  File "/usr/local/lib/python3.7/site-packages/urllib3/connection.py", line 168, in _new_conn
    self, "Failed to establish a new connection: %s" % e)
urllib3.exceptions.NewConnectionError: <urllib3.connection.HTTPConnection object at 0x6bb76a90>: Failed to establish a new connection: [Errno -3] Try again

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/requests/adapters.py", line 449, in send
    timeout=timeout
  File "/usr/local/lib/python3.7/site-packages/urllib3/connectionpool.py", line 638, in urlopen
    _stacktrace=sys.exc_info()[2])
  File "/usr/local/lib/python3.7/site-packages/urllib3/util/retry.py", line 399, in increment
    raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPConnectionPool(host='telematics.oasa.gr', port=80): Max retries exceeded with url: /api/?act=getStopArrivals&p1=330115 (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x6bb76a90>: Failed to establish a new connection: [Errno -3] Try again'))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/homeassistant/helpers/entity.py", line 220, in async_update_ha_state
    await self.async_device_update()
  File "/usr/local/lib/python3.7/site-packages/homeassistant/helpers/entity.py", line 377, in async_device_update
    await self.hass.async_add_executor_job(self.update)
  File "/usr/local/lib/python3.7/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/local/lib/python3.7/site-packages/homeassistant/components/oasa_telematics/sensor.py", line 116, in update
    self.data.update()
  File "/usr/local/lib/python3.7/site-packages/homeassistant/components/oasa_telematics/sensor.py", line 165, in update
    results = self.oasa_api.getStopArrivals(self.stop_id)
  File "/usr/local/lib/python3.7/site-packages/oasatelematics/__init__.py", line 62, in getStopArrivals
    return telematics_request(query)
  File "/usr/local/lib/python3.7/site-packages/oasatelematics/__init__.py", line 6, in telematics_request
    req = requests.post(api_endpoint + query)
  File "/usr/local/lib/python3.7/site-packages/requests/api.py", line 116, in post
    return request('post', url, data=data, json=json, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/requests/api.py", line 60, in request
    return session.request(method=method, url=url, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/requests/sessions.py", line 533, in request
    resp = self.send(prep, **send_kwargs)
  File "/usr/local/lib/python3.7/site-packages/requests/sessions.py", line 646, in send
    r = adapter.send(request, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/requests/adapters.py", line 516, in send
    raise ConnectionError(e, request=request)
requests.exceptions.ConnectionError: HTTPConnectionPool(host='telematics.oasa.gr', port=80): Max retries exceeded with url: /api/?act=getStopArrivals&p1=330115 (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x6bb76a90>: Failed to establish a new connection: [Errno -3] Try again'))

Additional information:

@smartHomeHub
Copy link

I’m using OASA API over 2 years and I want to mention that the service goes down several times a day. It seems that your issue is a connectivity problem.

@sicutero
Copy link
Author

sicutero commented May 1, 2019

Hey, it has never worked for me from day 1 since it was introduced with the new HA version.
I'm banging my head against the wall to find out what the issue is :(.

@sicutero
Copy link
Author

sicutero commented May 3, 2019

@panosmz can you have a look at it? thank you!

oasa_telematics: Error on device update!
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/homeassistant/helpers/entity_platform.py", line 261, in _async_add_entity
    await entity.async_device_update(warning=False)
  File "/usr/local/lib/python3.7/site-packages/homeassistant/helpers/entity.py", line 377, in async_device_update
    await self.hass.async_add_executor_job(self.update)
  File "/usr/local/lib/python3.7/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/local/lib/python3.7/site-packages/homeassistant/components/oasa_telematics/sensor.py", line 116, in update
    self.data.update()
  File "/usr/local/lib/python3.7/site-packages/homeassistant/components/oasa_telematics/sensor.py", line 190, in update
    sort = sorted(self.info, itemgetter(ATTR_NEXT_ARRIVAL))
TypeError: sorted expected 1 arguments, got 2

@panosmz
Copy link
Contributor

panosmz commented May 3, 2019

Hey @sicutero. This was solved in #23381, I forgot to open an issue, apologies for that. Your first issue was due to oasa api downtime, as @smartHomeHub mentioned, it can happen sometime during the day.

@sicutero
Copy link
Author

sicutero commented May 4, 2019

thank you !

@sicutero sicutero closed this as completed May 4, 2019
@sicutero sicutero reopened this May 19, 2019
@sicutero
Copy link
Author

sicutero commented May 19, 2019

Thank you for the update !
is this how the output supposed to be ? :
2019-05-19T13:53:29.639419+00:00
Also there is a 2 hour time deference.
HA itself is showining the correct time.

@panosmz
Copy link
Contributor

panosmz commented May 19, 2019

Yes, that's how it's supposed to be. The state returned is a utc timestamp, so you can choose the relative time representation on your frontend. See #22196 (comment).

You can format this value to display like In 2 minutes for example. Notice the +00:00 at the end of the timestamp. If you set your time_zone correctly and format the value to local time you should get the correct time.

@stale
Copy link

stale bot commented Aug 17, 2019

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates.
Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍
This issue now has been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Aug 17, 2019
@stale stale bot closed this as completed Aug 24, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants