i used the ttlock api to establish this. if you like i can help
1st step you’ll need a developer account and it must be reviewed.
once its reviewed you’ll need to send the client_id, client_secret, grant_type, a new username, a new password, and a redirect url… this can be done with a simple html form
Access token<br>
<form action="https://api.sciener.com/oauth2/token" method="post" enctype="application/x-www-form-urlencoded">
<input type="text" name="client_id" value="your app id"><br>
<input type="text" name="client_secret" value="your app secret"><br>
<input type="text" name="grant_type" value="password"><br>
<input type="text" name="username" value="your new username"><br>
<input type="text" name="password" value="your new password"><br>
<input type="text" id="lname" name="redirect_uri" value="https://home assistant address/auth/authorize"><br>
<input type="submit" value="Submit">
</form>
when you do this it will give you a access token and refresh token
KEEP THIS SAFE!!!
you will need the access token to make rest calls to the api
to get the last user who unlocked the door i used a sensor
sensor:
- platform: rest
name: "unlock name"
scan_interval: 5
resource_template: https://api.ttlock.com/v3/lockRecord/list?clientId= your client id/app id &accessToken= your access token &lockId= your lock id number &pageNo=1&pageSize=1&date={{ (now().timestamp() | int * 1000 ) }}
value_template: '{{ value_json.list[0].username }}'
the api doc has all the information from here.