Unifi controller error

I’m getting an error after home assistant restarts and can not get unifi to see my devices

log:

Error setting up platform legacy
Traceback (most recent call last):
File “/usr/local/lib/python3.7/site-packages/urllib3/contrib/pyopenssl.py”, line 472, in wrap_socket
cnx.do_handshake()
File “/usr/local/lib/python3.7/site-packages/OpenSSL/SSL.py”, line 1915, in do_handshake
self._raise_ssl_error(self._ssl, result)
File “/usr/local/lib/python3.7/site-packages/OpenSSL/SSL.py”, line 1647, in _raise_ssl_error
_raise_current_error()
File “/usr/local/lib/python3.7/site-packages/OpenSSL/_util.py”, line 54, in exception_from_error_queue
raise exception_type(errors)
OpenSSL.SSL.Error: [(‘SSL routines’, ‘tls_process_server_certificate’, ‘certificate verify failed’)]

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File “/usr/local/lib/python3.7/site-packages/urllib3/connectionpool.py”, line 603, in urlopen
chunked=chunked)
File “/usr/local/lib/python3.7/site-packages/urllib3/connectionpool.py”, line 344, in _make_request
self._validate_conn(conn)
File “/usr/local/lib/python3.7/site-packages/urllib3/connectionpool.py”, line 843, in validate_conn
conn.connect()
File “/usr/local/lib/python3.7/site-packages/urllib3/connection.py”, line 370, in connect
ssl_context=context)
File "/usr/local/lib/python3.7/site-packages/urllib3/util/ssl
.py", line 368, in ssl_wrap_socket
return context.wrap_socket(sock)
File “/usr/local/lib/python3.7/site-packages/urllib3/contrib/pyopenssl.py”, line 478, in wrap_socket
raise ssl.SSLError(‘bad handshake: %r’ % e)
ssl.SSLError: (“bad handshake: Error([(‘SSL routines’, ‘tls_process_server_certificate’, ‘certificate verify failed’)])”,)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File “/usr/local/lib/python3.7/site-packages/requests/adapters.py”, line 449, in send
timeout=timeout
File “/usr/local/lib/python3.7/site-packages/urllib3/connectionpool.py”, line 641, in urlopen
_stacktrace=sys.exc_info()[2])
File “/usr/local/lib/python3.7/site-packages/urllib3/util/retry.py”, line 399, in increment
raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host=‘192.168.1.101’, port=8443): Max retries exceeded with url: /api/login (Caused by SSLError(SSLError(“bad handshake: Error([(‘SSL routines’, ‘tls_process_server_certificate’, ‘certificate verify failed’)])”)))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File “/usr/src/homeassistant/homeassistant/components/device_tracker/setup.py”, line 69, in async_setup_legacy
self.platform.get_scanner, hass, {DOMAIN: self.config})
File “/usr/local/lib/python3.7/concurrent/futures/thread.py”, line 57, in run
result = self.fn(*self.args, **self.kwargs)
File “/usr/src/homeassistant/homeassistant/components/unifi/device_tracker.py”, line 73, in get_scanner
site_id=site_id, ssl_verify=verify_ssl)
File “/usr/local/lib/python3.7/site-packages/pyunifi/controller.py”, line 89, in init
self._login()
File “/usr/local/lib/python3.7/site-packages/pyunifi/controller.py”, line 137, in _login
r = self.session.post(login_url, json=params)
File “/usr/local/lib/python3.7/site-packages/requests/sessions.py”, line 581, in post
return self.request(‘POST’, url, data=data, json=json, **kwargs)
File “/usr/local/lib/python3.7/site-packages/requests/sessions.py”, line 533, in request
resp = self.send(prep, **send_kwargs)
File “/usr/local/lib/python3.7/site-packages/requests/sessions.py”, line 646, in send
r = adapter.send(request, **kwargs)
File “/usr/local/lib/python3.7/site-packages/requests/adapters.py”, line 514, in send
raise SSLError(e, request=request)
requests.exceptions.SSLError: HTTPSConnectionPool(host=‘192.168.1.101’, port=8443): Max retries exceeded with url: /api/login (Caused by SSLError(SSLError(“bad handshake: Error([(‘SSL routines’, ‘tls_process_server_certificate’, ‘certificate verify failed’)])”)))

configuration:

device_tracker:

  • platform: unifi
    host: 192.168.1.XXX
    username: ! secret unifi_username
    password: ! secret unifi_password
    verify_ssl: True
    site_id: default
    detection_time: 60
    track_new_devices: yes
    ssid_filter:
    • ‘XXXXXXXXX1’
    • ‘XXXXXXXXX2’

any idea why i’m getting this error ??? the integration worked in the past but not anymore.

please help

Error setting up platform legacy

Did you miss any breaking changes updates or have some old custom components? Since it should not mention that if all is ok :wink: just a thought. I have unifi working fine on my side have not changed much lately though.

can you share with me your unifi configuration ?

thank you

Try removing from config and setting up in Integrations

Configuration>>Integrations>>"+">>unifi controller

would the unifi device_tracker works if i do that ?

docs are unclear but YES. device tracking works when setup using intergrations

I just tried it and i couldn’t find the devices. like nothing in known_devices.yaml or anywhere in home assistant.

Integration path doesn’t support device tracker yet. Work is ongoing to make it work

so i’m back to zero !!!

verify_ssl: true
maybe set to false. Are you sure ssl is OK from HA? recently renew cert or other change?

also sorry.
just realized this was not working for me.
I dont use this so when I checked I thought I saw working. when I verified again…realized I need to setup myself :smile:

I figured it out. you can not have special characters in the username & password field (you can not use secret.yaml ).

pretty sure i have weird characters in my passwords (maybe not unifi) but i also see a space in between the ! secret , don’t know if that matters.