Note!: The following instruction is dedicated for the second generation of HTTP Gate module!

The manual shows how to integrate the Grenton system with Tedee lock. The integration is for API version 1.25 and is based on the information posted at:
https://tedee-tedee-api-doc.readthedocs-hosted.com/en/latest/index.html
https://api.tedee.com/

In the previous instruction (link) the ROPC authentication method was used - support for this method has been terminated. The following instruction presents the authentication with a personal key - Personal Access Key (PAK).


Tedee:

1. Integration should begin by creating an account, pairing the lock with a mobile device, calibrate the lock and control it from the dedicated application.

 

2. If the previously described steps have been performed correctly, you can proceed to obtain a Personal Access Key (PAK). Go to https://portal.tedee.com/ and log in to the mobile application.

 

3. Please note that the Personal Access Key (PAK) is assigned to your account and not to a specific lock!

 

After logging in click the icon in the upper right corner and select the "Personal access keys" option:


Note: The personal access key (PAK) is assigned to your account and not to a specific lock!


3. After logging in click the icon in the upper right corner and select the "Personal access keys" option:


4. If you are logging in for the first time, add a new key:


In order to generate a personal key, you need to specify its name, expiry time and the permissions it will have. 

(Check: Operate Lock, Device Read) 


Note: The maximum validity period of a Personal Key is 5 years!


After entering the required data and confirming it a window with a new key will appear:

Note: You can see the key only once, so be sure to save it. If you lose the key, you will need to create a new one.


Grenton:

For integration Tedee lock with Grenton system, follow these steps.


1. Create the following variables in the User features of the Gate HTTP module:


Note! The initial value of the tedee_PAK feature is the key previously copied from https://portal.tedee.com/.


Note! The initial value of the tedee_lock_sn feature is the serial number of your lock. This information is available in dedicated application: My devices -> Lock -> Settings -> Information.


2. Create a HttpRequest virtual object:

3. The settings for the TedeeLock_DeviceID virtual object that allows to get the lock ID are as follows:

where:
Host: https://api.tedee.com
Path: /api/v1.25/my/lock
QueryStringParams: \z


4. Create a Tedee_DeviceID_req script:

local key = "Authorization: PersonalKey " .. Gate_HTTP->tedee_PAK .. "\r\n"
Gate_HTTP->TedeeLock_DeviceID->SetRequestHeaders(key)
Gate_HTTP->TedeeLock_DeviceID->SendRequest()local key = "Authorization: PersonalKey " .. Gate_HTTP->tedee_PAK .. "\r\n"Gate_HTTP->TedeeLock_DeviceID->SetRequestHeaders(key)Gate_HTTP->TedeeLock_DeviceID->SendRequest()
C

5. Create a Tedee_DeviceID_resp script:

if(Gate_HTTP->TedeeLock_DeviceID->StatusCode==200) then 
local resp = Gate_HTTP->TedeeLock_DeviceID->ResponseBody
Gate_HTTP->tedee_lock_sn_get=resp.result[num].serialNumber

if(Gate_HTTP->tedee_lock_sn==Gate_HTTP->tedee_lock_sn_get) then
Gate_HTTP->tedee_lock_id = resp.result[num].id
else
Gate_HTTP->Tedee_DeviceID_resp(num+1)
end
end
C


where num variable is a parameter of this script:

Note! One Bridge and one Tedee lock were used in the shown example.


6. Assign this script with a num parameter value equal to 1 to the OnResponse event of the TedeeLock_DeviceID  virtual object:


7. By sending the configuration to the CLU and calling the Tedee_DeviceID_req script, the user features in the Gate module should take the appropriate values:


8. Next, we create another HttpRequest virtual object. The settings for the TedeeLock_LockID virtual object that allows to get information about the lock (such as device status, battery level, among other things) are as follows:

where:

Host: https://api.tedee.com
Path: /api/v1.25/my/lock/
QueryStringParams: \z


9. CreateTedee_LockID_req script:

