home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
72.64k stars 30.41k forks source link

Nuki Lock stopped working - Timeout #41702

Closed tristanXme closed 3 years ago

tristanXme commented 4 years ago

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

probot-home-assistant[bot] commented 4 years ago

nuki documentation nuki source (message by IssueLinks)

mamoel666 commented 4 years ago

Looks like #41460

probot-home-assistant[bot] commented 4 years ago

Hey there @pschmitt, @pvizeli, mind taking a look at this issue as its been labeled with an integration (nuki) you are listed as a codeowner for? Thanks! (message by CodeOwnersMention)

tristanXme commented 4 years ago

Oh yes, sorry for that. Created a Issue for that longer ago but got the information to use the template (sorry for not using it as i'm new to github) but as i was on vacation I did not had time before to do so. Now somebody else already created a (similar) issue.

Old one of me: https://github.com/home-assistant/core/issues/41071

tristanXme commented 3 years ago

I just fully removed my custom REST API Calls, to make sure, that the error is not because the bridge is busy and does not answer to the nuki integration. But even after removing it complete and also deleting the binary sensors generated by my API Calls in the the "database", it still does not work - even after a full reboot of the host system.

Any Idea?

tristanXme commented 3 years ago

Maybe in general it would be better to change the integration to push from nuki instead of pulling. Nuki is supporting this right now.

mamoel666 commented 3 years ago

Same here. My bridge wifi does some sort of reboot as soon as HA tries to access the API. No problems if called via browser.

tristanXme commented 3 years ago

Tested a downgrade to 0.115 - it still does not get back to work... So it does not seem to be related to the current version.

mamoel666 commented 3 years ago

The problem occured the first time when I upgraded to 0.116. It worked flawlessly with all previous versions (I upgraded from 0.115.6). But I can confirm, that a downgrade doesn't fix the problem now and I have no explanation for it.

jghaanstra commented 3 years ago

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

tristanXme commented 3 years ago

Yes, but if it would be that error, it should work at least sometimes. But it does not work at anytime anymore.

Ciqsky commented 3 years ago

Oh yes, sorry for that. Created a Issue for that longer ago but got the information to use the template (sorry for not using it as i'm new to github) but as i was on vacation I did not had time before to do so. Now somebody else already created a (similar) issue.

Old one of me:

41071

Also for me. Same problem. Has anyone found a solution? Or temporarily a workaround?

tristanXme commented 3 years ago

No, sadly there is no workaround / fix currently that I know

Ciqsky commented 3 years ago

No, sadly there is no workaround / fix currently that I know

I'm searching if HA can process/receive callback. I have already created 2 restful method to call lock and unlock nuki inside HA but i can't receive any info about state. Nuki can register 3 IP address to send state info anytime there any changes on nuki. But HA must receive this info....

tristanXme commented 3 years ago

You can get the state also by pulling the rest API but sadly the pulling method is not that reliable. The Callbacks could be gathered by webhooks I think - but I never worked with those, so I'm not sure how to do it exactly.

Ciqsky commented 3 years ago

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/

mamoel666 commented 3 years ago

Even openHAB is using callbacks.

dvbit commented 3 years ago

Same over here. Switching to nodered node to manage it

Ciqsky commented 3 years ago

Same over here. Switching to nodered node to manage it

What does it mean? How did you manage to find Nuki's status from NodeRed?

lackylucky commented 3 years ago

I have the same problem after the update to Home Assistant 0.117

lackylucky commented 3 years ago

I have the same problem after the update to Home Assistant 0.117

Nuki Look Firmware 2.9.10 solved the problem for me

tristanXme commented 3 years ago

I have the same problem after the update to Home Assistant 0.117

Nuki Look Firmware 2.9.10 solved the problem for me

mine also came back to life!