Coder Social home page Coder Social logo

keyble's People

Contributors

henfri avatar oyooyo avatar schlagmichdoch avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

keyble's Issues

Disadvantages of Equiva Lock

Hi @oyooyo ! I have read that you no longer are using this lock. Can I ask why?

I am planning to replace a HMIP smart lock because I cannot open the door when there is no electricity at home (which sadly is not so infrequent).

Thank you for your efforts!

MQTT client only working twice

Amazing library! The repository works really well, especially with direct sendcommand, i don't have any issues.

I'm running it on my raspi 3b+. However, when trying the mqtt broker as a service, it doesn't always run as expected (usually twice after rebooting, it works fine). The messages are sent to the broker correctly, but then nothing outbound. Is the example provided for sure correct?
If yes, do you have a working example of a client? I'm new to mqtt so chances are high, that i made something wrong.
Some of my code snippets
client = mqtt.Client()
client.connect("localhost",1883,600)
client.subscribe("door_lock/status")
client.on_publish = on_publish
client.on_message=on_message
client.publish("door_lock/action", "open")
client.loop_start()

I dunno if that's related but when locking, the status usually changes to "UNKNOWN".

Thanks for your help! Amazing work!

Help Adding Support for Sherlock

Hello @oyooyo ,
I have seen your project and hard work and I hope you could help me with my Sherlock Smart Lock. 🤞
Unfortunately the company has died and the app won’t work anymore… :( so I can’t use this smart lock…

I have one smart key that can open the smart lock but I think that from not so much time it will stop to work either, now I ask you if you could help me to decode the logic of my smart lock ad we can add also the compatibility of Sherlock in your library :)

I can connect to the smart lock BLE with Sherlock, I could also see the notification and the write UUID but I don’t know how sould I write to open the door.

i hope in your reply
Best regards
Stefano

Cannot read properties of undefined (reading 'map')

Im getting an exception at the time of registering the user:

Registering user on Smart Lock with address "xx:1a:22:xx:6c:xx", card key "xxxxxxxxx" and serial "xxx"...
libc++abi: terminating due to uncaught exception of type Napi::Error: Cannot read properties of undefined (reading 'map')

cannot register new user

Hi,

Just installed in VM on Synology, but this happened to me on Raspberry Pi3 2 yeas ago.

Croot@debian-nodejs:~# keyble-registeruser -n keyble -q M001ZXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXNEQXXXXXXXXX Press and hold "Unlock" button until the yellow light flashes in order to enter pairing mode Registering user on Smart Lock with address "00:xx:xx:xx:xx:e9", card key "xxxxxxxxxxxxxxxxxxxxxxxxxxx" and serial "NEQXXXXXXXX"...

And it stay like this forever.
Running everything with root.

QR code

Hello.
I bought a used e-q3 KEY-BLE at the internet auction. Unfortunately, I do not have a card with a QR code for it.
I realized that the content of the code is the MAC address, followed by the serial number of the device. What is the middle string and is it possible to generate a QR sign at all, is the device suitable for rubbish?
I contacted the manufacturer's website, but he refuses to generate the code.
I will be grateful for any help.
Best regards!

Possible to obtain log data?

Does keyble provide any functionality to obtain the log data? I assume this is stored on the lock? This would be really helpful!
image

Protocol docu

Hi,

I just got my new eqiva door lock, started playing around and found this tool to be very helpful.

Is there a documentation about the protocol somewhere? Would be nice to have, to play around with the lock by myself.

Unfortunately I'm not familiar with JavaScript, I'm more the C/C++ and Python guy, so maybe it would be better for me to have a look onto the ESP32 project... but

I was wondering if it would be complicated/possible to extend keyble to also read the locks logs - as it is possible with the app.
I have seen the related issue #33 for this, but there is no final answer... I just mentions:

And figuring out how the device log works would take quite a bit of effort since I've never looked into this so far.

So does this mean there is no docu about the protocol and it needs to be reverse engineered?

I also found the "Mount_Options_Set_Message"... which seems not to be used for any function in the commandline tool? Is there any plan for usage?

Thx for this great tool and your answers

Fehler beim Abfragen des Status

Absetzen eines Befehls bspw Abfrage des Status geht einmal, danach nur noch dieser Fehler:
Error: TypeError: Cannot read properties of undefined (reading 'get_discovered_characteristic')

Debian 10/11 als VM unter Proxmox mit USB Bluetooth durchgeschleift, Node Version 8-16 alles probiert. Nach dem Neuaufsetzen der VM geht es dann wieder einmal und danach wieder obiger Fehler

Tutorial: Equiva key-ble Smart Lock and Integration with Home Assistant using keyble and keyble-mqtt

Equiva key-ble Smart Lock Integration with Home Assistant using keyble and keyble-mqtt

