puttyman / hass-amplifi

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

Integration stops providing all entities when device_tracker entities enabled #40

Closed hawksj closed 2 months ago

hawksj commented 8 months ago

When reinitialising integration, there are a number of device tracker entities added for connected devices that are disabled by default. In my HA, I am trying to use this integration for general network observation with connected devices and throughput.

After enabling the disabled entities, after approx 5 minutes, the integration stops providing any entities at all.

IMG_9410

This error message is found in home-assistant.log:

2023-11-02 20:57:17.059 ERROR (MainThread) [homeassistant.config_entries] Error unloading entry 172.20.0.1 for sensor Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/config_entries.py", line 551, in async_unload await self._async_process_on_unload(hass) File "/usr/src/homeassistant/homeassistant/config_entries.py", line 685, in _async_process_on_unload if job := self._on_unload.pop()(): ^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/amplifi/__init__.py", line 41, in async_stop_coordinator coordinator._async_stop_refresh(None) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ AttributeError: 'AmplifiDataUpdateCoordinator' object has no attribute '_async_stop_refresh' 2023-11-02 20:57:17.077 ERROR (MainThread) [homeassistant.config_entries] Error unloading entry 172.20.0.1 for device_tracker Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/config_entries.py", line 551, in async_unload await self._async_process_on_unload(hass) File "/usr/src/homeassistant/homeassistant/config_entries.py", line 685, 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'

3 minutes earlier, there was also this error logged. This appears to be the actual time the entities stopped being provided:

2023-11-02 20:54:13.914 ERROR (MainThread) [homeassistant.config_entries] Error unloading entry 172.20.0.1 for sensor Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/config_entries.py", line 543, in async_unload result = await component.async_unload_entry(hass, self) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/components/sensor/__init__.py", line 132, in async_unload_entry return await component.async_unload_entry(entry) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 202, in async_unload_entry raise ValueError("Config entry was never loaded!") ValueError: Config entry was never loaded! 2023-11-02 20:54:13.934 ERROR (MainThread) [homeassistant.config_entries] Error unloading entry 172.20.0.1 for device_tracker Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/config_entries.py", line 543, in async_unload result = await component.async_unload_entry(hass, self) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/components/device_tracker/config_entry.py", line 81, in async_unload_entry return await component.async_unload_entry(entry) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 202, in async_unload_entry raise ValueError("Config entry was never loaded!") ValueError: Config entry was never loaded!

172.20.0.1 is the IP address of my Amplifi Router so why it is trying to be unloaded, I’m not entirely sure. My best guess is that Home Assistant is either disconnecting or switching to another mesh point and in momentarily disconnecting from the router, it tries to remove… the router? To rule out any issues with bouncing between mesh points, I will create an SSID only broadcast from one device so HA can’t roam and see if that solves the issue.

Any insight that anyone can offer into what is going on here would be greatly appreciated. Unfortunately I’m not massively experienced with Python at this level so I’m pushed for how far I can take this, but happy to lend a hand where I can.

Cheers

hawksj commented 2 months ago

My HA is now on Ethernet rather than WiFi and this doesn't seem to happen as much any more. If the entities do become unavailable, restarting HA brings them back. Not sure why this happens. I'm not too fussed about fixing it as I am the only one to complain about it so until someone else does, I will close this issue.