ryanbateman / bvg-sensor

A HomeAssistant / HACS integration of Berlin Public Transport (BVG)
The Unlicense
14 stars 1 forks source link

BVG Sensor Issue #9

Open ndom91 opened 1 year ago

ndom91 commented 1 year ago

Seems the integration can no longer pull updates correctly. I'm using a version 0.0.1 according to the manifest.json in my custom_components/bvg_berlin_public_transport/manifest.json, but 0.3.1 according to HACS

sensor.yaml config:

- platform: bvg_berlin_public_transport
  name: M5 > Hohenschönhausen, Zingster Str.
  direction: "Hohenschönhausen, Zingster Str."
  stop_id: "900000120513"
  walking_distance: 0

Logs:

2023-06-04 15:17:55.735 ERROR (MainThread) [homeassistant.helpers.entity] Update for sensor.m5_hohenschonhausen_zingster_str fails
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 554, in async_update_ha_state
    await self.async_device_update()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 781, in async_device_update
    await hass.async_add_executor_job(self.update)
  File "/usr/local/lib/python3.10/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/config/custom_components/bvg_berlin_public_transport/sensor.py", line 154, in update
    self.singleConnection = self.getSingleConnection(self.direction, self.min_due_in, 0)
  File "/config/custom_components/bvg_berlin_public_transport/sensor.py", line 182, in getSingleConnection
    for pos in self.data:
TypeError: 'NoneType' object is not iterable

Also on the integration page, none of those sensors seem to appear :thinking:

image

EDIT: Debug logging enabled confirms my fears, BVG endpoint returning a 503


2023-06-04 16:21:21.543 DEBUG (SyncWorker_2) [custom_components.bvg_berlin_public_transport.sensor] HTTP Error 503: Service Unavailable
2023-06-04 16:21:21.543 WARNING (SyncWorker_2) [custom_components.bvg_berlin_public_transport.sensor] Connection to BVG API lost, using local cache instead
ndom91 commented 1 year ago

The v5 API endpoint (https://v5.bvg.transport.rest/stops/{}...., sensor.py:99) yuo're using here seems to be deprecated:

image

https://transport.rest/

ndom91 commented 1 year ago

Theres a ton of left over from the template you used to set this up as well. I'm trying to see if I can clean up some of that stuff and bump the API version here: https://github.com/ryanbateman/bvg-sensor/pull/10