home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
71.5k stars 29.91k forks source link

AttributeError: 'TransportNSW' object has no attribute 'get_departures' #123965

Open alexeiw123 opened 1 month ago

alexeiw123 commented 1 month ago

The problem

Sensor is not created on boot due to an error: transport_nsw: Error on device update!

AttributeError: 'TransportNSW' object has no attribute 'get_departures'

What version of Home Assistant Core has the issue?

core-2024.8.1

What was the last working version of Home Assistant Core?

core-2024.8.1

What type of installation are you running?

Home Assistant OS

Integration causing the issue

transport nsw

Link to integration documentation on our website

https://www.home-assistant.io/integrations/transport_nsw

Diagnostics information

No response

Example YAML snippet

sensor:
  - platform: transport_nsw
    name: "Afternoon Bus"
    stop_id: "***"
    route: "***"
    api_key: !secret TfNSW_API_Key

### Anything in the logs that might be useful for us?

```txt
Logger: homeassistant.components.sensor
Source: helpers/entity_platform.py:727
integration: Sensor (documentation, issues)
First occurred: 3:14:53 PM (1 occurrences)
Last logged: 3:14:53 PM

transport_nsw: Error on device update!
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 727, in _async_add_entity
    await entity.async_device_update(warning=False)
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1302, in async_device_update
    await hass.async_add_executor_job(self.update)
  File "/usr/local/lib/python3.12/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/transport_nsw/sensor.py", line 128, in update
    self.data.update()
  File "/usr/src/homeassistant/homeassistant/components/transport_nsw/sensor.py", line 160, in update
    _data = self.tnsw.get_departures(
            ^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'TransportNSW' object has no attribute 'get_departures'


### Additional information

_No response_
home-assistant[bot] commented 1 month ago

transport_nsw documentation transport_nsw source

andystewart999 commented 3 weeks ago

I think this might originally have been caused by my forked integration, relating to duplicated class names, but (a) I've fixed that and it hasn't resolved the issue and (b) uninstalling it prior to the fix didn't resolve the issue either.

I think somehow that Home Assistant only maintains a single location/database for Python modules installed via the manifest? After an HA upgrade (ie 2024.8.0 to 2024.8.1) the problem goes away which suggest to me that the baked-in integrations and their dependencies are being re-installed over whatever's currently in place?

alexeiw123 commented 3 weeks ago

yes, I can confirm I did try both integrations.