Kane610 / aiounifi

Asynchronous library to communicate with Unifi Controller
MIT License
59 stars 51 forks source link

Traffic rules (v64) broken with old controller versions #517

Closed paravoid closed 9 months ago

paravoid commented 9 months ago

The 2023.11 Home Assistant upgrade brought aiounifi v64 with it, which in turn enabled the Traffic Rules functionality (#409)

In one of the setups I maintain, I run a very old controller version, 6.0.45. Ubiquiti had stated that this is the last version that supported the original, legacy UAPs, EOLed in 2021. (A quick search reveals that users have had success with newer versions, but this is an antiquated setup that I haven't dared to touch.)

This version does not have the traffic rules API, or in fact, the /v2/ API at all, resulting into the integration not starting up:

Backtrace from Home Assistant

``` Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/config_entries.py", line 402, in async_setup result = await component.async_setup_entry(hass, self) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/components/unifi/__init__.py", line 40, in async_setup_entry await controller.initialize() File "/usr/src/homeassistant/homeassistant/components/unifi/controller.py", line 252, in initialize await self.api.initialize() File "/usr/local/lib/python3.11/site-packages/aiounifi/controller.py", line 78, in initialize await asyncio.gather(*[update() for update in self.update_handlers]) File "/usr/local/lib/python3.11/site-packages/aiounifi/interfaces/api_handlers.py", line 101, in update raw = await self.controller.request(self.api_request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/aiounifi/controller.py", line 74, in request return await self.connectivity.request(api_request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/aiounifi/interfaces/connectivity.py", line 82, in request response, bytes_data = await self._request( ^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/aiounifi/interfaces/connectivity.py", line 134, in _request raise ResponseError(f"Call {url} received 404 Not Found") aiounifi.errors.ResponseError: Call https://unifi.void.home:8443/v2/api/site/default/trafficrules received 404 Not Found ```

I tried to find in which version, or even year, this API was introduced but was ultimately unsuccessful.

I'll fully and completely understand if you don't want to make compromises for obsolete & Ubiquiti-unsupported controller versions, and you therefore decide to decline this issue. At the same time, perhaps the traffic rule functionality isn't super core to the integration, and gracefully handling its absence isn't a huge toll?

Anecdotally, I think the old controller+UAP combo is still relatively popular due to Ubiquiti's somewhat abrupt end of support, combined with the hardware shortages and the resulting small per customer quotas, as well as the slow product development of the the past couple of years.

Thanks for the consideration regardless :)

Kane610 commented 9 months ago

For this case right now I will be fixing the issue, but this isn't a promise to continue supporting old versions of UniFi indefinitely.

I think its perfectly valid to just as well expect to spend some time working on a backup of the UniFi system at hand and upgrading it to see if it works or not.