kvj / hass_nuki_ng Goto Github PK
View Code? Open in Web Editor NEWBetter support for Nuki devices in the Home Assistant
License: MIT License
Better support for Nuki devices in the Home Assistant
License: MIT License
According the last release of Nuki Bridge HTTP API (V1.13.1), from 15/12/2021, there are new doorsensor state introduced with the new external door sensor :
ID | name |
---|---|
1 | deactivated |
2 | door closed |
3 | door opened |
4 | door state unknown |
5 | calibrating |
16 | uncalibrated |
240 | removed |
255 | unknown |
Hello,
thanks for the great Integration for the Nuki System.
Do u know, how to add, a Trigger in Homassistant for a doorbell? That i can automate some things, if the doorbell rings?
that will be great.
Greetings
Hi there,
I just figured that when using this extension the status of a nuki lock has a 20+ mins delay in being updated.
E.g. a door is locked, shows as unlocked for another 20mins before updating its' status.
I parallel-installed the official integration again to check and there it is almost real-time.
Right now I am using both integrations in parallel until Nuki NG found a solution to the bug. It's not nice but a way to handle things to avoid triggering on false devices states.
I’d say it is not really an issue but I wonder whether it might be possible to fetch the ringing of the door bell with the opener and use it as a trigger?
Hi,
I try to connect to a Callback function. But there aren't docs or explain why this is not working.
Would you please explain to me how to do this?
From HA (2021.11.5) with the last version of this custom_components, i've several errors :
Logger: custom_components.nuki_ng.nuki
Source: custom_components/nuki_ng/nuki.py:40
Integration: Nuki Lock (documentation, issues)
First occurred: 22 novembre 2021 à 06:22:34 (197 occurrences)
Last logged: 09:39:43
Failed to get latest data: Http response: 503
Traceback (most recent call last):
File "/config/custom_components/nuki_ng/nuki.py", line 208, in _update
info = await self.api.bridge_info()
File "/config/custom_components/nuki_ng/nuki.py", line 66, in bridge_info
return await self.async_json(lambda r: r.get(self.bridge_url("/info")))
File "/config/custom_components/nuki_ng/nuki.py", line 40, in async_json
raise ConnectionError(f"Http response: {response.status_code}")
ConnectionError: Http response: 503
I've a physical bridge
In current beta versions of 2022.4 the sensor and binary_sensor domains are not working anymore.
I am getting the following error message:
Logger: homeassistant.components.binary_sensor
Source: helpers/entity_registry.py:529
Integration: Binärsensor (documentation, issues)
First occurred: 16:13:17 (2 occurrences)
Last logged: 16:13:17
Error adding entities for domain binary_sensor with platform nuki_ng
Error while setting up nuki_ng platform for binary_sensor
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 382, in async_add_entities
await asyncio.gather(*tasks)
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 510, in _async_add_entity
entry = entity_registry.async_get_or_create(
File "/usr/src/homeassistant/homeassistant/helpers/entity_registry.py", line 345, in async_get_or_create
return self.async_update_entity(
File "/usr/src/homeassistant/homeassistant/helpers/entity_registry.py", line 529, in async_update_entity
raise ValueError("entity_category must be a valid EntityCategory instance")
ValueError: entity_category must be a valid EntityCategory instance
On discord beta channel i found the following message regarding a similar error message:
That looks like custom components using the string instead of the enum for EntityCategory
The Service LOCK_N_GO isn´t implemented?
Nuki 3.0 without Bridge
How to start an automation as soon as the Opener detects a door bell ringing?
When I open or close the door, I can see that the state of my Nuki is either "locked" or "unlocked". However, according to https://developer.nuki.io/page/nuki-bridge-http-api-1-13/4/#heading--lock-states also other states like "unlatched" are support, but I don't see this in HA.
Could you please add this?
When i try add "Nuki lock" integration i receive this:
Error
Config flow could not be loaded
Logger: custom_components.nuki_ng.nuki
Source: custom_components/nuki_ng/nuki.py:72
Integration: Nuki Lock (documentation, issues)
First occurred: 12:44:29 (2 occurrences)
Last logged: 12:45:00
Failed to get latest data: ("Connection broken: InvalidChunkLength(got length b'HTTP/1.1 200 OK\r\n', 0 bytes read)", InvalidChunkLength(got length b'HTTP/1.1 200 OK\r\n', 0 bytes read))
Traceback (most recent call last):
File "/usr/local/lib/python3.9/site-packages/urllib3/response.py", line 700, in _update_chunk_length
self.chunk_left = int(line, 16)
ValueError: invalid literal for int() with base 16: b'HTTP/1.1 200 OK\r\n'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/lib/python3.9/site-packages/urllib3/response.py", line 441, in _error_catcher
yield
File "/usr/local/lib/python3.9/site-packages/urllib3/response.py", line 767, in read_chunked
self._update_chunk_length()
File "/usr/local/lib/python3.9/site-packages/urllib3/response.py", line 704, in _update_chunk_length
raise InvalidChunkLength(self, line)
urllib3.exceptions.InvalidChunkLength: InvalidChunkLength(got length b'HTTP/1.1 200 OK\r\n', 0 bytes read)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/lib/python3.9/site-packages/requests/models.py", line 760, in generate
for chunk in self.raw.stream(chunk_size, decode_content=True):
File "/usr/local/lib/python3.9/site-packages/urllib3/response.py", line 575, in stream
for line in self.read_chunked(amt, decode_content=decode_content):
File "/usr/local/lib/python3.9/site-packages/urllib3/response.py", line 796, in read_chunked
self._original_response.close()
File "/usr/local/lib/python3.9/contextlib.py", line 137, in __exit__
self.gen.throw(typ, value, traceback)
File "/usr/local/lib/python3.9/site-packages/urllib3/response.py", line 458, in _error_catcher
raise ProtocolError("Connection broken: %r" % e, e)
urllib3.exceptions.ProtocolError: ("Connection broken: InvalidChunkLength(got length b'HTTP/1.1 200 OK\\r\\n', 0 bytes read)", InvalidChunkLength(got length b'HTTP/1.1 200 OK\r\n', 0 bytes read))
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/config/custom_components/nuki_ng/nuki.py", line 344, in _update
bridge_info = await self.api.bridge_info()
File "/config/custom_components/nuki_ng/nuki.py", line 72, in bridge_info
return await self.async_json(lambda r: r.get(self.bridge_url("/info")))
File "/config/custom_components/nuki_ng/nuki.py", line 36, in async_json
response = await self.hass.async_add_executor_job(lambda: cb(requests))
File "/usr/local/lib/python3.9/concurrent/futures/thread.py", line 58, in run
result = self.fn(*self.args, **self.kwargs)
File "/config/custom_components/nuki_ng/nuki.py", line 36, in <lambda>
response = await self.hass.async_add_executor_job(lambda: cb(requests))
File "/config/custom_components/nuki_ng/nuki.py", line 72, in <lambda>
return await self.async_json(lambda r: r.get(self.bridge_url("/info")))
File "/usr/local/lib/python3.9/site-packages/requests/api.py", line 75, in get
return request('get', url, params=params, **kwargs)
File "/usr/local/lib/python3.9/site-packages/requests/api.py", line 61, in request
return session.request(method=method, url=url, **kwargs)
File "/usr/local/lib/python3.9/site-packages/requests/sessions.py", line 529, in request
resp = self.send(prep, **send_kwargs)
File "/usr/local/lib/python3.9/site-packages/requests/sessions.py", line 687, in send
r.content
File "/usr/local/lib/python3.9/site-packages/requests/models.py", line 838, in content
self._content = b''.join(self.iter_content(CONTENT_CHUNK_SIZE)) or b''
File "/usr/local/lib/python3.9/site-packages/requests/models.py", line 763, in generate
raise ChunkedEncodingError(e)
requests.exceptions.ChunkedEncodingError: ("Connection broken: InvalidChunkLength(got length b'HTTP/1.1 200 OK\\r\\n', 0 bytes read)", InvalidChunkLength(got length b'HTTP/1.1 200 OK\r\n', 0 bytes read))
I've created a blueprint for Home assistant that in combination with this integration and the The "Home Assistant Dahua Integration" (That can installed via HACS) to open the door from the Dahua DMSS app. This blueprint can be found via
Maybe you can add this to the wiki or the readme
Hi, I recently downloaded and installed Nuki Lock through HACS, restarted HA and then checked "Configuration > Integrations". It does not show up Nuki Lock integration, just the "Nuki" that I have already installed.
Is this integration still active for installing? If so, what could be wrong?
Thank you
Hi, is it possible to have this integrated via YAML instead of UI? If so, how?
Hello,
is there no option to unlatch?
This is by far the most important feature. Otherwise you are dependend from Nuki App to get it.
Hello, my airbnb guests get an automatic temporary code on the keypad. Is it possible to use this code to open another entity like a garage door? I would suggest by adding a zero or so to the original code.
Hey there, I'm quite happy with the integration, running a lot smoother then die official one.
But I'm struggling with opening the door when I'm outside:
With the HomeKit Integration from Nuki, the door gets unlatched when I tell Siri to open the door. In both cases, when the door is locked and also when the door is already unlocked. This behavior comes from configuring bar / knob in the Nuki App.
Within the Nuki App, I can select between unlock and open. This would be the best option in HomeKit too, but not possible because of HomeKit restrictions.
With your integration, it always just unlocks the door, it never unlatches.
So I think there is no best way for all use cases but while searching I found this thread on the Nuki Dev board: https://developer.nuki.io/t/homekit-unlock-command-opens-door/533/15
Within this thread someone recommends adopting the way of the homebridge plugin which allows using several customizable options. Perhaps it is possible to implement this function into your integration?
I think an implementation just like the one in homebridge-nuki plugin would be perfect; see: >https://github.com/lukasroegner/homebridge-nuki 31
unlatchFromLockedToUnlocked : If set to true, the door is unlatched when you switch from “locked” to “unlocked” in the Home app. If set to false, the door is just unlocked when you switch from “locked” to “unlocked” in the Home app. (only for SmartLock)
unlatchFromUnlockedToUnlocked : If set to true, the door is unlatched when you switch from “unlocked” to “unlocked” [1] in the Home app (this move is valid and works in the Home app, just hold down the switch, swipe it to “locked” and then “unlocked” without releasing your finger - do not release the finger until you reached the “unlocked” position again). If set to false, nothing is done when you switch from “unlocked” to “unlocked” in the Home app. [2] (only for SmartLock)
unlatchLock : If set to true, a second lock switch is exposed for unlatching the smart lock. (only for SmartLock)
[1] Also works with Siri, you can ask to unlock devices that are already unlocked.
[2] If you use this mode of operation, the separate unlatchLock is not really necessary. Use unlatchFromLockedToUnlocked: true , unlatchFromUnlockedToUnlocked: true and unlatchLock: false to mimic the HomeKit behavior of the lock.
best regards,
Lars
Phuturist found a workaround te see who's initiated a change in lockstate via the WebAPI (and setup automations with that info).
Is it possible to integrate this in the integration?
https://developer.nuki.io/t/add-user-to-bridge-http-api-notifications/151/35
Hi,
First of all let me say that I'm really thankfull about the hard work that you are doing !
I successfully installed the nuki_ng integration using the web api, and only the web api. For some reason, while I try to enter the bridge api (with or without the web api), the integration freezes and I've never accomplished to get the local bridge api working.
Why is this important ? Because I've got no thrustworthy states of my door sensor. I think that the web api is 'too slow' to handle open and closed states of my door.
Could you please help ? A lot of automations (with regards to front-door lightning etc) are depending on my door state of nuki.
I'm using nuki 2.0, and bridge + lock are up to date with latest firmware
Thanks in advance !
Kr,
Bart
I have the keypad, and when I tried to add this function the last time its worked but I don't know how to create a hacs component, so I stop to working on this
Please add door sensor battery state and %
https://nuki.io/en/door-sensor/
I have one, and working ok with this integration, but missing batterry state of this device
Hi,
my understanding was that the mentioned callback should update the sensors states (e.g. door state
sensor) immediately after the door is open/closed.
Unfortunately, even though the callback is listed in callbacks and the state is updated via polling (e.g. if I keep the door open for >30 secs - the default polling interval - the door state sensor is changed), the update isn't immediate (which is what I would like to achieve).
Is there a way how to get "immediate" updates of sensors?
error:
Logger: homeassistant.setup
Source: setup.py:162
First occurred: 22:10:45 (1 occurrences)
Last logged: 22:10:45
Setup failed for custom integration nuki_ng: Unable to import component: No module named 'custom_components.nuki_ng.constants'
Hi,
I have a Nuki Lock v3, but no other Nuki sensors.
Apparently, it delivers a DoorSensorState of 0, resulting in an exception in this integration.
It also makes the lock entity not work correctly (i.e. never updates).
Adding the DoorSensorState UNAVAILABLE = 0 to states.py solves all issues.
Could this be added for the next version?
class DoorSensorStates(BaseStates):
UNAVAILABLE = 0
...
Don´t know for how long but I receive the below message in my HA Log. Integration works fine but I like to have clean log files if possible. Any idea what this can be?
Using Nuki NG Custom Component latest Version and latest HA Version 2021.12.1 but this error appears already before updating.
Thx for helping if possible.
Dieser Fehler wurde von einer benutzerdefinierten Integration verursacht
Logger: custom_components.nuki_ng.nuki
Source: custom_components/nuki_ng/nuki.py:40
Integration: Nuki Lock (documentation, issues)
First occurred: 08:23:55 (19 occurrences)
Last logged: 08:32:56
Error while fetching auth:
Traceback (most recent call last):
File "/config/custom_components/nuki_ng/nuki.py", line 284, in _update
item["web_auth"] = await self.api.web_list_all_auths(dev_id)
File "/config/custom_components/nuki_ng/nuki.py", line 155, in web_list_all_auths
response = await self.web_async_json(
File "/config/custom_components/nuki_ng/nuki.py", line 143, in web_async_json
return await self.async_json(lambda r: cb(r, {
File "/config/custom_components/nuki_ng/nuki.py", line 40, in async_json
raise ConnectionError(f"Http response: {response.status_code}")
ConnectionError: Http response: 401
I can add both of my locks fine but they get unavailable after a couple of seconds. I still can lock/unlock via web API though.
Got invalid repository when trying to add it to HACS
As far as I understand, the integration registers a callback URL in the bridge and processes the callbacks. Shouldn't that classify the integration as local_push
instead of local_polling
as it is stated in the manifest right now?
Hi There anyone know why my automation , that is really simple , just to close the lock , fails sometimes with 503 ??
Error executing script. Unexpected error for call_service at pos 8: Http response: 503
While executing automation automation.abrir_portas
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 372, in _async_step
await getattr(self, handler)()
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 575, in _async_call_service_step
await service_task
File "/usr/src/homeassistant/homeassistant/core.py", line 1630, in async_call
task.result()
File "/usr/src/homeassistant/homeassistant/core.py", line 1667, 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 self.hass.helpers.service.entity_service_call(
File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 668, in entity_service_call
future.result() # pop exception if have
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 927, in async_request_call
await coro
File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 705, in _handle_entity_call
await result
File "/config/custom_components/nuki_ng/lock.py", line 57, in async_unlock
await self.coordinator.action(self.device_id, "unlock")
File "/config/custom_components/nuki_ng/nuki.py", line 326, in action
result = await self.api.bridge_lock_action(dev_id, action, device_type)
File "/config/custom_components/nuki_ng/nuki.py", line 87, in bridge_lock_action
return await self.async_json(
File "/config/custom_components/nuki_ng/nuki.py", line 41, in async_json
raise ConnectionError(f"Http response: {response.status_code}")
ConnectionError: Http response: 503
I know that Nuki supports providing access to others to open the lock, but i'm curious if there is a way to know who last opened the door or who or what device actually opened the door.
It would be nice to be able to configure an external door sensor (like aqara) instead of the nuki door sensor and combine this with the lock state to calculate the overall door state.
I had a door sensor before I bought the nuki so I don't want to buy a nuki door sensor.
Hi,
when I try the example from the Readme:
type: button
entity: lock.nuki_front_door_lock
tap_action:
action: call-service
service: lock.open
service_data: {}
target:
entity_id: lock.nuki_front_door_lock
name: Nuki
(with my entity_id of the lock of course), it doesn't unlatch - it only "opens" (the lock shows white LED - so it gets the signal, but doesn't unlatch) on "Unlock" action (long press on the button in Lovelace UI and clicking "unlock"). I can't make it unlatch actually.
Currently, the integration uses the original Nuki logo as logo and icon:
https://github.com/home-assistant/brands/tree/master/custom_integrations/nuki_ng
It is difficult to see this in dark themes:
HA allows to provide images optimized for dark background:
https://github.com/home-assistant/brands#image-specification
I propose to find/design and add these.
Currently, when the web token changes, it is not possible to update the integration. You need to delete it and re-add it with the new token. It would be great if there was an option to re-configure the active integration.
Hi -
Seeing as the integration already has access to both api's, is there a service exposed that can be used to call these? This would allow for options not currently supported directly to be automated.
Thanks!
Hi,
When I try to set up this integration, I got the error:
Failed to get list of devices from bridge: Failed to parse: http://192.168.178.22:9090:8080/list?token=XXXXXXXX
In fact I've set up my NUKI API on the port 9090 as the 8080 is already used for something else in the network.
Is it possible to have an input for the port to be used in the integration set up?
I am using special characters (@€&) in my API-Token. The integration does not encode them before sending them out, nor does it tell me I need to to that. This leads to error 401 when trying to setup the Integration. It took me a while to figure out, that I need to encode my Token using something like this:
https://www.urlencoder.org/
When pasting in the encoded token, everything works flawless.
Maybe it would be possible to add a checkbox to setup, which enabled URL-encoding for special chars (or just enable it by default)?
Hello and thank you for this awesome development.
I am trying to install it but getting the error below. Can you please advice?
Here is the log:
2021-12-16 13:20:51 ERROR (MainThread) [custom_components.nuki_ng.config_flow] Failed to get list of devices from web API: Http response: 401
Traceback (most recent call last):
File "/config/custom_components/nuki_ng/config_flow.py", line 37, in find_nuki_devices
response = await nuki.web_list()
File "/config/custom_components/nuki_ng/nuki.py", line 173, in web_list
resp = await self.web_async_json(
File "/config/custom_components/nuki_ng/nuki.py", line 143, in web_async_json
return await self.async_json(lambda r: cb(r, {
File "/config/custom_components/nuki_ng/nuki.py", line 40, in async_json
raise ConnectionError(f"Http response: {response.status_code}")
ConnectionError: Http response: 401
I think it would be a good idea to use the hashed token ( Documentation ) instead of the plain version to protect the token a little bit better.
This seems to be only possible in the hardware bridge, so maybe this needs to be checked before using it if possible.
This line
timestamp = datetime.utcnow().isoformat()[:-7]+'Z'
rand_num = str(random.randint(0,65535))
hash_token = hashlib.sha256((f"{timestamp},{rand_num},{token}").encode()).hexdigest()
return f"{url}{path}?ts={timestamp}&rnr={rand_num}&hash={hash_token}{extra_str}"
but I'm just starting with python so I'm not quite sure about the right syntax. Also I am not 100 percent sure about the random number format where the documentation says "uint16". Maybe someone with more experience can create a pull request for that? :)
Hi,
I've just configured the integration and it looks like everything works as expected, but when checking the log I found several error messages:
2021-12-15 21:38:49 ERROR (MainThread) [custom_components.nuki_ng.nuki] Failed to update callback https://xxx.duckdns.org:xxxx/api/webhook/nuki_ng_bridge_hook_xxx Traceback (most recent call last): File "/config/custom_components/nuki_ng/nuki.py", line 268, in _update callbacks_list = await self.api.bridge_check_callback(self.bridge_hook) File "/config/custom_components/nuki_ng/nuki.py", line 129, in bridge_check_callback result = await self.async_json( File "/config/custom_components/nuki_ng/nuki.py", line 40, in async_json raise ConnectionError(f"Http response: {response.status_code}") ConnectionError: Http response: 400
Do you have any clue what should I check or where can be the issue? It looks like the webhook is created automatically by the integration os I don't know where and what to check.
Just for the record, I double-checked the bridge API token and it should be correct.
Thanks a lot.
Hi,
I'm using opener, lock and bridge. My bridge is not allowed to connect to the internet, but that throws some errors inside the integration and won't let it work properly. But it should be possible to only use the bridge-API and not the web-API, right? I am using no Web Api Token anyways.
Error in logs:
2022-04-14 04:47:38 ERROR (MainThread) [custom_components.nuki_ng.nuki] Failed to get latest data: Http response: 401 Traceback (most recent call last): File "/config/custom_components/nuki_ng/nuki.py", line 323, in _update bridge_info = await self.api.bridge_info() File "/config/custom_components/nuki_ng/nuki.py", line 72, in bridge_info return await self.async_json(lambda r: r.get(self.bridge_url("/info"))) File "/config/custom_components/nuki_ng/nuki.py", line 38, in async_json raise ConnectionError(f"Http response: {response.status_code}") ConnectionError: Http response: 401 2022-04-14 04:47:38 ERROR (MainThread) [custom_components.nuki_ng.nuki] Error fetching nuki_ng data: 2022-04-14 04:48:08 ERROR (MainThread) [custom_components.nuki_ng.nuki] Failed to update callback http://192.168.2.2:8123/api/webhook/nuki_ng_bridge_hook_bc1927bcb5ec97f1db6e578549480df7
When allowing the bridge to connect to the internet it works like it should, so it's definetly regarding internet-access of the bridge.
2022-04-06 20:31:25 WARNING (MainThread) [homeassistant.config_entries] Config entry '2090791A' for nuki integration not ready yet: ("Connection broken: InvalidChunkLength(got length b'HTTP/1.1 200 OK\r\n', 0 bytes read)", InvalidChunkLength(got length b'HTTP/1.1 200 OK\r\n', 0 bytes read)); Retrying in background
Hi there, is this integration intended to work with the Nuki Android Bridge app?
I'm getting Error communicating with Nuki bridge
when trying to add the New Nuki device.
I'm using the Android Bridge App, and have double checked the IP address and tried multiple different tokens.
I may get a hardware bridge in the future, but was hoping to cheap out to test things out with an old android device in the meantime.
Thank you!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.