NUKI Hub firmware for the ESP32

The fingerprint part of the API is not (yet?) documented. The API does support expiration and so on, but it’s not implemented in NUKI Hub … for two reasons. First, it’s not that easy to map this into MQTT, and second you can control this actually from your smart home solution. Just delete the code whenever you want it to be expired, no need to set expiry via NUKI Hub.

thanks for your reply!
You can delete codes from the normal smartlock apps as well and still the companies implement an expiration feature. I also think it’s a better idea to setup e. g. a code for neighbors when being on holiday and directly set an expiration on it so you don’t forget do delete it afterwards. Or just think about rental apartments/airbnb. Furthermore, the possibility to just use a code once is helpful as well.

I take it, if an expiration is not possible I cannot set a specific time frame as well? For example only Mondays between 8-10am for housekeeping?

I’m not saying it’s not possible. It’s there in the bluetooth API, just not implemented in NUK Hub.

The difference between setting it via the smartphone app vs. HA is that you can automate it with HA (or at least I assume so, I use iobroker), while you have to manually delete codes using the smartphone app. So you can tell HA to add the code every Monday to Friday at 8 am and delete it at 10 am, no manual interaction necessary.

Hm, I have not thought about it that way. Thanks :slight_smile:

Thanks a lot for this project, it is really amazing.

First time playing with a esp32 and in 10 minutes my nuki hub was working.

Sometimes when I open or close the door with HA takes a few second to show the updated state in HA, is it normal this delay?

It is a Nuki v4 (no pro) and I used a ESP32 ESP-WROOM-32, wifi signal is very good (-40dbm) and BT around -65dbm (1 m).

Thanks!!

Yes, the delay is normal.

1 Like

Since some people liked the solution on github for the presence sensor, i post this again on the “right” forum. To use nuki hub for presence, just add this as an mqtt sensor:

mqtt:
  sensor:
    - name: "nuki_presence_sensor"
      state_topic: "nuki/presence/devices"
      value_template: "{{ 'home' if 'YOUR-iBEACON-ID' in value else 'not_home' }}"
      unique_id: "nuki/presence/devices_uid"

Then you have a sensor if your iBeacon ID is recognized by NukiHUB, home if recognized and not_home if you are away.

For having a sensor for the rssi, just use:

mqtt:
  sensor:
    - name: "nuki_esp32_lock_rssi"
      state_topic: "nuki/lock/rssi"
      value_template: "{{ value }}"
      unique_id: nuki_esp32_nuki_lock_rssi_unique_id

Maybe it helps the one or other

Sorry I wasn’t clear on GitHub, I meant the rssi for the beacon not the lock :slight_smile:

I’ve been using the above to open the lock since yesterday and it opens well before I reach the door, definitely better than nuki’s auto unlock.

With a bit of automation I switch on the ble transmitter on the ha app as I enter the home zone and off after an unlock. Great stuff!

Ahh, ok. This is not just so easy, beside i am not a templating expert.
Maybe some of the really advanced users here have an idea for us.
Nuki gives us a text string like this:

08:b6:xx:xx:xx:e6;presence_az_e-7007e4;-81
4b:75:18:xx:xx:xx;Galaxy Watch4 (FKXF);-82
54:d2:xx:xx:xx:ad;Nuki_1C4705AD;-56

I would think the most easy way would be, ha converts this to json and then we would search the right name and pick the value from this data set, but i don’t know how this is done exactly in a template.
Maybe @123 oder @Didgeridrew have an idea when reading this?

FAQ Guideline 16 - Should I tag people?

Oh my bad, i was not aware of that rule. Sorry that i tagged you, but i have read so many threads where both you made advanced templates, so i thought you could help us here.
Again sorry that i made some circumstances for you and didgeridrew.

Hello guys, thanks for this amazing project! I’m currently facing the following behavior:
if I use the function lock’n’go, the state of the lock in Homeassistant stays “open”, while the Nuki is locked, so the state is not synchronized. What I’m doing wrong? Thanks!

{% set entry_list = 
'08:b6:xx:xx:xx:e6;presence_az_e-7007e4;-81
4b:75:18:xx:xx:xx;Galaxy Watch4 (FKXF);-82
54:d2:xx:xx:xx:ad;Nuki_1C4705AD;-56' %}

{% set pos = entry_list.find('Galaxy Watch4') %}
{% set pos2 = entry_list[pos:].find('\n') %}

{{ entry_list[pos:pos+pos2].split(';')[1] }}

I’m not sure this is the most efficient way of extracting it but hopefully this helps as a starter

1 Like

I don’t know also, but it is a way to extract and it works, many thanks. It’s far beyond my knowledge, but in a quiet minute i will try to understand the logic.
Since it wasn’t for me, @xaris33 here is the mqtt sensor for the rssi of your beacon:

mqtt:
  sensor:
    - name: "nuki_esp32_presence_rssi"
      state_topic: "nuki/presence/devices"
      value_template: >
        {% set nuki_list = value %}
        {% set pos = nuki_list.find('YOUR-iBEACON-ID') %}
        {% set pos2 = nuki_list[pos:].find('\n') %}
        {{ nuki_list[pos:pos+pos2].split(';')[1] }}
      unique_id: nuki_esp32_nuki_presence_rssi_unique_id

All credits goes to Josh for this wonderful solution!!!

2 Likes

Hi,
I am trying to get a nukihub running here but the image flash constantly fails at exact 63%: with error “serial port is not ready. close any other application using it and try again”

  • already tried various cables
  • already tried other ESP32 (same type, which already worked as bluetooth proxy in home assistant
  • shall i try different type of ESP32 ? (C maybe??)

any other hint to get this done ?
thanx in advance

ok … interesting

  • just tried it with webflash on a raspi5
  • and it suceeded !
  • never trust a windows machine
    but still I am curios what the problem is - as I saw that also on the raspi at exact 63% it kind of was stuck shortly and then immediatly switched to 100% and installation complete
    very strange … looks like some final steps in the flash process which fail on the windows machine => will try another windows machine to check whether its an instance problem of that one windows setup
    will keep you posted
    cheerz

Hello,

The NUKIHUB works great, thank you very much.

Does anyone have any tips for me on how to write an automation that flashes an LED every time the NUKI latch is unlocked. Even if the door is opened with Autounlock via the Nuki APP.

Thank you
Torsten

I installed Nuki Hub fresh and it works very well :slight_smile: thx a lot.

I have used the MQTT auto discovery.
image

I have activated the unlatch in Home Assistant and I can unlatch and receive the log in home assistant.
image
However, If I open the door with keypad no message appears.
I only see messages if door is locked or unlocked, no unlatch.
image

Is there a chance to get this message?

From GitHub:

MQTT Interface

Lock

  • lock/state: Reports the current lock state as a string. Possible values are: uncalibrated, locked, unlocked, unlatched, unlockedLnga, unlatching, bootRun, motorBlocked

hi,
next question from my side is how to pair Nuki opener with nukihub:

  • I checked the “opener enabled” checkbox in nukihub admin gui
  • I started the opener setup in Nuki app and came to the subprocess where it says to press opener button for 10 seconds to put opener in pairing mode with bridge (which I assume is surrogates by the nukihub esp32)
  • I tried to reboot the nukihub, as this also worked to pair it with Nuki lock
  • BUT nothing happens
  • and nukihub web gui still shows “opener paired” as disabled

am I missing something ? or is in this case the nukihub not meant to act as a bridge …

thanx

You might need to try several times (and/or move the ESP closer), the opener’s BLE signal is weaker than the lock’s in my experience.