hass_nuki_ng icon indicating copy to clipboard operation
hass_nuki_ng copied to clipboard

Lost connenction to web api after last update

Open PetrMa opened this issue 1 year ago • 33 comments

Hello,

I made an update from 0.3.9 to 0.3.10 today and after HA reboot I lost access to Web Api sensors. After downgrade back to 0.3.9 everything is OK. It is issue on my side or not?

Device: Nuki Smart Lock 3.0 Pro without bridge

thanks, Regards, Petr

PetrMa avatar Aug 28 '22 16:08 PetrMa

status is ok for me, but i have 404 error for lock/unlock actions

forzewin avatar Aug 28 '22 16:08 forzewin

Same for me

deku-m avatar Aug 28 '22 18:08 deku-m

Also a 404.

rdehuyss avatar Aug 28 '22 20:08 rdehuyss

raise ConnectionError(f"Http response for {response.request.url}: {response.status_code} {response.reason}") ConnectionError: Http response for https://api.nuki.io/smartlock/XXXXXXXXX/action: 404 Not Found

Inferi0r avatar Aug 28 '22 21:08 Inferi0r

Same problem here with 0.3.9 and 0.3.10, i revert to 0.3.8 and everything is working again

xtimmy86x avatar Aug 29 '22 07:08 xtimmy86x

The discussion is in #76 There's a regression detected, but the fix isn't known yet

kvj avatar Aug 29 '22 09:08 kvj

Hi, have the same here with thaat log message. I noticed that the integration is using wrong lock ID... even after removing and configuring a new, it is still the wrong lock ID. I hope this helps...

chu11u avatar Aug 30 '22 12:08 chu11u

There should be a new device which is called Nuki WebApi. The device contains a entity for every user. Including a user for webapi. Make sure that it is on.

Se7enair avatar Aug 30 '22 15:08 Se7enair

device is there but switches are greyed out

forzewin avatar Aug 30 '22 15:08 forzewin

Reverted to 0.3.8, still same issue :/

I deleted/added the integration.

Generated new API token with all authorizations and i still have the 404 error..

I dont understand..

forzewin avatar Aug 31 '22 10:08 forzewin

I need more details to help you resolving the issue.

@chu11u when you say "wrong lock ID", what is "wrong" value and what should be the correct one?

@forzewin which API call gives your 404 and what is the ID of your device?

kvj avatar Aug 31 '22 10:08 kvj

I need more details to help you resolving the issue.

@chu11u when you say "wrong lock ID", what is "wrong" value and what should be the correct one? The part in the URL wuch hold the lockid is different than my own lockid. I ran those api calls my self to get my lockid and got a different number. Than I ran the same lock action call with the right lockid, and the device locked and unlock. So now I use the integration only for the state of the lock and using direct calls for lock/unlock untill the integration is fixed.

@forzewin which API call gives your 404 and what is the ID of your device? I got the 404 when I tried to lock or unlock. It is the action URL call. It showed briefly on the Lovelace bottom and also in the log file.

chu11u avatar Aug 31 '22 11:08 chu11u

Sorry for the formatting, i am on my phone.

here the full error when trying to unlock the lock :

Échec d'appel du service "lock/unlock". Http response for https://api.nuki.io/smartlock/292XXXX48996/action: 404 Not Found

full log :

Logger: homeassistant.components.websocket_api.http.connection
Source: custom_components/nuki_ng/nuki.py:39
Integration: Home Assistant WebSocket API (documentation, issues)
First occurred: 11:54:11 (17 occurrences)
Last logged: 13:57:27