Hey there! Are you struggeling to integrate your eqiva smart lock into your smart home and control it using Home Assistant? Don't worry, there's a solution called keyble that allows you to control the Equiva key-ble Smart Lock using your computer and integrate it with Home Assistant.

This tutorial enables the integration of the Equiva key-ble Smart Lock into the Home Assistant system using keyble and keyble-mqtt. It allows you to conveniently control the door lock through the Home Assistant interface and trigger automated actions. You can lock, unlock, and open the door, as well as monitor the lock's status. However, it's important to note that the smart lock cannot handle two concurrent Bluetooth connections. If the manufacturer's official smartphone app is connected to the lock, keyble will not be able to connect to it simultaneously. Therefore, make sure to close the smartphone app for keyble to function properly.

Before we begin, I want to emphasize that making a door lock accessible over the network or the internet comes with certain security risks. If you choose to follow this guide, please be aware of the risks involved and take appropriate measures to secure your network and Home Assistant installation.

Alright, let's get started! I'll walk you through the steps on how to set up the Equiva key-ble Smart Lock with keyble and keyble-mqtt on a Raspberry Pi and integrate it with Home Assistant. Please note that you should already have a running Home Assistant instance and an MQTT broker installed. I won't cover the installation of these components in detail in this guide.

All Glory to https://github.com/oyooyo for developing key-ble!

Prerequisites

Before we begin, make sure you meet the following prerequisites:

Ensure that your Raspberry Pi is connected to the internet and update the system to have the latest updates and patches.

Installation of keyble

To install keyble, open a terminal window on your Raspberry Pi and execute the following commands:

sudo apt-get -y update && sudo apt-get -y dist-upgrade
curl -sL https://deb.nodesource.com/setup_lts.x | sudo -E bash -
sudo apt-get install --upgrade -y build-essential nodejs
sudo apt-get -y install bluetooth bluez libbluetooth-dev libudev-dev
sudo npm install --update --global --unsafe-perm keyble
sudo setcap cap_net_raw+eip $(eval readlink -f `which node`)

These commands perform the following actions:

  1. Update the system and install the latest updates.
  2. Install Node.js LTS and the required dependencies.
  3. Install Bluetooth libraries for communication with the smart lock.
  4. Install keyble globally using npm. (This step might take a while! Take a coffee break.)
  5. Allow keyble to run without sudo privileges.

Make sure the installation process completes without any errors.

Registering a User with keyble-registeruser

To control the Equiva key-ble Smart Lock, you'll need a user ID and the corresponding 128-bit user key. Since the manufacturer's official app doesn't provide a way to retrieve this information, you'll first need to register a new user. For that, we'll use the keyble-registeruser tool.

Use the following command to register a new user:

keyble-registeruser -n homeassistant -q M0123456789ABK0123456789ABCDEF0123456789ABCDEFNEQ1234567

Replace homeassistant with your desired username and M0123456789ABK0123456789ABCDEF0123456789ABCDEFNEQ1234567 with the information encoded in the QR code of the lock's "Key Card." Hold down the "Unlock" button until the yellow light flashes to activate the pairing mode. The tool will register the user and provide the necessary arguments you'll need to control the smart lock. If you encounter any issues with setting the name, you can cancel the action with Ctrl+C. Nevertheless, the user should still be registered, and you can verify it in the manufacturer's smartphone app.

Note down the MAC address of the smart lock (address), the user ID (user_id), and the user key (user_key) provided by the keyble-registeruser tool.

Installation of keyble-mqtt

keyble-mqtt is an MQTT client that allows you to control the Equiva key-ble Smart Lock via MQTT. Install keyble-mqtt by executing the following command:

sudo npm install --update --global --unsafe-perm keyble-mqtt

Ensure that the installation completes without any errors.

Running keyble-mqtt as a Service

To run keyble-mqtt as a service on your Raspberry Pi and ensure it starts automatically on system startup, we can create a systemd service file.

Create a new file named keyble-mqtt.service in the directory /etc/systemd/system/ with:

sudo nano /etc/systemd/system/keyble-mqtt.service

and insert the following content:

[Unit]
Description=keyble-mqtt
After=network.target

[Service]
ExecStart=/usr/bin/node /usr/lib/node_modules/keyble-mqtt/keyble-mqtt.js 01:23:45:67:89:ab 1 ca78ad9b96131414359e5e7cecfd7f9e --host 127.0.0.1
WorkingDirectory=/usr/lib/node_modules/keyble-mqtt
Restart=always

[Install]
WantedBy=multi-user.target

Make sure to replace the MAC address of the smart lock (01:23:45:67:89:ab) and the user data (1 and ca78ad9b96131414359e5e7cecfd7f9e) in the ExecStart line.

