kvj / hass_nuki_ng

Better support for Nuki devices in the Home Assistant
MIT License
185 stars 36 forks source link

Error communicating with Nuki bridge #142

Open 6iorgio opened 1 year ago

6iorgio commented 1 year ago

Hi,

I have a problem when trying to add Nuki Lock integration. I get this message:

image

The IP address of the bridge is correct and the bridge itself is fully functional. The Bridge API Token is also correct.

I'm running HA 2023.2.5 on Raspberry Pi 4

image

Here below the log. Thank you for help:

This error originated from a custom integration.

Logger: custom_components.nuki_ng.config_flow Source: custom_components/nuki_ng/nuki.py:78 Integration: Nuki Lock (documentation, issues) First occurred: 16:08:20 (1 occurrences) Last logged: 16:08:20

Failed to get list of devices from bridge: HTTPConnectionPool(host='192.168.86.41', port=8080): Max retries exceeded with url: /info?token=#########(Caused by ConnectTimeoutError(<urllib3.connection.HTTPConnection object at 0x7f6d6a9270>, 'Connection to 192.168.86.41 timed out. (connect timeout=10)')) Traceback (most recent call last): File "/usr/local/lib/python3.10/site-packages/urllib3/connection.py", line 174, in _new_conn conn = connection.create_connection( File "/usr/local/lib/python3.10/site-packages/urllib3/util/connection.py", line 95, in create_connection raise err File "/usr/local/lib/python3.10/site-packages/urllib3/util/connection.py", line 85, in create_connection sock.connect(sa) TimeoutError: timed out

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/usr/local/lib/python3.10/site-packages/urllib3/connectionpool.py", line 703, in urlopen httplib_response = self._make_request( File "/usr/local/lib/python3.10/site-packages/urllib3/connectionpool.py", line 398, in _make_request conn.request(method, url, **httplib_request_kw) File "/usr/local/lib/python3.10/site-packages/urllib3/connection.py", line 239, in request super(HTTPConnection, self).request(method, url, body=body, headers=headers) File "/usr/local/lib/python3.10/http/client.py", line 1282, in request self._send_request(method, url, body, headers, encode_chunked) File "/usr/local/lib/python3.10/http/client.py", line 1328, in _send_request self.endheaders(body, encode_chunked=encode_chunked) File "/usr/local/lib/python3.10/http/client.py", line 1277, in endheaders self._send_output(message_body, encode_chunked=encode_chunked) File "/usr/local/lib/python3.10/http/client.py", line 1037, in _send_output self.send(msg) File "/usr/local/lib/python3.10/http/client.py", line 975, in send self.connect() File "/usr/local/lib/python3.10/site-packages/urllib3/connection.py", line 205, in connect conn = self._new_conn() File "/usr/local/lib/python3.10/site-packages/urllib3/connection.py", line 179, in _new_conn raise ConnectTimeoutError( urllib3.exceptions.ConnectTimeoutError: (<urllib3.connection.HTTPConnection object at 0x7f6d6a9270>, 'Connection to 192.168.86.41 timed out. (connect timeout=10)')

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/usr/local/lib/python3.10/site-packages/requests/adapters.py", line 489, in send resp = conn.urlopen( File "/usr/local/lib/python3.10/site-packages/urllib3/connectionpool.py", line 787, in urlopen retries = retries.increment( File "/usr/local/lib/python3.10/site-packages/urllib3/util/retry.py", line 592, in increment raise MaxRetryError(_pool, url, error or ResponseError(cause)) urllib3.exceptions.MaxRetryError: HTTPConnectionPool(host='192.168.86.41', port=8080): Max retries exceeded with url: /info?token=#########(Caused by ConnectTimeoutError(<urllib3.connection.HTTPConnection object at 0x7f6d6a9270>, 'Connection to 192.168.86.41 timed out. (connect timeout=10)'))

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/config/custom_components/nuki_ng/config_flow.py", line 34, in find_nuki_devices info = await nuki.bridge_info() File "/config/custom_components/nuki_ng/nuki.py", line 78, in bridge_info return await self.async_json(lambda r: r.get(self.bridge_url("/info"), timeout=BRIDGE_TIMEOUT)) File "/config/custom_components/nuki_ng/nuki.py", line 37, in async_json response = await self.hass.async_add_executor_job(lambda: cb(requests)) File "/usr/local/lib/python3.10/concurrent/futures/thread.py", line 58, in run result = self.fn(*self.args, self.kwargs) File "/config/custom_components/nuki_ng/nuki.py", line 37, in response = await self.hass.async_add_executor_job(lambda: cb(requests)) File "/config/custom_components/nuki_ng/nuki.py", line 78, in return await self.async_json(lambda r: r.get(self.bridge_url("/info"), timeout=BRIDGE_TIMEOUT)) File "/usr/local/lib/python3.10/site-packages/requests/api.py", line 73, in get return request("get", url, params=params, kwargs) File "/usr/local/lib/python3.10/site-packages/requests/api.py", line 59, in request return session.request(method=method, url=url, kwargs) File "/usr/local/lib/python3.10/site-packages/requests/sessions.py", line 587, in request resp = self.send(prep, send_kwargs) File "/usr/local/lib/python3.10/site-packages/requests/sessions.py", line 701, in send r = adapter.send(request, kwargs) File "/usr/local/lib/python3.10/site-packages/requests/adapters.py", line 553, in send raise ConnectTimeout(e, request=request) requests.exceptions.ConnectTimeout: HTTPConnectionPool(host='192.168.86.41', port=8080): Max retries exceeded with url: /info?token=#########(Caused by ConnectTimeoutError(<urllib3.connection.HTTPConnection object at 0x7f6d6a9270>, 'Connection to 192.168.86.41 timed out. (connect timeout=10)'))

