core: Nuki Lock stopped working - Timeout
The problem
Hello,
the nuki integration just stopped working for me. In Addition to the official NUKI integration, i use a custom REST API command to get the state of the door (opend /closed). Thats still working. Even calling the Nuki API by browser gives a “valid” response. So there shouldnt be any problem with the nuki bridge in general.
Environment
Currently Running HASS.IO on a Rapsberry PI with 4GB.
Supervisor Version: 247 HassOS 4.13 Home Assistant 0.116.2 - but it did not work on 0.115 either.
Problem-relevant configuration.yaml
#Nuki SmartLock
lock:
- platform: nuki
host: MYIP
token: MYTOKEN`
Traceback/Error logs
`Logger: homeassistant.components.lock Source: /usr/local/lib/python3.8/asyncio/events.py:81 Integration: Schloss (documentation, issues) First occurred: 11. Oktober 2020, 13:55:18 (1 occurrences) Last logged: 11. Oktober 2020, 13:55:18
Setup of lock platform nuki is taking over 10 seconds`
`Logger: homeassistant.components.lock
Source: components/nuki/lock.py:80
Integration: Schloss (documentation, issues)
First occurred: 11. Oktober 2020, 13:55:30 (1 occurrences)
Last logged: 11. Oktober 2020, 13:55:30
Error while setting up nuki platform for lock
Traceback (most recent call last):
File "/usr/local/lib/python3.8/site-packages/urllib3/connectionpool.py", line 426, in _make_request
six.raise_from(e, None)
File "<string>", line 3, in raise_from
File "/usr/local/lib/python3.8/site-packages/urllib3/connectionpool.py", line 421, in _make_request
httplib_response = conn.getresponse()
File "/usr/local/lib/python3.8/http/client.py", line 1347, in getresponse
response.begin()
File "/usr/local/lib/python3.8/http/client.py", line 307, in begin
version, status, reason = self._read_status()
File "/usr/local/lib/python3.8/http/client.py", line 268, in _read_status
line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")
File "/usr/local/lib/python3.8/socket.py", line 669, in readinto
return self._sock.recv_into(b)
socket.timeout: timed out
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/lib/python3.8/site-packages/requests/adapters.py", line 439, in send
resp = conn.urlopen(
File "/usr/local/lib/python3.8/site-packages/urllib3/connectionpool.py", line 726, in urlopen
retries = retries.increment(
File "/usr/local/lib/python3.8/site-packages/urllib3/util/retry.py", line 403, in increment
raise six.reraise(type(error), error, _stacktrace)
File "/usr/local/lib/python3.8/site-packages/urllib3/packages/six.py", line 735, in reraise
raise value
File "/usr/local/lib/python3.8/site-packages/urllib3/connectionpool.py", line 670, in urlopen
httplib_response = self._make_request(
File "/usr/local/lib/python3.8/site-packages/urllib3/connectionpool.py", line 428, in _make_request
self._raise_timeout(err=e, url=url, timeout_value=read_timeout)
File "/usr/local/lib/python3.8/site-packages/urllib3/connectionpool.py", line 335, in _raise_timeout
raise ReadTimeoutError(
urllib3.exceptions.ReadTimeoutError: HTTPConnectionPool(host='192.168.178.36', port=8080): Read timed out. (read timeout=20)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 193, in _async_setup_platform
await asyncio.shield(task)
File "/usr/local/lib/python3.8/concurrent/futures/thread.py", line 57, in run
result = self.fn(*self.args, **self.kwargs)
File "/usr/src/homeassistant/homeassistant/components/nuki/lock.py", line 80, in setup_platform
devices.extend([NukiOpenerEntity(opener) for opener in bridge.openers])
File "/usr/local/lib/python3.8/site-packages/pynuki/bridge.py", line 238, in openers
return self._get_devices(device_type=const.DEVICE_TYPE_OPENER)
File "/usr/local/lib/python3.8/site-packages/pynuki/bridge.py", line 199, in _get_devices
for l in self.list(device_type=device_type):
File "/usr/local/lib/python3.8/site-packages/pynuki/bridge.py", line 128, in list
data = self.__rq("list")
File "/usr/local/lib/python3.8/site-packages/pynuki/bridge.py", line 103, in __rq
result = requests.get(
File "/usr/local/lib/python3.8/site-packages/requests/api.py", line 76, in get
return request('get', url, params=params, **kwargs)
File "/usr/local/lib/python3.8/site-packages/requests/api.py", line 61, in request
return session.request(method=method, url=url, **kwargs)
File "/usr/local/lib/python3.8/site-packages/requests/sessions.py", line 530, in request
resp = self.send(prep, **send_kwargs)
File "/usr/local/lib/python3.8/site-packages/requests/sessions.py", line 643, in send
r = adapter.send(request, **kwargs)
File "/usr/local/lib/python3.8/site-packages/requests/adapters.py", line 529, in send
raise ReadTimeout(e, request=request)
requests.exceptions.ReadTimeout: HTTPConnectionPool(host='192.168.178.36', port=8080): Read timed out. (read timeout=20)`
Additional information
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 2
- Comments: 22
The issue is that the current integration polls the lock for the status while the Nuki Bridge seems very limited in resources. A lot of request receive a 503 error from the lock. A much better way to integrate Nuki with Home Assistant is to use the callback functionality of the lock itself. That makes polling obsolete, will result in faster updates, will drain the Nuki battery less and is more reliable. More information is described in this feature request: https://community.home-assistant.io/t/nuki-use-callbacks-instead-of-unreliable-polling/229064/5
NO, polling is not an option. Webhook not permit to process any info, only to call a script. https://developer.nuki.io/page/nuki-bridge-http-api-1-12/4/