Save the file and execute the following commands to enable and start the service:

sudo systemctl enable keyble-mqtt.service
sudo systemctl start keyble-mqtt.service

keyble-mqtt will now run as a service and automatically start on system startup. To ensure that the service started correctly, you can use the following command:

sudo systemctl status keyble-mqtt.service

Configuration in Home Assistant

To integrate the Equiva key-ble Smart Lock into Home Assistant, you'll need to edit the Home Assistant configuration file.

Open the configuration.yaml file of Home Assistant and add the following YAML code:

mqtt:
  lock:
    - name: Front Door
      state_topic: "keyble/01:23:45:67:89:ab/status"
      command_topic: "keyble/01:23:45:67:89:ab/command"
      payload_lock: "lock"
      payload_unlock: "unlock"
      payload_open: "open"
      state_locked: "LOCKED"
      state_unlocked: "UNLOCKED"
      state_locking: "MOVING"
      state_unlocking: "MOVING"
      optimistic: false
      qos: 0
      retain: true
      value_template: "{{ value_json.lock_status }}"

Make sure to replace the MAC address of the smart lock (01:23:45:67:89:ab) in the state_topic and command_topic properties. You can also adjust the name of the lock (Front Door).

Save the configuration.yaml file and restart Home Assistant to apply the configuration changes.

Creating a Button Card to Control the Smart Lock

To control the Equiva key-ble Smart Lock in Home Assistant, we'll create a button card. Open the Lovelace configuration file of Home Assistant and add the following YAML code:

type: vertical-stack
title: Front Door
cards:
  - type: entities
    entities:
      - entity: lock.front_door
    show_header_toggle: true
    state_color: true
  - type: grid
    cards:
      - type: custom:button-card
        name: Lock
        tap_action:
          action: call-service
          service: mqtt.publish
          service_data:
            topic: keyble/01:23:45:67:89:ab/command
            payload: lock
      - type: custom:button-card
        name: Unlock
        tap_action:
          action: call-service
          service: mqtt.publish
          service_data:
            topic: keyble/01:23:45:67:89:ab/command
            payload: unlock
      - type: custom:button-card
        name: Open
        tap_action:
          action: call-service
          service: mqtt.publish
          service_data:
            topic: keyble/01:23:45:67:89:ab/command
            payload: open
    columns: 3
    square: false

Ensure that you replace the MAC address of the smart lock (01:23:45:67:89:ab) in the topic properties of the button card.

Save the Lovelace configuration file and refresh the Home Assistant interface. You should now see a button card that allows you to lock, unlock, and open the smart lock.

Conclusion

Congratulations! You have successfully integrated the Equiva key-ble Smart Lock with keyble and keyble-mqtt in Home Assistant. You can now control the smart lock through the Home Assistant interface and trigger automated actions. Explore further features of Home Assistant and expand your smart home control.

Enjoy controlling your Equiva key-ble Smart Lock in your smart home!

MQTT Service stopped working after a few seconds

I installed keyble and if I use it not as an MQTT Service it works fine.

As MQTT Service it works a few seconds, then no commands are received or published.
I figured out, that the problem is solved, when I use the parameter -adt 0.

And of course when I set it to -adt 3, the connections lost after this time (3s) when I set it to 10 then after 10s. Looks like keyble have problems to reconnect after auto disconnect.

Question: How much more is the battery usage withe -adt 0 ??? Is it significant?

Best Regards
Micky

Update 0.1.4 to 0.2.3 or 0.3.2 need help with nodeJS14

Hi Joachim,

seit Jahren nutze ich keyble erfolgreich mit iobroker, aber ohne Adapter, nur per EXEC in Skripten. Vielen Dank schon mal für deine geniale Arbeit!

Nun habe ich mein System von nodeJS 12 auf 14 aktualisiert und seit dem bekam ich bei 9 von 10 keyble Aufrufen folgenden Fehler:

Error: TypeError: Cannot read property 'get_discovered_characteristic' of undefined

Bisher war keyble 0.1.4 installiert. Nun sah ich, dass du bereits bei 0.3.2 bist und habe dies mittels sudo npm install --update --global --unsafe-perm [email protected] installiert. Liegt weiterhin unter /usr/lib/node_modules/keyble/
Anders wollte er die 0.1.4 nicht aktualisieren.

Aber nun funktioniert der Aufruf gar nicht mehr:
keyble-sendcommand: command not found
bzw.
bash: /usr/bin/keyble-sendcommand: No such file or directory

keyble-cli scheint es noch nicht zu geben?
Not Found - GET https://registry.npmjs.org/keyble-cli - Not found

Hab nun mal 0.2.3 installiert. Diese wirft aber auch recht oft Fehler:

$ keyble-sendcommand --status_update_time 0 --timeout 40 --address 00:11:22:33:44:55 --user_id 2 --user_key 0815 --command status
[ 'Error: ', '' ] TypeError: Cannot read property 'get_discovered_characteristic' of undefined
at Key_Ble.ensure_peripheral (/usr/lib/node_modules/keyble/keyble.js:455:52)
at async Key_Ble.ensure_connected (/usr/lib/node_modules/keyble/keyble.js:466:3)
at async Key_Ble.send_message (/usr/lib/node_modules/keyble/keyble.js:427:4)
at async Key_Ble.ensure_nonces_exchanged (/usr/lib/node_modules/keyble/keyble.js:475:3)
at async Key_Ble.send_message (/usr/lib/node_modules/keyble/keyble.js:417:4)
at async Key_Ble.request_status (/usr/lib/node_modules/keyble/keyble.js:485:3)

oder:

$ keyble-sendcommand --status_update_time 0 --timeout 40 --address 00:11:22:33:44:55 --user_id 2 --user_key 0815 --command status
noble warning: unknown handle 256 disconnected!
[ 'Error: ', '' ] Error: Unknown Connection Identifier (0x2)
at NobleBindings.onLeConnComplete (/usr/lib/node_modules/keyble/node_modules/@abandonware/noble/lib/hci-socket/bindings.js:240:13)
at Hci.emit (events.js:400:28)
at Hci.processLeConnComplete (/usr/lib/node_modules/keyble/node_modules/@abandonware/noble/lib/hci-socket/hci.js:795:8)
at Hci.processLeMetaEvent (/usr/lib/node_modules/keyble/node_modules/@abandonware/noble/lib/hci-socket/hci.js:766:10)
at Hci.onSocketData (/usr/lib/node_modules/keyble/node_modules/@abandonware/noble/lib/hci-socket/hci.js:596:12)
at BluetoothHciSocket.emit (events.js:400:28)

Alle 7-8 Versuche bekomme ich dann den Status. Prinzipiell funktioniert keyble 0.1.4 oder 0.2.3 weiterhin. Aber unter nodeJS 12 lief 1/10 der Kommandos schief (timeout oder auch noble warning), aber nun sind es eher 9/10.

Was kann ich machen damit es stabiler wird?
Und wie kann man die 0.3.2 z.B. mit iobroker javascript exec nutzen?

Proxmox VM mit Ubuntu 20.04.3 LTS
nodeJS 14.18.1 (/usr/bin/nodejs)
npm 6.14.15 (/usr/bin/npm)

Update README with notice to close the smartphone app

Hi!

I am using the lock together with the iOS app.
Now I have tried keyble with the lock.

You should mention in the README that while dealing with keyble, it is better to close the app.
The BLE peripheral that is built into the lock does not seem to handle more than one concurrent BLE connection at a time.
Trying to keep the app open while using keyble tools seems to lead to strange behaviour where commands time out and registering a user causes problems.

After having made sure that the iOS app is closed, everyhting worked as expected.

From my BLE knowledge and experiences I know that for simple BLE peripherals it is common to only support one concurrent connection only at the same time. Newer BLE peripherals which follow more recent version of the bluetooth spec (>=4.2) MAY support more concurrent connections at the same time.

Add "toggle" command

keyble should have a "toggle" command that automatically switches between the "locked" and the "unlocked" state.
@Ircama already provided an implementation, see #16

Prebuild binaries not found node-bluetooth and node-usb

Zuerst einmal: Tausend Dank für deine Arbeit an einem "unabhängigen" (= frei von einer proprietären App/Cloud) Zugang zum Smartlock. Das ist genau das was ich schon lange gesucht habe!