gshlomi commented 1 year ago

Same here, ever since I've upgraded to 2023.3. I think it might be related to a change done with Python, upgraded to 3.11, but urllib3 still refers to 3.10

efolio commented 1 year ago

I had a similar issue. It just worked today…

6iorgio commented 1 year ago

Same here, ever since I've upgraded to 2023.3. I think it might be related to a change done with Python, upgraded to 3.11, but urllib3 still refers to 3.10

Hi gshlomi, do you still have the problem?

gshlomi commented 1 year ago

Same here, ever since I've upgraded to 2023.3. I think it might be related to a change done with Python, upgraded to 3.11, but urllib3 still refers to 3.10

Hi gshlomi, do you still have the problem?

No, my Nuki bridge just totally died, switched over to ESP32 emulation…

6iorgio commented 1 year ago

Same here, ever since I've upgraded to 2023.3. I think it might be related to a change done with Python, upgraded to 3.11, but urllib3 still refers to 3.10

Hi gshlomi, do you still have the problem?

No, my Nuki bridge just totally died, switched over to ESP32 emulation…

I'm not that expert. What's an ESP32 emulation and did you connect the Nuki lock to HA by it? Thank you.

gshlomi commented 1 year ago

Same here, ever since I've upgraded to 2023.3. I think it might be related to a change done with Python, upgraded to 3.11, but urllib3 still refers to 3.10

Hi gshlomi, do you still have the problem?

No, my Nuki bridge just totally died, switched over to ESP32 emulation…

I'm not that expert. What's an ESP32 emulation and did you connect the Nuki lock to HA by it? Thank you.

https://github.com/technyon/nuki_hub

konradwalsh commented 1 year ago

I had this communication error too and over the course of 5 mins I pressed the submit button every 20-30 seconds and then it connected one of the times

Just in case that helps anyone else

Alex73hub commented 1 year ago

Logger: homeassistant.config_entries Source: helpers/network.py:206 First occurred: 1 aprile 2023, 21:19:56 (1 occurrences) Last logged: 1 aprile 2023, 21:19:56

Error setting up entry Nuki for nuki_ng Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/config_entries.py", line 383, in async_setup result = await component.async_setup_entry(hass, self) File "/config/custom_components/nuki_ng/init.py", line 26, in async_setup_entry coordinator = NukiCoordinator(hass, entry, data) File "/config/custom_components/nuki_ng/nuki.py", line 345, in init url = config.get("hass_url", get_url(hass)) File "/usr/src/homeassistant/homeassistant/helpers/network.py", line 167, in get_url request_host = _get_request_host() File "/usr/src/homeassistant/homeassistant/helpers/network.py", line 206, in _get_request_host raise NoURLAvailableError homeassistant.helpers.network.NoURLAvailableError

platini76 commented 1 year ago

gshlomi

diy you manage to use nuki_ng with technyon esp32 emulation?

platini76 commented 1 year ago

Same here, ever since I've upgraded to 2023.3. I think it might be related to a change done with Python, upgraded to 3.11, but urllib3 still refers to 3.10

Hi gshlomi, do you still have the problem?

No, my Nuki bridge just totally died, switched over to ESP32 emulation…

I'm not that expert. What's an ESP32 emulation and did you connect the Nuki lock to HA by it? Thank you.

https://github.com/technyon/nuki_hub

how do you use nuki_hub and retrieve bridge api token??

Rain-ZG commented 1 year ago

i had the similar issue, but when checking logs in HA error was 401 unauthorized. In my token I had ? as part of the token, when I changed token to only numbers and characters it started to work

ruthem commented 1 year ago

I still have the same issue. Also I get 401 unauthorized error when trying to configure the integration. In my token there are only numbers and capital letters. Does anyone have further advises?

erd82 commented 1 year ago

I guess the solution is quite simple:

After the bridge is restarted, you should try to configure the integration with your new token in Home Assistant.

Please give me a thumbs up, if the solution was helpful.

bpolaszek commented 1 year ago

Hi there, same here (using RaspiNukiBridge as addon):

Capture d’écran 2023-11-14 à 11 03 25

Log say:

Failed to get list of devices from bridge: HTTPConnectionPool(host='http', port=80): Max retries exceeded with url: //172.30.33.2:8080/info?token=e56f353daa61095e6fd1dacc4b0c8dcf48a5663b04f741f8880fcc05a472b729 (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0xde89e510>: Failed to establish a new connection: [Errno -5] Name has no usable address'))

But when I get into hassio's container and I curl the URL myself, it works.

Capture d’écran 2023-11-14 à 11 05 56

Any ideas? When looking at the log above, it looks like the scheme is missing, although I provided it. I don't know if it's just for log formatting purposes or if the underlying python script actually removes the scheme, which would explain why it doesn't work...

raaaf commented 1 year ago

I have the same problem as @bpolaszek. The only difference is that I'm using the regular bridge. Any ideas? :)

inc-ali commented 1 year ago

I guess the solution is quite simple:

  • It might be that your mobile app and the bridge are still in maintenance mode and / or the (recently changed) API token is not finally stored on the bridge itself.
  • Solution: Please leave the maintenance mode on your Nuki bridge. The app will tell you that the bridge will be restarted.

After the bridge is restarted, you should try to configure the integration with your new token in Home Assistant.

Please give me a thumbs up, if the solution was helpful.

This was the solution for me (using the regular bridge). Once the bridge is configured and you exit the maintenance mode, the bridge will reboot. Afterwards it connects as expected.