Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for multiple locks #2

Open
Savjee opened this issue Jul 21, 2022 · 5 comments
Open

Support for multiple locks #2

Savjee opened this issue Jul 21, 2022 · 5 comments
Labels
enhancement New feature or request

Comments

@Savjee
Copy link
Contributor

Savjee commented Jul 21, 2022

Hi,

First up: awesome work! Works flawlessly!

Would it be possible to pair multiple Nuki locks to the same ESP?
I'm planning on adding a second lock (frontdoor + backdoor) and place my ESP32 in the middle.

@uriyacovy
Copy link
Owner

Hi Savjee,
Thank you for the feedback.

Regarding your request, I was already considering this but I think it is a bit problematic due to several reasons:

  1. The pairing/unpairing process would be more complicated to the average user.
  2. Testing of this feature would be difficult (while I plan to buy another Nuki, I don't own two devices currently).
  3. It is difficult to assess how good multiple devices are supported by the underlying library (https://github.com/I-Connect/NukiBleEsp32)

Overall, considering that an ESP32 module costs ~$5, I think it does not worth the effort. Nevertheless, I'll keep the issue open (as a feature request), and wait for additional comments.

Uri

@uriyacovy uriyacovy added the enhancement New feature or request label Jul 21, 2022
@Savjee
Copy link
Contributor Author

Savjee commented Jul 21, 2022

Thanks for your reply!

I don't have a lot of experience with developing for ESPHome, and zero knowledge of BLE, but I do want to give this a go. Here are my initial thoughts, and I'd love your feedback/guidance.

We could create multiple instances of your Nuki implementation and set their deviceId in the YAML. I believe this is supported by the NukiBLE library you're using (not sure though how you set the deviceId in your code. Seems like it's fixed to 2020002?)

Example:

lock:
  - platform: nuki_lock
    name: Front door
    device_id: 1234567  # Available in Nuki app
  - platform: nuki_lock
    name: Back door
    device_id: 987654  # Available in Nuki app

As for your other remarks:

  1. I believe the current pairing process could be kept. The logic would be: if the user has not defined a device_id himself, follow the regular pairing process.
  2. Agreed. I'm planning on buying a second one soon, so I could test it if you want.
  3. That's true. However, at first glance, it's seems well designed.

I know that ESP32's are cheap, and I have several of them around the house. But it seems wasteful to have 1 for each lock. I like to consolidate as much as possible.

@uriyacovy
Copy link
Owner

  1. The device id should be fixed, since it represents the bridge device id and not the smart lock device id (see "Authorization Data" in the Nuki bridge API doc).
  2. If everything is implemented right, the only thing you need to do to support multiple locks is to pass a unique device name for each lock. You can do this by initializing Nuki::NukiBle in nuki_lock.cpp with this->get_name() instead of this->deviceName_

I suggest that once you get the 2nd nuki, test the changes and I'll pull the PR if everything goes right.

@mkotek
Copy link

mkotek commented Nov 20, 2022

+1 on 2 locks spport

@uriyacovy
Copy link
Owner

I appreciate the feedback and the request, but currently, due to scheduling, IO and other complexities when working with BT and ESPHome, I do not plan support for two locks.
I'd leave the issue open to get further feedback.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants