hass-amplifi icon indicating copy to clipboard operation
hass-amplifi copied to clipboard

Coordinator missing async_remove_listener

Open hawksj opened this issue 1 year ago • 2 comments

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.

hawksj avatar May 16 '24 14:05 hawksj

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/

atudor2 avatar May 16 '24 17:05 atudor2

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.

hawksj avatar May 17 '24 13:05 hawksj