Everything about the TTLock access type that was developed
We mainly use 3 functions so far
This function is fairly simple, but you need a couple of things to access it.
We just generate a random 6 digit code and call this function with the password name to be the bookingId and the access code is hopefully saved.
All the dates need to be added in milliseconds
After the password became valid, after start time, the user has to enter within the first 24 hours, otherwise the passcode becomes invalid.
API documented in Postman
This is also simple, I just call the endpoint with all the data that is saved in the access database and it will update everything automatically.
One tricky thing is that might cause errors in the future is that when it finishes to update, it will return the errorcode 0, but the operation was successful.
The error code
However this is also returned if you tried to delete a passcode with an id that was already deleted or probably also with an id that never existed, so it might lead to some errors in the future, but I have no idea how to check it. One solution could be to check whether an id exists before doing anything, but that would be computationally inefficient.
Documented in Postman
We just need the password id to delete it, but the same problem is there as with the last change passcode function, namely that you can delete something twice or something that never existed and it will still show a success.
Docs in Postman
Log entry function
When someone tries to enter into a lock, either successfully or unsuccessfully, data will be sent to one cloud function endpoint specified here.
This is the logSuccessfullEntry function that gets the data. With this we can find the bookind id based on the user name of the user, then write into the access collection in the database. There is a log written and a new array entry in the entered array.
The data that we get look like this:
{ "lockId": "9226705", "lockMac": "FD:FE:2E:63:F5:51", "notifyType": "1", "admin": "jh@jobelhome.com", "records": "[{\"lockId\":9226705,\"electricQuantity\":98,\"serverDate\":1717182097828,\"recordTypeFromLock\":4,\"recordType\":4,\"success\":1,\"lockMac\":\"FD:FE:2E:63:F5:51\",\"keyboardPwd\":\"271071\",\"lockDate\":1717182150000,\"username\":\"240531-240602-55797830\"}]" }Ttlock
Ttlock gateway
USB C charger
3 pieces of AAA Battery
screwdriver for the door
Download the TTLock application
From the Jobelhome keepass get the email and password for sign in, it is inside the 100 Platforms -> TTlock app entry
Add the lock to the app, by turning on Bluetooth and connecting, the process should be pretty easy
The only thing that we need from the lock to be able to access it from far away is to be connected to the Jobelhome account and to have the lockId. Once you connected the lock to the app, it is easy to get the lockId
Get lockId in TTLock APP 's lock basics page (Settings->Basics),as shown in screenshot below:
In the config file in git, you need to add this JSON object
"access": {
"accessType": "TTLOCK",
"accessConfigInfo": {
"clientId": "aaaaaaa",
"accessToken": "aaaaaaa",
"lockId": "00000",
"clientSecret": "aaaaaa",
"refresh_token": "aaaaaa"
}
},
You can get the clientId and clientSecret from the config if there are already other properties under this account.
If not you can create a new account for a new owner, you just go here, create an application and wait for a few days. Then you can copy the clientId and clientSecret from there.
The accessToken and refresh_token you can get with the Postman, go to this URL, the Get access token request, and get both tokens at once. To use it you will have to hash the password that you got from Keepass with a tool like this.
The lockId you can get from the previous step in the app.
The accessToken expires every 90 days, currently the code does not handle the creation of a new access token based on a refresh token, I will fix that, but if there is an issue with that the access token can be generated like in previous
step.
Register a user on the TTlock Platform https://euopen.ttlock.com/login
Once registered, create an application. This application is for TTlock so they know what our application is about, it is necessary so we can get access to the API
The type of the application should be Web, otherwise it shouldn't matter what is written there. The approval process should take a couple of days, for me it took a day.
Once done, copy the client_id and the client_secret, and send these to the developer setting up the platform.