Ich habe bei der Installation von keyble allerdings das Problem, dass zwei Abhängigkeiten nicht heruntergeladen werden können. Die Ursache ist, dass die entsprechenden Dateinamen in den Repositories so nicht existieren:
prebuild-install http 404 https://github.com/tessel/node-usb/releases/download/v1.6.3/usb-v1.6.3-node-v83-linux-arm.tar.gz
`node-pre-gyp WARN Tried to download(404): https://github.com/abandonware/node-bluetooth-hci-socket/releases/download/0.5.3-6/bluetooth_hci_socket-0.5.3-6-node-v83-linux-arm.tar.gz
Ich hab es sowohl mit der release- als auch der beta-Version probiert.

Ich habe keinen entsprechenden Issue oder Wiki-Eintrag dazu gefunden, nach meinem Verständnis müssten "einfach" die Abhängigkeiten angepasst werden.

Ob sich das auf die Funktion von Keyble auswirkt, kann ich ehrlich gesagt nicht sagen, da es mir bisher noch nicht gelungen ist das Schloss ordnungsgemäß zu pairen, aber das liegt evtl. daran, dass ich ein gebrauchtes Schloss gekauft habe, mit der Smartphone-App habe ich aktuell auch Schwierigkeiten mit dem Pairing.

Wenn ich irgendwie unterstützen kann, bitte gerne melden! Wenn ich einen Fehler melde, der keiner ist, weise mich bitte zurecht und akzeptiere bitte schon jetzt meine Entschuldigung ;-)

Errors out with EAFNOSUPPORT

Hello,

I'm very interested in using keyble for my equiva EQ3 smart lock.
Unfortunately I get below error every time that I try to run the user registration:

keyble-registeruser -n xyz -q MxyzMxyz
/usr/lib/node_modules/keyble/node_modules/@abandonware/noble/lib/hci-socket/hci.js:74
this._socket = new BluetoothHciSocket();
^

Error: EAFNOSUPPORT, Address family not supported by protocol
at new Hci (/usr/lib/node_modules/keyble/node_modules/@abandonware/noble/lib/hci-socket/hci.js:74:18)
at new NobleBindings (/usr/lib/node_modules/keyble/node_modules/@abandonware/noble/lib/hci-socket/bindings.js:25:15)
at Object. (/usr/lib/node_modules/keyble/node_modules/@abandonware/noble/lib/hci-socket/bindings.js:546:18)
at Module._compile (internal/modules/cjs/loader.js:1063:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
at Module.load (internal/modules/cjs/loader.js:928:32)
at Function.Module._load (internal/modules/cjs/loader.js:769:14)
at Module.require (internal/modules/cjs/loader.js:952:19)
at require (internal/modules/cjs/helpers.js:88:18)
at module.exports (/usr/lib/node_modules/keyble/node_modules/@abandonware/noble/lib/resolve-bindings.js:13:12) {
errno: 97,
code: 'EAFNOSUPPORT',
syscall: 'socket'
}

It appears to be some version inconsistency with noble. I already searched the internet heavily, did try to build with different versions of node, but no success.

Do you have any hints on how I could this successful to build and run?

Thanks a lot in advance.

Peter

Issues in the new code which removes the hardcoded delays

Thanks for the new version. Unfortunately, I had limited time to test it. It sounds good and really speeds up timing. Here are some glitches:

  • when Eqiva eQ-3 device is not in range, keyble-sendcommand waits indefinitely for the "active" step: a timeout would be useful. The meaning of the STATUS_UPDATE_TIME timer is not clear to me; it does not look to control this timeout anyway.
  • lock command works, then the step switches from "active" to "undefined" and subsequently it freezes (control C to break); after interrupting, the status reports "undefined"; this is because my device uses status 3 for signaling the lock position (to test it, I labeled it closed in lock_status_string within keyble.js. After defining this additional status (3: 'closed') and changing the event to wait it in the lock() function (return this.await_event('status:closed')), the lock command completes correctly. Perhaps both events 0 and 3 (locked and closed) should be waited.
  • open command works, then freezes (control C to break); subsequently, a status query reports "unlocked"; I noticed that the issue can be fixed by setting the default_auto_disconnect_time to 30 seconds instead of 15. The many rotations of my Eqiva eQ-3 device in both directions issued by the open command take more than 15 seconds to complete.

List or Remove registered users

First, thanks for the keyble. It's exactly what I was looking for once I realized that the eqiva door locker had not base station for remote control.

I'm using under Raspbian, and it's working just fine. I was just wondering:

-Is there a way to remove registered users?
-Is there a way to list registered users?
-Is there a way to log actions made by users?

Systemd Start Script for Mosquitto connection

Hello,

would it make sense to document howto autostart the chain of mosquitto commands and keyble?
Here my conf:

/etc/systemd/system/SmartlockSchuppen.service
[Unit]
Description=SmartlockHintertuer
Require = network-online.target
After = network-online.target

[Service]
Type=simple
ExecStart=/usr/local/bin/SmartlockSchuppen.sh
Restart=always

[Install]
WantedBy=multi-user.target

/usr/local/bin/SmartlockSchuppen.sh then just includes the commands
#!/bin/bash #/usr/bin/mosquitto_sub -h 192.168.177.3 -t "SmartlockHintertuer/action" | /usr/local/bin/keyble-sendcommand --address x --user_id 3 --user_key y | /usr/bin/mosquitto_pub -h 192.168.177.3 -l -r -t "SmartlockHintertuer/status"

Seems trivial, but took me a while to figure out. With an init-script it did not work. The network was not reachable -although I had it as a dependency. My first tries with systemd failed as well until I put the chain of commands into an external script. So, it is not so trivial in the end

Greetings,
Hendrik

Wrong example in Wiki for Topic

Hi, and thank you for your great work.
I just wanted to ask you to change the Topic for the mqtt Smartlock.sh file example from "Smartlock/action" to "door_lock/action"
it took me some time... ;)
thx

Entwicklung von Version 1.0.0

Die deutsche Version von #22, weil die meisten keyble-Nutzer offensichtlich deutsch sprechen.
Jegliche Kommentare etc. betreffend der Entwicklung von Version 1.0.0 (siehe #22) bitte hier posten.

Nodemcu / esp32 compatibility

Hi,

due to the low price i think the lock would be optimal in combination with a cheap controller.
Is there a way to run this on Nodemcu or will there be a future release for that?

[DE] Projekteinbindung in ioBroker

Hi,
ich schreibe hier mal auf Deutsch.. Ich bin vor zwei Tagen auf dein Projekt aufmerksam geworden und da ich im Besitz des besagten Türschlosses bin und mein Zuhause "Smart" ist, dank der Software ioBroker hier ganz Stumpf die Frage: Würdest Du der Community helfen deinen Code in einen Adapter zu packen für ioBroker?

Der Adapter ist bereits requested, aber Du bist scheinbar schon tief in der Materie :)

ioBroker/AdapterRequests#114

Danke dir im Voraus

Development of keyble version 1.0.0

I plan to release keyble version 1.0.0 in the near future, which will come with a few changes worth mentioning:

  1. The current "keyble" npm package will be split into two parts: The "keyble" package will only contain the core API, the command line tools will all move to a separate package named "keyble-cli". So in the future, you will probably npm install keyble-cli instead of npm install keyble.

  2. There will only be a single command line tool in the future, probably named "keyble". So there won't be separate keyble-registeruser and keyble-sendcommand scripts; your command line will change from keyble-sendcommand ... to keyble sendcommand ... (notice the space instead of the dash character)

  3. Starting with version 1.0.0, I intend to provide a properly documented and stable API and switch to semantic versioning. So if you're using keyble as an API in another Javascript project, backwards-incompatible changes to the API shall only occur on major version changes in the future.

  4. I intend to provide some more npm packages in order to make it easier to use keyble in smart home systems:

  • keyble-mqtt, for making it easier to use control the smart lock via MQTT
  • keyble-nodered, for making it easier to control the smart lock via Node Red
  • keyble-iobroker, create an actually working adapter for ioBroker

Until version 1.0.0 is ready, the version 0.1.14 from 2018 is the latest stable version that gets installed when running

npm install keyble

The latest unstable development version can be installed by using the nexttag, e.g.

npm install keyble@next

I will post some updates on the status of the development here.
If you have any suggestions, comments etc. concerning the development of version 1.0.0, please post them here as well.

Nodejs 10 Kompatibilität

Ich habe versucht keyble mit einem aktuellen debian buster unter raspberry zum laufen zubringen. Leider kann man nodejs 8 gar nicht mehr darauf installieren. Er bügelt immer gleich die 10 drauf.

Hast du vielleicht nochmal die Zeit und Lust das ganze auf nodej10 kompatibel zu bauen? Das tool ist wirklich super. War kurz davor die Alexa via Skill anzukoppeln :-/

Danke im voraus

Fehlermeldung unter Ubuntu

Hallo,

ich habe zum Testen in einer VirtualBox mit Ubuntu 18.04 das Keyble installiert. Das Registrieren euners Benutzers im Smartlock hat grundlegend funktioniert. Bei der Meldung

Setting user name to "testuser"...

kommen die folgenden Meldungen:

Bluetooth hci0: unexpected SMP command 0x02 from <MAC Adresse>
Bluetooth hci0: unexpected SMP command 0x03 from <MAC Adresse>
Bluetooth hci0: unexpected SMP command 0x04 from <MAC Adresse>
Bluetooth hci0: unexpected SMP command 0x06 from <MAC Adresse>
Bluetooth hci0: unexpected SMP command 0x07 from <MAC Adresse>

Die selben Meldungen kommen wenn ich versuche ein Kommando zu senden.

In der App ist ein User mit der Bezeichnung user 2 angelegt.

ubuntu 20.04

Hey Guys,
i am running Ubuntu 20.04 LTS and when i run the script for mqtt, i always get an error after short time:
noble warning: unknown handle 71 disconnected!
and after that, it stops working
could you please help me?
thx

Adding a status command

Congratulations for this code!

I can confirm that it works as per documentation on a Raspberry Pi Zero W with Raspbian O.S.

I anyway think that there are a couple of possible improvements: removing the currently included delays (the code has at the moment one delay of 5 seconds and another one of 10 seconds which might be optimized) and adding the status command (useful feature; e.g., door is currently locked/unlocked).

I tried to test key_ble.request_status(), which, if I am not wrong, is always returning null data (regardless the actual state of the door):

{ '0':
   { __type__:
      { __super__: [Object],
        id: 131,
        label: 'STATUS_INFO',
        properties: [Object] },
     data_bytes: [],
     data:
      { a: false,
        user_right_type: 0,
        e: false,
        f: false,
        g: false,
        h: false,
        i: false,
        j: false,
        lock_status: 0,
        l: undefined,
        m: undefined } } }

Notice that I also used a similar test code to dump keyble.ensure_nonces_exchanged() and some information is returned in this case:

{ '0':
   { __type__:
      { __super__: [Object],
        id: 3,
        label: 'CONNECTION_INFO',
        properties: [Object] },
     data_bytes: [ 5, 53, 34, 245, 210, 138, 108, 142, 235, 0, 16, 23, 0, 0 ],
     data:
      { user_id: 5,
        remote_session_nonce: [Array],
        bootloader_version: 16,
        application_version: 23 } } }

Can you advise on how to get the locked or unlocked state of the device?

Keine Registrierung möglich

Server: Ubuntu 18.04 LTS
Nodejs: 8.15.0

Nach Eingabe von
keyble-registeruser -n PC -q xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

kommt

Press and hold "Unlock" button until the yellow light flashes in order to enter pairing mode
Registering user on Smart Lock with address "xx:xx:xx:xx:xx:xx", card key "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" and serial "xxxxxxxxxxxx"...

das Pairing-Signal am Schloss ist hört nach ca. 45 Sekunden auf, aber weiter passiert nichts. Nach ein paar Minuten beende ich dann mit Strg-C am HomeServer den Pairingversuch. Es kommt kein Timeout oder dergleichen. Der HomeServer ist frisch mit Ubuntu aufgesetzt, kein Docker oder VM.

register does not work

[root@hawkstar husqar]# keyble-registeruser --qr_code_data XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX --user_name hsqr
Press and hold "Unlock" button until the yellow light flashes in order to enter pairing mode
Registering user on Smart Lock with address "00:1a:22:0a:1c:14", card key "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" and serial "NEQ1064762"...

Nothing morge happens on my system...

libc++abi: terminating due to uncaught exception of type Napi::Error

I'm trying to run
DEBUG=* keyble-registeruser -n testuser1 -q XXX
on my mac.

After a few seconds that is what I get:

Registering user on Smart Lock with address "XXX", card key "XXX" and serial "XXX"... noble stateChange poweredOn +0ms simble:info Starting to scan for peripheral... +0ms noble scanStart +0ms libc++abi: terminating due to uncaught exception of type Napi::Error zsh: abort DEBUG=* keyble-registeruser -n testuser1 -q

Do you know how to get around that bug?

UnhandledPromiseRejectionWarning and other errors

I tried now for months to get this running stable, but every few minutes it stopped working.
And i can't really reproduce the problem. Its such a strange behavior.

I restart bluetooth, the restart the keyble-mqtt service.
And some seconds later i get this error.

18:52:03 raspizero2 keyble-mqtt.sh[23658]: (node:23659) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'write' of undefined │
18:52:03 raspizero2 keyble-mqtt.sh[23658]: at Key_Ble.send_message_fragment (/opt/nodejs/lib/node_modules/keyble-mqtt/node_modules/keyble/keyble.js:498:28) │
18:52:03 raspizero2 keyble-mqtt.sh[23658]: at processTicksAndRejections (internal/process/task_queues.js:93:5) │
18:52:03 raspizero2 keyble-mqtt.sh[23658]: at async Key_Ble.send_message_fragments (/opt/nodejs/lib/node_modules/keyble-mqtt/node_modules/keyble/keyble.js:506:4) │
18:52:03 raspizero2 keyble-mqtt.sh[23658]: at async Key_Ble.send_message (/opt/nodejs/lib/node_modules/keyble-mqtt/node_modules/keyble/keyble.js:530:3) │
18:52:03 raspizero2 keyble-mqtt.sh[23658]: at async Key_Ble.ensure_nonces_exchanged (/opt/nodejs/lib/node_modules/keyble-mqtt/node_modules/keyble/keyble.js:575:3) │
18:52:03 raspizero2 keyble-mqtt.sh[23658]: at async Key_Ble.send_message (/opt/nodejs/lib/node_modules/keyble-mqtt/node_modules/keyble/keyble.js:513:4) │
18:52:03 raspizero2 keyble-mqtt.sh[23658]: at async Key_Ble.send_command (/opt/nodejs/lib/node_modules/keyble-mqtt/node_modules/keyble/keyble.js:405:3) │
18:52:03 raspizero2 keyble-mqtt.sh[23658]: at async Key_Ble.lock (/opt/nodejs/lib/node_modules/keyble-mqtt/node_modules/keyble/keyble.js:364:3) │
18:52:03 raspizero2 keyble-mqtt.sh[23658]: at async MqttClient. (/opt/nodejs/lib/node_modules/keyble-mqtt/keyble-mqtt.js:159:7) │
18:52:03 raspizero2 keyble-mqtt.sh[23658]: (Use node --trace-warnings ... to show where the warning was created) │
18:52:03 raspizero2 keyble-mqtt.sh[23658]: (node:23659) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or │
18:52:03 raspizero2 keyble-mqtt.sh[23658]: (node:23659) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js p│

grafik

Then i repeat this, restart BT and keyble i got a different error from noble


│May 19 18:55:03 raspizero2 keyble-mqtt.sh[23658]: /opt/nodejs/lib/node_modules/keyble-mqtt/node_modules/@abandonware/noble/lib/hci-socket/hci.js:120 │
│May 19 18:55:03 raspizero2 keyble-mqtt.sh[23658]: this._socket.bindRaw(this._deviceId); │
│May 19 18:55:03 raspizero2 keyble-mqtt.sh[23658]: ^ │
│May 19 18:55:03 raspizero2 keyble-mqtt.sh[23658]: Error: EALREADY, Operation already in progress │
│May 19 18:55:03 raspizero2 keyble-mqtt.sh[23658]: at Hci.init (/opt/nodejs/lib/node_modules/keyble-mqtt/node_modules/@abandonware/noble/lib/hci-socket/hci.js:120:18) │
│May 19 18:55:03 raspizero2 keyble-mqtt.sh[23658]: at Hci.pollIsDevUp (/opt/nodejs/lib/node_modules/keyble-mqtt/node_modules/@abandonware/noble/lib/hci-socket/hci.js:135:14) │
│May 19 18:55:03 raspizero2 keyble-mqtt.sh[23658]: at listOnTimeout (internal/timers.js:554:17) │
│May 19 18:55:03 raspizero2 keyble-mqtt.sh[23658]: at processTimers (internal/timers.js:497:7) { │
│May 19 18:55:03 raspizero2 keyble-mqtt.sh[23658]: errno: 114, │
│May 19 18:55:03 raspizero2 keyble-mqtt.sh[23658]: code: 'EALREADY', │
│May 19 18:55:03 raspizero2 keyble-mqtt.sh[23658]: syscall: 'bind' │
│May 19 18:55:03 raspizero2 keyble-mqtt.sh[23658]: }

grafik

And now, if I repeat this one more time, restart bt and keyble, I get this smp error, but keyble does the job and turn the key.
At first i was worried about the snp error, but now its a hint that the communication is working.

grafik

This behavior is completely random.
ATM i have a cron job running, which restarts BT and keyble every 5min, but even with this, the chance that the look opens if needed are <50%.

Is there anything i can do to help?

unexpected SMP command

I'm using keyble mqtt for some time now and get every few minutes/hours some Bluetooth kernel errors.

raspizero2 kernel: [ 1277.916823] Bluetooth: hci0: unexpected SMP command 0x02 from 00:1a:xxxx

In this time, the look is offline in Home Assistant. In 5 from 10 attempts this happens if we need it.
I'm running it on a raspi zero. There are no other running processes, the zero is only for keyble.
Is there anything I can do about this?

grafik

grafik

Delay in executing a sendcommand

Hi, first of all I'd like to thank you for sharing the code. I have been looking for such a program since 2017. By chance and little help from google, I found your code. It is working flawlessly.

The only issue that I am having is amount of time between sending a KEYBLE-SENDCOMMAND and initial reaction from the Eqiva Smart lock. I have measured it and averages between 5 to 7 seconds from the moment hitting enter key until lock starting to react (not including the time to rotate the lock). It is the same for all commands, open, lock, unlock even status. I tried it from a bunch of other computers but it is the same.

When I use the app it is almost instantaneously, no delay at all. I thought it might be due to auto_disconnect feature, so I disabled it with -adt 0 but no luck.

In my setup, the smart lock is powered by a external power source and I have no concern about saving batteries, rather I'd like instant reaction from the smart lock.

What I would like to know is:

1- is it normal for the lock to take 5 to 7 seconds for a keyble-sendcommand?
2- what causes this delay?
2- is there any way to reduce the above mentioned time?
3- how can I check that I am connected to the smart lock?

I really appreciate any help or comment.

many thanks,
NFC++

Switches to status "UNKNOWN" after locking

When sending the command "lock", keyble switches to the state "UNKNOWN" followed by a timeout error.

Is there a remedy?

MOVING
UNKNOWN
Error: Promise did not resolve within 45000 milliseconds

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.