puttyman / hass-amplifi

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

Log is filled with "Session is closed" #24

Closed rackabajsarn closed 1 month ago

rackabajsarn commented 1 year ago

My entities are unavailable and my logfile is getting filled with this message:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 205, in _async_refresh
    self.data = await self._async_update_data()
  File "/config/custom_components/amplifi/coordinator.py", line 55, in _async_update_data
    devices = await self._client.async_get_devices()
  File "/config/custom_components/amplifi/client.py", line 26, in async_get_devices
    return await self._async_get_info()
  File "/config/custom_components/amplifi/client.py", line 81, in _async_get_info
    resp = await self._client.post(info_async_url, data=form_data)
  File "/usr/local/lib/python3.10/site-packages/aiohttp/client.py", line 399, in _request
    raise RuntimeError("Session is closed")
RuntimeError: Session is closed

Does anyone know what might be the issue? Firmware version 3.7.1 Amplifi Router HD

teaching-innovation commented 1 year ago

Same problem for me. Possibly one of many but following for a solution. Happy to do some debugging with some instructions.


This error originated from a custom integration.

Logger: custom_components.amplifi.coordinator
Source: custom_components/amplifi/client.py:81 
Integration: Amplifi (documentation, issues) 
First occurred: 06:26:36 (3 occurrences) 
Last logged: 06:26:56

Unexpected error fetching amplifi data: Session is closed
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 205, in _async_refresh
    self.data = await self._async_update_data()
  File "/config/custom_components/amplifi/coordinator.py", line 55, in _async_update_data
    devices = await self._client.async_get_devices()
  File "/config/custom_components/amplifi/client.py", line 26, in async_get_devices
    return await self._async_get_info()
  File "/config/custom_components/amplifi/client.py", line 81, in _async_get_info
    resp = await self._client.post(info_async_url, data=form_data)
  File "/usr/local/lib/python3.10/site-packages/aiohttp/client.py", line 399, in _request
    raise RuntimeError("Session is closed")
RuntimeError: Session is closed
teaching-innovation commented 1 year ago

This is my other error that is showing in the log for more context.


Logger: homeassistant.config_entries
Source: helpers/entity_component.py:175 
First occurred: 06:35:18 (2 occurrences) 
Last logged: 06:35:18

Error unloading entry 192.168.&&.&& for sensor
Error unloading entry 192.168.&&.&& for device_tracker
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 498, in async_unload
    result = await component.async_unload_entry(hass, self)
  File "/usr/src/homeassistant/homeassistant/components/sensor/__init__.py", line 262, in async_unload_entry
    return await component.async_unload_entry(entry)
  File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 175, in async_unload_entry
    raise ValueError("Config entry was never loaded!")
ValueError: Config entry was never loaded!
teaching-innovation commented 1 year ago

@rackabajsarn I did a fair bit of searching for solutions today. I noticed this problem comes up when you delete and then re add the integration without restarting HA. It seems to go and get new login and info tokens and keeps processing the old tokens. When I did this today my integration was flicking between 2 and 30 devices depending if it was using old or new tokens.

My advice would be to delete the integration, restart HA, then install the integration and set it up.

Unfortunately my problem seems that only devices that are also used by other integration such as sonoff get updated. All my devices seem to be found by the integration and the total number of entities matches my connected devices in the app but it leaves them as status "disabled"

Any ideas? @puttyman

hawksj commented 1 month ago

As with #23, closing this issue as stale. Please report again if these issues persist. Unable to replicate on this end. #22 says reinstall fixed the issue.