gtfs2: Bug: `homeassistant.exceptions.ConfigEntryNotReady: 'str' object has no attribute 'engine'`

Describe the bug Unable to set up GTFS V2 using Transport for Ireland (tfi) data source.

Steps/data to reproduce the behavior, e.g.

Just trying to get the information into the app at all, using the “departures near a location” option when setting up a stop.

Auth is required for real time information via an API key, that may have some impact?

My datasource is named tfi-dublin-bus.

Release used HACS and the latest release as of today (2024-03-24)

Additional

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 318, in _async_refresh
    self.data = await self._async_update_data()
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/gtfs2/coordinator.py", line 234, in _async_update_data
    self._data["local_stops_next_departures"] = await self.hass.async_add_executor_job(
                                                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/gtfs2/gtfs_helper.py", line 787, in get_local_stops_next_departures
    result = schedule.engine.connect().execute(
             ^^^^^^^^^^^^^^^
AttributeError: 'str' object has no attribute 'engine'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 350, in _async_setup_platform
    await asyncio.shield(awaitable)
  File "/config/custom_components/gtfs2/sensor.py", line 75, in async_setup_entry
    await coordinator.async_config_entry_first_refresh()
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 290, in async_config_entry_first_refresh
    raise ex
homeassistant.exceptions.ConfigEntryNotReady: 'str' object has no attribute 'engine'
$ ls -ahl /data/home-assistant/gtfs2/
total 78M
drwxrwxrwx 1 1024 users  142 Mar 24 19:19 .
drwxrwxrwx 1 1026 users  538 Mar 24 19:23 ..
-rwxrwxrwx 1 1024 users 188K Mar 24 19:19 tfi-dublin-bus.sqlite
-rwxrwxrwx 1 1024 users 1.7M Mar 24 19:19 tfi-dublin-bus_temp_out.zip
-rwxrwxrwx 1 1024 users  76M Mar 24 19:19 tfi-dublin-bus_temp.zip
$

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 39 (20 by maintainers)

Most upvoted comments

Release 0.4.2. now catches better if extracting still ongong and avoid crash of the sqlite. I cannot fix the issue why it is not extracting at all as I cannot reproduce that using the same url/source. Closing this topic

My proposal is to restart (get rid of orphan processes), retry the datasource and wait before adding a stop. My extract took 50mins…

The re-zip prevented sqlite-journal creation during zip-cleaning. I use a external library to create the sqlite which is not really supported anylonger so have to come up with my own ‘onventions’ and I am not a real dev 😃

FYI… my re-zip is a bit overly complex but it worked stable… filename.zip is downloaded, then renamed to filename_temp.zip then this is cleaned to filename_temp_out.zip which is then again renamed to filename.zip

Having thought it through, I believe this is the cause… the process is still trying to create a ‘cleaned’ new zip but somewhere it creates the sqlite…only after the new zip is there the sqlite-journal is being created and I check only on the latter… You seem to be too fast 😃 … or: my check has gaps 😃

After you submitted the datasource, please donot try to add a stop…let it run. It may be that my check-on-etxracting is not working

Can you try to run the integration in debug mode please… maybe something else will pop-up.

yeah…deleting is now deleting with *, I did not anticipate on multiple sources for the same area/city… will redo that too The .nfs are from the current process so these will go when you restart (I guess you know this already) Irish rail is working? i.e. only issues with the link all above this post?