dauden1184 / RaspiNukiBridge

Simple Nuki Bridge implementation using asyncio
GNU General Public License v3.0
48 stars 19 forks source link

Add support for opener #3

Closed Bladestar2105 closed 1 year ago

Bladestar2105 commented 2 years ago

Hello!

Your Bridge works very well with the smartlock! Could you please implement support for the opener?

And another question. How can I enable it so it autostarts when my Linux comes up?

dauden1184 commented 2 years ago

Hello,

I don't have a Opener so I cannot test it, I will look into it anyway but I probably will need some help from you while debugging.

For start the software automatically you can create a systemd service, I will add a small guide to the readme in the next days

Bladestar2105 commented 2 years ago

Tell me what you need and I can help you :-)

dauden1184 commented 2 years ago

Were you able to pair the opener with the software? what kind of issues are you having?

dauden1184 commented 2 years ago

And another question. How can I enable it so it autostarts when my Linux comes up?

Added instructions for this in the README

maddingamer commented 2 years ago

Hi, I just found your repo and I'm getting an opener soon and want to use some kind of software bridge. I will try it out and would be happy to help adding support for the opener :)

maddingamer commented 2 years ago

Found the documentation for opener: https://developer.nuki.io/page/nuki-opener-api-1/7

dauden1184 commented 2 years ago

I see that there are not many differences from the smartlock, you should be able to pair the opener with the software. Can you confirm this? after this I'll add the missing actions for the opener

maddingamer commented 2 years ago

Sounds promising, I haven't tried or even installed your software yet. I will try today evening or tomorrow morning and will give an update.

maddingamer commented 2 years ago

It took me a few tries, but it seems to have worked.

Output in a pastebin as I am too stupid to properly format in here 😂 https://pastebin.com/K8AG1fNK

Edit: Also it stays at the last line until I quit.

dauden1184 commented 2 years ago

So, this happens while trying to pair the opener?

maddingamer commented 2 years ago

So, this happens while trying to pair the opener?

Exactly. Took me a few times to get it to kinda pair tho.

dauden1184 commented 2 years ago

The pairing seems to not be completed, I'll look into it. Please try to run the pairing command with the --verbose flag to have more logs (remember to hide any personal information in it)

maddingamer commented 2 years ago

Please try to run the pairing command with the --verbose flag to have more logs (remember to hide any personal information in it)

It seems like it doesn't make any difference using --verbose flag. Output is exactly the same.

dauden1184 commented 2 years ago

So, it seems the software cannot find the ble characteristic used by the pairing process (but on the docs it's the same as the smartlock, so that's strange). Anyway I just added some verbose logs so, if you can, update and try again with the verbose logs flag please

maddingamer commented 2 years ago

I'll try again with verbose logs once I get home!

maddingamer commented 2 years ago

Here you go: https://pastebin.com/Q8GUcZ0m

dauden1184 commented 2 years ago

uhm, It seems the values of the characteristics in the official docs are wrong? Can you please try to edit the file nuki.py and change these lines:

BLE_SERVICE_CHAR = "a92ee202-5501-11e4-916c-0800200c9a66"
BLE_PAIRING_CHAR = 'a92ee101-5501-11e4-916c-0800200c9a66'

with these:

BLE_SERVICE_CHAR = "a92ae202-5501-11e4-916c-0800200c9a66"
BLE_PAIRING_CHAR = 'a92ae101-5501-11e4-916c-0800200c9a66'

and run it again?

maddingamer commented 2 years ago

uhm, It seems the values of the characteristics in the official docs are wrong?

Interesting 🤔😂

Got another error now: https://pastebin.com/RuJpicRq

dauden1184 commented 2 years ago

It seems the error is that the opener isn't in pairing mode. You should press the button on the opener for 5 seconds in order to set it in pairing mode, did you do this?

maddingamer commented 2 years ago

It seems the error is that the opener isn't in pairing mode. You should press the button on the opener for 5 seconds in order to set it in pairing mode, did you do this?

I guess I didn't press long enough. Now it seems to look better: https://pastebin.com/QSu9VmBH

dauden1184 commented 2 years ago

yes, that's good! the pairing process is completed, you can copy the info in the yaml file (as explained in the readme) and start the software.

