finish06 / pyunifi

https://unifi-sdn.ubnt.com/
MIT License
226 stars 100 forks source link

Authentication issue with unifi controller 5.5.9 #3

Closed nunofgs closed 7 years ago

nunofgs commented 7 years ago

I'm using the unify home assistant component which depends on this library at version 2.0.0.

After updating my unifi controller to the latest beta (5.5.9), I noticed that my home-assistant unify integration stopped working.

Here's the debug output:

17-04-19 22:04:23 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "uvloop/future.pyx", line 374, in uvloop.loop.BaseTask._fast_step (uvloop/loop.c:112704)
  File "/usr/src/app/homeassistant/components/device_tracker/__init__.py", line 698, in async_device_tracker_scan
    found_devices = yield from scanner.async_scan_devices()
  File "uvloop/future.pyx", line 230, in __iter__ (uvloop/loop.c:110600)
  File "uvloop/future.pyx", line 432, in uvloop.loop.BaseTask._fast_wakeup (uvloop/loop.c:113980)
  File "uvloop/future.pyx", line 101, in uvloop.loop.BaseFuture._result_impl (uvloop/loop.c:108900)
  File "/usr/local/lib/python3.5/concurrent/futures/thread.py", line 55, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/src/app/homeassistant/components/device_tracker/unifi.py", line 88, in scan_devices
    self._update()
  File "/usr/src/app/homeassistant/components/device_tracker/unifi.py", line 79, in _update
    clients = self._controller.get_clients()
  File "/usr/local/lib/python3.5/site-packages/pyunifi/controller.py", line 183, in get_clients
    return self._read(self.api_url + 'stat/sta')
  File "/usr/local/lib/python3.5/site-packages/pyunifi/controller.py", line 82, in _read
    return self._jsondec(r.text)
  File "/usr/local/lib/python3.5/site-packages/pyunifi/controller.py", line 75, in _jsondec
    raise APIError(obj['meta']['msg'])
pyunifi.controller.APIError: api.err.LoginRequired

Any idea on what the issue may be?

finish06 commented 7 years ago

The controller connection is being logged out after a very short period of time without update. Do you have the update rate set in your home assistant configuration?

nunofgs commented 7 years ago

Do you have the update rate set in your home assistant configuration?

Good call. I've raised interval_seconds to 30 and my issue went away.

Thanks!