[140127195676832] Http response for https://api.nuki.io/smartlock/292XXXXX996/action: 404 Not Found
[140127194185936] Http response for https://api.nuki.io/smartlock/292XXXXX48996/action: 404 Not Found
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 199, in handle_call_service
    await hass.services.async_call(
  File "/usr/src/homeassistant/homeassistant/core.py", line 1713, in async_call
    task.result()
  File "/usr/src/homeassistant/homeassistant/core.py", line 1750, in _execute_service
    await cast(Callable[[ServiceCall], Awaitable[None]], handler.job.target)(
  File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 204, in handle_service
    await service.entity_service_call(
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 676, in entity_service_call
    future.result()  # pop exception if have
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 930, in async_request_call
    await coro
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 713, in _handle_entity_call
    await result
  File "/config/custom_components/nuki_ng/lock.py", line 56, in async_unlock
    await self.coordinator.action(self.device_id, "unlock")
  File "/config/custom_components/nuki_ng/nuki.py", line 466, in action
    await self.api.web_lock_action(self.web_id(dev_id), action)
  File "/config/custom_components/nuki_ng/nuki.py", line 126, in web_lock_action
    await self.web_async_json(
  File "/config/custom_components/nuki_ng/nuki.py", line 184, in web_async_json
    return await self.async_json(
  File "/config/custom_components/nuki_ng/nuki.py", line 39, in async_json
    raise ConnectionError(f"Http response for {response.request.url}: {response.status_code} {response.reason}")
ConnectionError: Http response for https://api.nuki.io/smartlock/2928XXXX48996/action: 404 Not Found

the id of my lock in nuki app looks like this

ID Smart Lock: 30XXXF64

I lightly modified id's to anonymise them

forzewin avatar Aug 31 '22 12:08 forzewin

I need more details to help you resolving the issue. @forzewin which API call gives your 404 and what is the ID of your device? I got the 404 when I tried to lock or unlock. It is the action URL call. It showed briefly on the Lovelace bottom and also in the log file.

My API call is: [140186346527696] Http response for https://api.nuki.io/smartlock/292805081XXX/action: 404 Not Found

My device ID is: ID2C8AFXXX

I have a Smart Lock Pro 3.0 (Firmware: 197381 which is 3.3.5) without Bridge. I do have a bunch of openers laying around.

Inferi0r avatar Aug 31 '22 12:08 Inferi0r

Thanks for the input. I've pushed a fix to the main branch, could you please test the it? (Install main version via HACS)

kvj avatar Aug 31 '22 12:08 kvj

Just did it and i can confirm that the fix works like a charm.

Everything is back and working again

Thanks a lot @kvj

forzewin avatar Aug 31 '22 12:08 forzewin

Thanks for the input. I've pushed a fix to the main branch, could you please test the it? (Install main version via HACS)

Yes, main version is working for me too!

Inferi0r avatar Aug 31 '22 13:08 Inferi0r

Thanks for the input. I've pushed a fix to the main branch, could you please test the it? (Install main version via HACS)

Sorry for being novice... how do I do that? i looked at the integration and there is no update. how do I install it?

chu11u avatar Aug 31 '22 14:08 chu11u

how do I install it?

Go to HACS, click on the integration, select "Re-download" from the popup menu and pick "main" from the list of all versions available

kvj avatar Aug 31 '22 14:08 kvj

Thanks for the input. I've pushed a fix to the main branch, could you please test the it? (Install main version via HACS)

Sorry for being novice... how do I do that? i looked at the integration and there is no update. how do I install it?

Go to HACS > Integrations > Search for Nuki Lock and click on it > on the upper right, click on ... > Redownload > Select Main

forzewin avatar Aug 31 '22 14:08 forzewin

Thanks for the input. I've pushed a fix to the main branch, could you please test the it? (Install main version via HACS)

Sorry for being novice... how do I do that? i looked at the integration and there is no update. how do I install it?

Go to HACS > Integrations > Search for Nuki Lock and click on it > on the upper right, click on ... > Redownload > Select Main Done. Do i need to re-install the integration also?

chu11u avatar Aug 31 '22 14:08 chu11u

You just need to restart HA after the redownload

forzewin avatar Aug 31 '22 15:08 forzewin

You just need to restart HA after the redownload

well... still get the 404 message: Http response for https://api.nuki.io/smartlock/292882605412/action: 404 Not Found

I have no problem leaving the lockid because it is wrong one...

Ill try to remove and configure the lock again

chu11u avatar Aug 31 '22 15:08 chu11u

Ok. I can confirm that main worked.

chu11u avatar Aug 31 '22 15:08 chu11u

is 0.3.10 the corrected version?

nope, I haven't pushed the updated release yet. That will be 0.3.11

kvj avatar Sep 01 '22 07:09 kvj

After a complete removal and reinstall of 'main' it worked for me as well. confirm.

Maximus48p avatar Sep 01 '22 10:09 Maximus48p

I can't confirm. Problem still exist.

Removal and reinstall did not work. Is equal which version i'll use: main or 0.3.10.

If a status is requested the bridge become a ping timeout for round about 2-3 Pings. This can be reproduced. I opened a ticket at Nuki, too.

LordShelmchen avatar Sep 04 '22 15:09 LordShelmchen

If a status is requested the bridge become a ping timeout for round about 2-3 Pings. This can be reproduced. I opened a ticket at Nuki, too.

In case the bridge receives too many requests, it reboots, it's a known issue due to the hw limitations of the bridge. It can process only 1 request at a time. Probably you're sending it requests not only from this integration but from the mobile app, the web app, etc.

The bridge has a log, check it and report it here, you should see the reboots. You can dump it via curl and the /log endpoint.

curl -H "Content-Type: application/json" 'http://bridge-ip:8080/log?token=bridgetoken'

alexdelprete avatar Sep 04 '22 22:09 alexdelprete

I can't confirm. Problem still exist.

Removal and reinstall did not work. Is equal which version i'll use: main or 0.3.10.

If a status is requested the bridge become a ping timeout for round about 2-3 Pings. This can be reproduced. I opened a ticket at Nuki, too.

Remove and install "main" version

chu11u avatar Sep 06 '22 18:09 chu11u

I had removed and install main, also tried to delete all files manually. Problem exists.

But a the nuki log, i can see the reboots. I have to wait for the answer from Nuki about this problem.

LordShelmchen avatar Sep 07 '22 13:09 LordShelmchen