puttyman / hass-amplifi

A home assistant integration for Ubiquiti Amplifi
27 stars 16 forks source link

Coordinator missing async_remove_listener #49

Open hawksj opened 2 months ago

hawksj commented 2 months ago

When deleting the config entry, the following error is raised:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 780, in async_unload
    await self._async_process_on_unload(hass)
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 934, in _async_process_on_unload
    if job := self._on_unload.pop()():
              ^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/amplifi/device_tracker.py", line 56, in async_unsub_discover_device_tracker
    coordinator.async_remove_listener(async_discover_device_tracker)
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'AmplifiDataUpdateCoordinator' object has no attribute 'async_remove_listener'. Did you mean: 'async_add_listener'?

The coordinator does not have an "async_remove_listener" function. This is the same error message mentioned in #40 but now I know what the issue actually is... I'm just not sure how to fix it right now. Raising this issue as something I hope to do in the future.

atudor2 commented 2 months ago

Related blog that I found mentioning this method - wonder if a breaking change on the HA side? https://developers.home-assistant.io/blog/2022/06/02/update_coordinator-context/

hawksj commented 2 months ago

I think you're right that this is related, I found the same thing looking up this method. I don't know how custom integrations are supposed to work well enough to tackle this right now.

This integration uses a few methods in this article: https://developers.home-assistant.io/docs/config_entries_index/

That links on to the async_will_remove_from_hass which is briefly described here: https://developers.home-assistant.io/docs/core/entity/#async_will_remove_from_hass

I need to sit down and properly to try to figure out the series of calls that are made when a config entry is removed. I'm also not sure how async_remove_listeners relates to the methods in the articles above. I think I need to step through it all and see what happens on unload.