maddingamer commented 2 years ago

Done. https://pastebin.com/V7KN8AGi

dauden1184 commented 2 years ago

So the communication is working but the format of the CONFIG message is different (the HomeKit status field is missing). I'll work on this and consolidate the different characteristics values we found. Probably updating tomorrow ;)

maddingamer commented 2 years ago

Makes sense as the opener is not supported by homekit at all.

Thanks! Let me know when to update and try again! :)

dauden1184 commented 2 years ago

You can update the software and try again

maddingamer commented 2 years ago

You can update the software and try again

Seems like the same problem as yesterday when pairing https://pastebin.com/zTsf1gTL

dauden1184 commented 2 years ago

It seems that there are problems with the pairing procedure but you already paired it yesterday, so It should be not necessary to do it again. can you start the software normally? (I'll fix the pairing procedure in the meantime)

maddingamer commented 2 years ago

I did a fresh start by downloading the repo again into a new folder, so I guess I have to pair it again first, sorry.

dauden1184 commented 2 years ago

ok, i think i fixed it, try again please

maddingamer commented 2 years ago

It generates the keys and then seems to be stuck on 2022-04-01 16:02:28.544|I|nuki.py:555|Device type: DeviceType.OPENER

EDIT: Added --verbose flag, stuck on 2022-04-01 16:06:33.407|D|nuki.py:466|Sending data to a92ae101-5501-11e4-916c-0800200c9a66: b"\x01\x00\x03\x00'\xa7"

dauden1184 commented 2 years ago

updated, try again please

maddingamer commented 2 years ago

Pairing completed. When starting the software its saying this in a loop (added the opener as smartlock, as it seems to expect a smartlock in the yaml):

https://pastebin.com/7Y6JTcPP

First time starting the software it also says Device XX:XX:XX:XX:XX is SMARTLOCK_1_2 before "Updating nuki state"

dauden1184 commented 2 years ago

Updated the code, please try again!

maddingamer commented 2 years ago

Done. It's still correct that I'm using 'smartlock' in the yaml right?

Https://pastebin.com/wr6BHPgB

dauden1184 commented 2 years ago

It's still correct that I'm using 'smartlock' in the yaml right?

yes, don't worry about that.

Looking at your logs it seems the software now correctly identify the device as the opener, and it's using the correct configuration mapping values (the one without the homekit status) but still it seems there is something different. can you try to run it with the verbose flag?

maddingamer commented 2 years ago

Okay, sry I didn't know there is a verbose flag for the script itself too (as it is already paired). But I ran with verbose now: https://pastebin.com/QY1DuagY

dauden1184 commented 2 years ago

good, I've probably found the problem, try again please

maddingamer commented 2 years ago

Looks good to me, it's getting the name, location etc from the opener and stays at the last line without error or exiting.

Https://pastebin.com/SHzMmb6h

What would be the next step?

dauden1184 commented 2 years ago

perfect! next step would be to try some actions on the opener. Are you planning to integrate this bridge with homeassistant, openhub or something like that?

maddingamer commented 2 years ago

I want to add it to homeassistant, yes :)

dauden1184 commented 2 years ago

well you can already do it, just configure the official integration using the ip address of your raspberry and the token that is saved in your nuki.yaml file. let's see if it works!

maddingamer commented 2 years ago

Works, but without any entities or devices.

dauden1184 commented 2 years ago

any errors in the software logs?

maddingamer commented 2 years ago

In ha logs it only says unknown device type: 1. Using the official integration.

dauden1184 commented 2 years ago

ye, my DeviceType mapping was incorrect :( Try to update the software and retry please

maddingamer commented 2 years ago

It seems to be still the same. I'll try again tomorrow tho, unless you find something.

dauden1184 commented 2 years ago

shoud be fixed now

maddingamer commented 2 years ago

shoud be fixed now

Now it just says canceled when setting up the integration. Logs are empty.

dauden1184 commented 2 years ago

The last edit was really a minor one, it shouldn't cause issues like this without some errors in the logs. Try to remove the integration, restart the software and homeassistant and try it again.

maddingamer commented 2 years ago

I restarted HA again, reenabled the previously deactivated integration and it now shows one entity. But it says locked, even tho it's an opener and not a lock.