[RELEASE] TTLock API Integration

First time creating a Hubitat driver. I do plan on trying to create an app to handle a callback URL from the TTLock API side to get quicker unlock/lock updates.

I've tested this on 4 locks and 2 gateways I have. (No WiFi locks). So far it can unlock/lock the locks and get the status.

Let me know any feedback and I'll do my best to be responsive. I can plan to integrate into Hubitat Package Manager.

This will require you sign up for a TTLock API account.

3 Likes

Been using it for a while now. I adjusted it as well to add an "app" code to take incoming changes via the callback URL. (optional).

I just submitted to HPM for this, but keeping version at 0.9 for now. It works mostly for routines I have that act on unlocking a door for us when we come home.

Hi,

Love the concept. However when I use the app it has a blank callback url. Any ideas?

You just want to right-click and copy the URL that is "Remote URL". Or is that blank as well?
image

Morning, @x86cpu

Thank you. Have managed to now copy and paste that into the ttlock app i created on the ttlock website but no events are coming back. Does it work right away or does it take time?

Thanks

Dagaz

update some notifications come through. if you use the app it doesnt. if you use nfc or passcode it does. but a bit delayed. now a bit hit and miss, some come through others dont.

It is VERY delayed sometimes. Quite annoying, but overall works when polls. Also sometimes, my deadbolt is unlocked, but says locked via TTL API.

I use mine more for ensuring things are locked up or unlocked, which does work more real time if locking/unlocking things.

I have installed the drivers for ttlock on C8. I may not have done them correctly. I am unable to find where I actually control the lock. When i click on the virtual device i created, there is no option to lock or unlock the device. Is anyone able to help me on this? Thank You in advance.

You do need to make sure you have the TTL API registration. Have you done that part?

I did. I got the client id and client secret. I created a virtual device and entered everything in the device under preferences

There is a button I left on (Getlocks) which should retrieve them and create the child devices. If that does not do it, try enabling logging and see if any errors show up or anything to indicate if it found any locks.

Ok. I just completed that. Where do i go now to find the options to lock and unlock doors?

It should create Componet devices under the TTL Main device. That's where you can unlock/lock them.

If it did NOT create them, then you need to enabled debug logs and check the logs of the TTL device.

It is working now. Thank you very much for your help.

I just installed this and I can now see my lock. However I cannot find the URL information in either the parent or the child preference.

Also, the current state for lock always says locked, even when I know the lock is unlocked. Is this tied to not having the URL info or is this something different regarding the status. I see the poll is set to 5 mins by default. If I hit the refresh button, the status changes. Is a 5 min poll recommended?

The URL for the callback is in the "app" driver code, you'll need to get that installed and then pick which locks you want it to use.

The 5 min is a recommendation yes. There is a API limit from them. I have 4 locks. Each time it polls (5 min or whenever), it uses N-locks +1 for the API usage. It uses 1 for getting the list of locks, then uses another on each lock to set the status of that lock. The idea is to set it with enough to not run out of the free API credits they give.

Thanks. I got the TTLock user App installed and I see it at the top.

Has anyone experienced a huge battery drain when their smart lock is connected to their gateway?

In my first few days of using my smart lock, I connected it to the gateway and then to hubitat with this intergration. I started with new batteries, but my smart lock battery was draining 10% per day. After a few days, I removed the gateway and my battery has not dropped a single percentage in the last 3 or 4 days (I've been updating the status of the battery daily to verify)

I'm guessing it is the constant communication with the gateway that is draining the battery, but could that be due to the polling from the hubitat intergration as I currently have it set to 5 minutes, or could it be something else with the gateway and the official TTLock app. I could not find any polling setting within the official app so I am not yet sure what is/was cauing the huge battery drain.

The Hubitat integration appears to be polling a cloud server. Not the lock’s gateway in your house.

I have not had any battery drain issues using this. The cloud polls the gateway, not sure if the gateway try to poll the lock itself or not. I have mine set to 5 min and no 10% daily. I use rechargeable batteries too. So far it's been months and only 2 locks are down to 90% vs. the others still at 100%.