This repo contains instructions for integrating the Danalock V3 Smart lock using web API requests.
Key use cases:
Table of contents:
Requirements:
This option involves running a Node-RED flow that abstracts away the complexity of dealing with the Danalock web APIs.
IMPORTANT NOTE: The API operations exposed by the Node-RED flow are NOT secure:
- Anyone with local network access can access the API operations exposed by the Node-RED flow (and indirectly the Danalock).
- Data is not encrypted during transport. Instructions for securing data in transit can be found here How To Secure Nginx with Let's Encrypt on Ubuntu 22.04.
Set the lock name in the Danalock web UI.
Lock naming rules:
0-9
, a-z
, and A-Z
. Note that the name is also case-sensitive._
) is also safe to use.A good example is garden_storage
.
See Node-RED installation options.
In all subsequent examples, Node-RED is assumed to be installed in in a host named nodered
, and the web UI and services are exposed from http://nodered:1880.
The Node-RED flow will look for Danalock credentials in a file named danalock.cfg
located in the working directory of the Node-RED process. If you can´t create this file, please see option Step 3 - ALTERNATIVE
below.
Examples:
Running Node-RED | Path to danalock.cfg |
---|---|
As a user named nodered |
/home/nodered/danalock.cfg |
As the root user in a LXC container (e.g. using Proxmox) | /root/danalock.cfg |
As an addon in Home-Assistant. | Set up a Node-RED context store |
Create a file in the working directory of your Node-RED installation named danalock.cfg
that follows the structure below, and add your Danalock account credentials:
{
"username": "username@somemail.com",
"password": "yourpassword"
}
Set your Danalock account credentials in the node named "set credentials".
Import danalock.json
to Node-RED. The flow logs events using Node-RED's standard logging capability. In some Node-RED installations the log can be viewed using the command node-red-log
.
In the below examples, the name of the lock is "storage_room".
Operation | API request |
---|---|
List locks | GET http://nodered:1880/danalock/locks |
Get state | GET http://nodered:1880/danalock/storage_room/get-state |
Lock the lock | GET http://nodered:1880/danalock/storage_room/lock |
Unlock the lock | GET http://nodered:1880/danalock/storage_room/unlock |
Get battery level | GET http://nodered:1880/danalock/storage_room/battery-level |
Note: All operations above (except "List locks") result in a call being made to the lock. Such calls often take about 5-7 seconds to complete.
Another option is to build your Danalock API client using API calls directly to the Danalock APIs. See OpenAPI docs unofficial-danalock-web-api.yaml
and unofficial-danabridge-web-api.yaml
for more info.
In this example, the server URLs are excluded.
First, retrieve the bridge's serial number. Requests are described in unofficial-danalock-web-api.yaml
.
GET /locks/v1
GET /devices/v1/{lock-serial_number}/paired_devices
to retrieve paired devices.Second, ask the Danalock bridge for status. Requests are described in unofficial-danabridge-web-api.yaml
.
lock serial_number
+ operation
(i.e. "afi.lock.get-state") in POST /bridge/v1/execute
to ask the bridge to prepare a status message. This call will return an job id
to be used in next request.job id
from previous call to poll the bridge for the status message POST /bridge/v1/poll
Danalock can be integrated into Home Assistant using standard platform components. Instructions are provided in home-assistant\recipe-unlock-15-minutes.md
.
Integrating Danalock to Home Assistant is discussed in the Unoffical danalock web API forum post.