Unoffical danalock web API

I will give it a try tonight.
I got an answer from Danalock also.
I’ll write it later. It’s not good, don’t get your hopes up.

No difference…
I’m still stuck at the first sequence. I can’t get the token in the Oauth subflow.

I tried to run the API from online but I get another error.


“Server” is the missing word.

Just for fun, I tried to use IFTTT, I could connect using IFTTT.
I was hoping I couldn’t since that would make sense.

Anyways… I got a very short reply:

Our API’s and SDK’s are not public. The are only for partners with a contract with Salto (the owner of Danalock).

So what you ask for I caanot help you with

I asked for local API, so it seems there is a local API :laughing:

I replied with this:


All the yellow marked unlocks are false unlocks. Where their app believed I have been more than 300 m away and got back.

Home Assistant says this:


Sure there are glitches where our phones has been reported outside, but that is not more than about 25 meters.
Far from the required 300 m.
And now just recently the door got unlocked when I walked upstairs.
Not very reliable product/app in my opinion.

Hi! Seems we have to discover the Danalock APIs on our own :+1: :slight_smile:

I’m also a bit disapointed at this Danlock product. For me I miss basic features like being able to schedule it getting locked, and easy integration, but also because it loses connection with the danabridge now and then. In these cases, I simply just get the real key, but I could never rely on this lock when I don’t have a key. Perhaps adding a danalock numpad would be a more robust solution, but if the lock can lose connection with the danabridge, perhaps it can lose connection with a numpad as easily.

I’m using Yale Doorman V2N for the main door. It more expensive, but it always works, and unlocking using mobile is quite quick - and not like the 7-8 seconds Danalock needs.

Can you provide more information about your node-red installation?

Perhaps try to build a simple flow where you use node-red-contrib-oauth2 and debug it? Or perhaps you already tried that? I’m losing track of what we’ve tried.

Regarding the try you had using oauth json in an online tool - it will not work, because the way the json is structured in node-red using the oauth2 node is not how the HTTP request body looks when it is sent to the danalock server.

I’ve done some major restructuring of the flow because it was getting hard to manage. Please note that changes are not extensively tested.

Still stuck at the first stage. I can’t get the token.
I tried to add a auth node and input the details manually in the node, no change…

I found the IP of my bridge, it uses a ESP chip.
Not sure if it’s 32 or something else, but since it uses Bluetooth I assume it’s a 32.
Did a port scan.

Could that mean the ESP phones home every now and then and asks if it should open or close the door?
That could make sense given the delay there is when you press unlock.

I think the reason there’s a delay when executing e.g. an unlock action is because the lock runs on battery - and having the lock connected via Bluetooth to the bridge all the time would deplete the battery much quicker, i.e. its a design decision from Danalock to decrease the polling interval to gain greater battery life at cost of less responsive lock actions.

Perhaps… But I don’t notice much delay when I arrive home and it detects my phone.

But surprise on the inside!
8266! But I can’t see any bluetooth chip, or even antenna…

Hello Erik.
Can you make a simple step by step procedure to integrate the danabridge in HOME ASSISTANT.
Maybe is asking too much but I would appreciate a lot.
Thanks in advance

Hi! No worries - have you checked the github page? There’s a link in the first post.

Still can’t get it working, just let me know and I’ll help you on the way.

Hi all

I just bought myself a Danabridge for a cheap sum and used it for my BT Danalock v3.

This integration works really nice, I did some slight modifications to the NR flow due to me having the NR completly locked in to it won’t accept http calls, but it do listen to events in HA.

So I changed the start of the flow to a “events: all node”, edited the switch so that it would direct based in on the events received and then just created a template lock in HA.

lock:
  - platform: template
    name: 'Guesthouse door'
    value_template: "{{ is_state('input_boolean.danabridge_lock_status', 'on') }}"
    lock:
      - service: svc2evnt.fire_event
        data:
          event_type: danalock_event
          data:
            domain: guesthouse
            id: lock
      - delay:
          seconds: 5
      - service: input_boolean.turn_on
        entity_id: input_boolean.danabridge_lock_status
    unlock:
      - service: svc2evnt.fire_event
        data:
          event_type: danalock_event
          data:
            domain: guesthouse
            id: unlock
      - delay:
          seconds: 5
      - service: input_boolean.turn_off
        entity_id: input_boolean.danabridge_lock_status

Here I’m also using a custom integration to be able to fire own events, that’s a handy one to easily integrate to NR since you can do service calls from wherever in HA. Using the input_boolean to keep track of the lock status since I need to have the open ended setting of the lock.

Nice! :+1: :wink:

Hi
I’m having trouble with getting this to work. I have installed the oauth2 node and put my credentials in the change node. Also edited my configuration.yaml, but it doesn’t work. If I look at the sensor status it says “401 Authorization Required

401 Authorization Required


nginx”.
I can’t call service to lock and unlock either. Please help. I have danabridge with one danalock v3

What’s the output of this web request?

node-red-host:1880/danalock/bridge/v1/execute/status

And where is your node-red installed? Host and port?

And you can use your Danalock credentials to login to the Danalock site?

Nevermind, I got it working!

I changed the url’s from:
http://node-red-host:1880/bridge/v1/execute/
to:
http://node-red-host:1880/endpoint/danalock/bridge/v1/execute/

Thank you!

1 Like

Thanks Erik.
I already read the github page but It seems that I need to use node-red and I never use node-red and I don´t know anything about it.
Will be my next challenge because I would like use danabridge in HA.
If you have any alternative and simple way to get it, please tell me.
Thanks for your help

Hi @Peixotocta1, node-red is actually quite easy to install, configure and get running, as well as debug. Its a very visual, low code, experience.

Most of the time the flexibility in the Home-assistant framework meets my needs, however, for simple integration tasks such as querying a web API, and finding a value in the response body, I came to really enjoy how node-red can solve this quickly.

To operate the Danalock locks, you need to implement Oauth flows, something that can be done in your preferred tool of choice - but I doubt it will be easier than the current node-red solution.

Try some node-red tutorials, and if you get stuck, you can always post your question in node-red forums, or here if its more related to Home-assistant.

Good luck!

Thanks Erik.
I already started following thw node red tutorials. Will take some time but I hope I´ll can do it.
Thanks one more time

@gechu

I’ve been using this for a few months now and mostly it is working nicely, but on and off I need to trigger the renewal for Oauth credentials.

Any idea of how long the tokens are active? Then I can schedule renewal based on that time.

Hi @Abertil, I’ve noticed it as well. I’ve also noticed that the bridge’s wifi connection somtimes just dies and is left in a disconnected state.

I don’t know how long an access token is valid, but you may be able to figure it out if you manually setup Postman to request an access token. Google or use the Oauth RFC to figure out how to setup the HTTP call - the parameter is called “expires_in” - more info here:
rfc6749 (ietf.org)

Regardless, if you add a scheduled trigger to the Node-red flow that would execute every 1 hour, I think you’ll have a workaround.

Thanks for pointing out the issue, don’t know when I’ll look into it finding a more elegant solution though. Vacation times :palm_tree: :slight_smile:

1 Like

Hey all, looking for a bit of help.
HA is on the latest version, i have put the NR flow in place, updated the URL to @ruzzbug suggestion (adding /endpoint/) but when i run the url directly NR goes nuts in debug.
If i look at the sensor.danalock i see the following:


In NR, the username and password are definetly set correctly (tried Incognito and logged in to Danalock website using the same credentials. Any suggestions?