NUKI Hub firmware for the ESP32

Hi,

I’m using an ESP32 mini as well, it’s all the same chip, so it shouldn’t matter.

If the network can’t be serviced, it would mean other tasks use up too much time … unlikely though. Can you get logs while this is happening? Maybe your ESP was disconnected at the time and in the process of reconnecting? If it’s fast enough the MQTT connection might not be dropped.

How close is your ESP to the router, is Wifi reception fine there? You could try a ESP CAM32 module, they come with an external Antenna. Just don’t connect the camera. Flashing is a bit trickier though, since they don’t have an USB-serial-converter, so you need an external one and connect it to the right PINs (and also power the ESP since they usually don’t provide enough power for flashing).

Actually, I think there are various different cores used in ESP32 SoCs (including some running at different clock speeds). I’ve been looking at different devkits (the CAM modules mostly got pretty bad reviews on Amazon), but those with U.FL connectors seem to be pretty hard to source at a reasonable price (the external antenna should get better BLE range as well).

WiFi is quite good at the current position, but I’m running a mesh network, so the ESP might randomly switch between two APs (not that it has any reason for this, but I can’t rule it out).

I’m using an ESP CAM32 for another project without any problems. It’s the cheapest option with an external Antenna I think, not sure about the bad reviews. If you get faulty one, just send it back.

1 Like

I can still reliably trigger the issue using the OTA update mechanism, regardless of wifi strength.

Here’s the result of a very basic request via telnet (not different from browser except I’m sending fewer headers):

$ telnet <hostename> 80
Trying <IP>...
Connected to <hostname>.
Escape character is '^]'.
GET / HTTP/1.1
HOST: <hostname>
Authorization: Basic <base64 encoded username:password>
HTTP/1.1 401 Unauthorized
Content-Type: text/html
WWW-Authenticate: Basic realm="Login Required"
Content-Length: 0
Connection: close

(But maybe we should take this to GitHub :slight_smile:)

Hey is there a way to get a notification after someone rings the door? (Nuki Opener)

I’d love to have such a notification myself, but unfortunately no the Opener doesn’t offer such functionality.

Just tumbled today about this thread and i like the idea of replacing the shitty bridge with an esp32 and open source software. For the first test it works fine, thank you for the good work.
Before i used the nuki_ng custom component with the bridge. But this one had a binary sensor for ringactions submitted by the opener which the bridge submitted via callbacks to home assistant (i used this to flash the lights in the rooms if somebody rings and it works).
So as i think in my simple mind, the esp32 communicates the same way (bt) with the opener as the bridge, how did it work with the custom component?

Interesting. I never had a bridge, since well I wrote the firmware for the ESP32. I found nothing in the API about reporting a ring action (see link below).

I could ask in the NUKI developer forum, they are actually quite helpful with such questions.

https://developer.nuki.io/page/nuki-opener-api-1/7/

1 Like

Isnt this what we need? Or does this only Work with the official Bridge?

Not necessarily. The bridge communicates with the Lock/Opener via Bluetooth, so does the NUKI Hub firmware. However they do it, they didn’t document it.

@technyon Awesome work! Thanks for the project, it works perfekt for me!

Version 5.6 fixes a Home Assistant specific issue, all relevant lock states are now correctly mapped to locked and unlocked.

Awesome project but I am having some issues with home assistant! I tried connecting it to HomeAssistant via MQTT and entered the details. The NukiHub Webinterface also says “connected” for MQTT. In HA, I have also seen it apparently connecting but it doesn’t show up as a new device.

For other MQTT I have also never needed an SSL certificate or similar, so that shouldn’t be an issue. Any ideas whether there anything additional to be done for autodiscovery to work?

edit: I also tried setting a discovery topic as per the examples here MQTT Discovery - Home Assistant ( i tried homeassistant/lock/nuki/config without success)

edit2: in fact, when I set any discovery topic, it seems to crash my home assistants mosquitto broker addon.

The discovery topic should be homeassistant (unless you configured your HA different from the default).

Thanks.

This causes the device to be discovered in home assistant but as long as I have the discovery topic set in the nukihub webinterface, my mosquitto broker addon keeps crashing (which is odd. Also the logs show nothing).

Edit: nevermind, after about 15 restarts (for some reason) it seems to be stable now.

I’d still suggest, at least mentioning in the docs that the discovery topic is homeassistant by default and needs to be set in the webinterface :slight_smile:

You don’t need to provide any SSL certificates as long as your broker isn’t configured for SSL.

Regarding your suggestion, I quote the relevant paragraph from the readme:

For a simpler integration, this software supports MQTT Discovery. To enable autodiscovery, supply the discovery topic that is configured in your Home Assistant instance (typically “homeassistant”) in the MQTT Configuration page. Once enabled, Smartlock and/or Opener should automatically appear on Home Assistant.

This is what I found for callbacks in terms of docs:

https://developer.nuki.io/page/nuki-bridge-http-api-1-13/4#heading--callback

I also found this:

Looks like RaspiNukiBridge has a way to detect if someone rang at the door, via the ring action binary sensor.

According to the dev, the device sends an iBeacon when state changes happen.

Not sure if it helps or not. And apologies if you have already looked at this (which most probably you did).

I would love to replace my Nuki Bridge with your ESP implementation. Nuki Bridge is highly limited in terms of # of connections and often replies with 503…

Cheers,
anthonws.

Hi,

I’m not getting an answer from the author of RaspiNukiBridge either, and from the code it’s not exactly clear how it works.

1 Like

OK, no answer from anyone. I’ll try and see what I can figure out myself.

Hi i have a Problem with the newest Firmware.
I can Lock and unlock the Opener via Home assistant but the Status in HA wont get updated it stays locked. RTO gets activated. Could you look into it? Already tried readding the Opener but didnt help…