local path_1 = "/api/v1.25/my/lock/" .. Gate_HTTP->tedee_lock_id .. "/sync"
Gate_HTTP->TedeeLock_LockID->SetPath(path_1)

local key = "Authorization: PersonalKey " .. Gate_HTTP->tedee_PAK .. "\r\n"
Gate_HTTP->TedeeLock_LockID->SetRequestHeaders(key)
Gate_HTTP->TedeeLock_LockID->SendRequest()
C

10. Create Tedee_LockID_resp script:

if(Gate_HTTP->TedeeLock_LockID->StatusCode==200) then   
local resp = Gate_HTTP->TedeeLock_LockID->ResponseBody
Gate_HTTP->tedee_lock_state = resp.result.lockProperties.state
Gate_HTTP->tedee_lock_charging = resp.result.lockProperties.isCharging
Gate_HTTP->tedee_lock_battery = resp.result.lockProperties.batteryLevel
end
C

11. Assign this script to the OnResponse event of the TedeeLock_LockID virtual object:


12. By sending the configuration to the CLU and calling the Tedee_DeviceID_req and then Tedee_LockID_req scripts, the User features in the Gate module should take the appropriate values:


13. Next, create another HttpRequest virtual object. The settings of the TedeeLock_Actions virtual object look as follows: where:

Host: https://api.tedee.com
Path: /api/v1.25/my/lock/
QueryStringParams: \z


14. Next, create the Tedee_Action_Open_req script, which when called after the configuration is submitted, will open the lock:

local path_1 = "/api/v1.25/my/lock/" .. Gate_HTTP->tedee_lock_id .. "/operation/unlock"
Gate_HTTP->TedeeLock_Actions->SetPath(path_1)

local key = "Authorization: PersonalKey " .. Gate_HTTP->tedee_PAK .. "\r\n"
Gate_HTTP->TedeeLock_Actions->SetRequestHeaders(key)
Gate_HTTP->TedeeLock_Actions->SendRequest()
C


15. Similarly, create the Tedee_Action_Close_req script, which when called after submitting the configuration, will close the lock:

local path_1 = "/api/v1.25/my/lock/" .. Gate_HTTP->tedee_lock_id .. "/operation/lock"
Gate_HTTP->TedeeLock_Actions->SetPath(path_1)

local key = "Authorization: PersonalKey " .. Gate_HTTP->tedee_PAK .. "\r\n"
Gate_HTTP->TedeeLock_Actions->SetRequestHeaders(key)
Gate_HTTP->TedeeLock_Actions->SendRequest()
C


16. Next, create the Tedee_Action_Pull_req script, which, when called after the configuration is uploaded, will pull back the latch when the door is open:

local path_1 = "/api/v1.25/my/lock/" .. Gate_HTTP->tedee_lock_id .. "/operation/pull"
Gate_HTTP->TedeeLock_Actions->SetPath(path_1)

local key = "Authorization: PersonalKey " .. Gate_HTTP->tedee_PAK .. "\r\n"
Gate_HTTP->TedeeLock_Actions->SetRequestHeaders(key)
Gate_HTTP->TedeeLock_Actions->SendRequest()
C


17. Finally, assign the Tedee_DeviceID_req script call to the OnInit event in the Gate Http module:


18. And place the call to the Tedee_LockID_req script in the Tedee_DeviceID_resp script:

if(Gate_HTTP->TedeeLock_DeviceID->StatusCode==200) then 
local resp = Gate_HTTP->TedeeLock_DeviceID->ResponseBody
Gate_HTTP->tedee_lock_sn_get=resp.result[num].serialNumber

if(Gate_HTTP->tedee_lock_sn==Gate_HTTP->tedee_lock_sn_get) then
Gate_HTTP->tedee_lock_id = resp.result[num].id
Gate_HTTP->Tedee_DeviceID_resp()
else
Gate_HTTP->Tedee_DeviceID_resp(num+1)
end
end


19. The configuration created this way is sent to the Gate HTTP module.


How to control Tedee lock using myGrenton application is presented in the following article:

Control with Tedee lock (PAK)