Last Updated on : 2023-06-15 05:25:34
This topic describes how to integrate with open capabilities of elevator control devices.
For more information about data points, see Modify Data Point.
Data point code | Description |
---|---|
face_lift | Take an elevator by face recognition. |
qrcode_lift | Take an elevator by scanning a QR code. |
out_lift | Support hall call. |
unify_lift | Call an elevator by car call and hall call. The elevator status is reported, including the elevator shaft, the current floor where the elevator car stops, and the traveling direction. |
out_auth | Call an elevator by car call and hall call. The elevator status is not reported. |
public_lift | The elevator car can stop at public floors that do not require authorization. |
API name | API endpoint |
---|---|
Delete Person | DELETE:/v1.0/elevator-control/{device_id}/persons/{person_id} |
Update Person | PUT:/v1.0/elevator-control/{device_id}/persons/{person_id} |
Add Person | POST:/v1.0/elevator-control/{device_id}/persons/{person_id} |
API name | API endpoint |
---|---|
Delete Face | DELETE:/v1.0/elevator-control/{device_id}/persons/{person_id}/faces/{face_id} |
Add Face | POST:/v1.0/elevator-control/{device_id}/persons/{person_id}/faces/{face_id} |
Update Face | PUT:/v1.0/elevator-control/{device_id}/persons/{person_id}/faces/{face_id} |
API name | API endpoint |
---|---|
Unfreeze Elevator Control Card | PUT:/v1.0/elevator-control/{device_id}/persons/{person_id}/card/{card_no}/unfreeze |
Freeze Elevator Control Card | PUT:/v1.0/elevator-control/{device_id}/persons/{person_id}/card/{card_no}/freeze |
Add Elevator Control Card | POST:/v1.0/elevator-control/{device_id}/persons/{person_id}/card/{card_no} |
Delete Elevator Control Card | DELETE:/v1.0/elevator-control/{device_id}/persons/{person_id}/card/{card_no} |
API name | API endpoint |
---|---|
Send Elevator Call Command | POST:/v1.0/elevator-control/{device_id}/persons/{person_id}/actions/call |
API name | API endpoint |
---|---|
Delete QR Code | DELETE:/v1.0/elevator-control/{device_id}/persons/{person_id}/qrcodes/{qr_code} |
Update QR Code | PUT:/v1.0/elevator-control/{device_id}/persons/{person_id}/qrcodes/{qr_code} |
Add QR Code | POST:/v1.0/elevator-control/{device_id}/persons/{person_id}/qrcodes/{qr_code} |
After you subscribe to the message service for a cloud development project, you will receive event messages from the linked elevator control devices. For more information about the integration with a message queue, see Message Queue.
When an elevator control device is triggered, the party who performs the integration process will be notified of the pass event. The event code is pass_event
.
value
Parameter | Type | Description | Required |
---|---|---|---|
uid | String | The ID of a specified person. Specify -1 for a stranger. |
Yes |
way | Integer | The elevator control methods. Valid values:
|
Yes |
t | Long | The 13-digit timestamp of the time when a person passes. | Yes |
success | Integer | Indicates whether the operation is successful. Valid values:
|
Yes |
message | String | The description of a specified passing event. In case of a failure, an error message will be returned. | No |
picUrl | String | The temporary URL of a photo taken when a person passes. This photo is taken by the device when a person passes. This photo can be downloaded through the URL. | No |
temp | String | The body temperature. | No |
startFloor | Integer | The floor on which the elevator starts. | No |
endFloor | Integer | The floor at which the elevator arrives. | No |
lifeNum | Integer | The serial number of a specified elevator shaft. | No |
extend | String | The extension field. | No |
{
"dataId": "AAXRV4BrtW9BRB9A2JYW****",
"devId": "6ca****",
"productKey": "e6rz6vba81wm****",
"status": [
{
"12": "{\"message\":\"ok\",\"success\":1,\"t\":1637548630452,\"uid\":\"zs123\",\"way\":4}",
"code": "pass_event",
"t": 1637548630455,
"value": "{\"message\":\"ok\",\"success\":1,\"t\":1637548630452,\"uid\":\"zs123\",\"way\":1}"
}
]
}
Report the elevator status, including the elevator shaft, the current floor where the elevator car stops, and the traveling direction. The event code is function_data
.
Parameter | Type | Description | Required |
---|---|---|---|
shaftList | List |
A list of elevator cars. | Yes |
ElevatorShaftDTO
Parameter | Type | Description | Required |
---|---|---|---|
lifeNum | Integer | The serial number of a specified elevator shaft. | No |
status | Integer | The status of a specified elevator. Valid values:
|
No |
direction | Integer | The traveling direction of a specified elevator. Valid values:
|
No |
curFloor | Integer | The current floor. It must be a physical floor. | No |
{
"dataId": "AAXRV4BrtW9BRB9A2JYW****",
"devId": "6ca****",
"productKey": "e6rz6vba81wm****",
"status": [
{
"6": "{\"shaftList\":[{\"lifeNum\":1,\"curFloor\":1,\"direction\":0,\"status\":1},{\"lifeNum\":2,\"curFloor\":1,\"direction\":0,\"status\":1}]}",
"code": "function_data",
"t": 1637548630455,
"value": "{\"shaftList\":[{\"lifeNum\":1,\"curFloor\":1,\"direction\":0,\"status\":1},{\"lifeNum\":2,\"curFloor\":1,\"direction\":0,\"status\":1}]}"
}
]
}
Currently, QR codes are classified into static QR codes and dynamic QR codes.
The QR code content format is shown as follows:
{
"qrcode": "7kCzIejJVhfwYOGGJLr1iUUPRXP69AiNMGcMhowRSVA=" // value: Base64 encoded string
}
Generate a static QR code in the following steps.
Sample:
User ID: ay16110581781387****
QR code content: 46bff10b9bf843fab194cf246bfedda8
Perform Base64 encoding of "ay16110581781387****|46bff10b9bf843fab194cf246bfedda8".
The resulting string is as follows:
YXkxNjExMDU4MTc4MTM4N240Mjd8NDZiZmYxMGI5YmY4NDNmYWIxOTRjZjI0NmJmZWRkYTg=
The QR code content is shown as follows:
{
"qrcode": "YXkxNjExMDU4MTc4MTM4N240Mjd8NDZiZmYxMGI5YmY4NDNmYWIxOTRjZjI0NmJmZWRkYTg="
}
Generate a dynamic QR code in the following steps.
generateTOTP
method.Sample code of the generateTOTP
method:
/**
* Generate a dynamic QR code
*
* @param uid Tuya user ID
* @param secretKey The secret key, a 32-digit string. It is recommended to be generated by the UUID.
* @param refreshTime The refresh time of a QR code
* @return
*/
public static TOTPTokenCodeDTO generateTOTP(String uid, String secretKey, Long refreshTime) {
if (StringUtils.isBlank(uid) || StringUtils.isBlank(secretKey) || refreshTime == null) {
log.error("Request parameter error, uid:{}, secretKey:{}, refreshTime:{}", uid, secretKey, refreshTime);
throw new RuntimeException("Request parameter error");
}
// Get the timestamp of the current time
long now = new Date().getTime();
// Convert the dynamic factor to hexadecimal
String time = Long.toHexString(timeFactor(now, refreshTime)).toUpperCase();
String totp = doGenerateTOTP(uid + secretKey, time);
// The duration after the dynamic code is generated in this cycle
long usedTime = validTime(now, refreshTime);
return new TOTPTokenCodeDTO(totp, usedTime);
}
/**
* @param key The user ID + seed key
* @param time The time factor
* @return
*/
private static String doGenerateTOTP(String key, String time) {
// 1. If the time is less than 16 characters, pad it with zeros. Example: 30B649C -> 00000000030B649C
StringBuilder timeBuilder = new StringBuilder(time);
while (timeBuilder.length() < 16) {
timeBuilder.insert(0, "0");
}
time = timeBuilder.toString();
// 2. Convert hexadecimal format to binary format
byte[] msg = hexStr2Bytes(time);
// 3. Convert the key to bytes
byte[] k = key.getBytes();
// 4. Hash encryption
byte[] hash = hmac_sha("HmacSHA256", k, msg);
// 5. Return a dynamic password of the specified number of digits
String encodeHexStr = Hex.encodeHexString(hash);
StringBuilder result = new StringBuilder(encodeHexStr);
// 6. If the returned value is less than the specified number of digits, pad it with 0
while (result.length() < 8) {
result.insert(0, "0");
}
return result.substring(0, 8);
}
/**
* Get the dynamic factor
*
* @param targetTime The specified time
* @param refreshTime The time step in milliseconds, as the refresh interval of the dynamic password
* @return long
*/
private static long timeFactor(Long targetTime, long refreshTime) {
return targetTime / refreshTime;
}
/**
// Get the duration after the dynamic code is generated in this cycle
*
* @param targetTime
* @param refreshTime
* @return
*/
private static long validTime(long targetTime, long refreshTime) {
return targetTime % refreshTime;
}
/**
* Hash encryption
*
* @param crypto The encryption algorithm
* @param keyBytes The key array
* @param text The encrypted content
* @return byte[]
*/
private static byte[] hmac_sha(String crypto, byte[] keyBytes, byte[] text) {
try {
Mac hmac;
hmac = Mac.getInstance(crypto);
SecretKeySpec macKey = new SecretKeySpec(keyBytes, "AES");
hmac.init(macKey);
return hmac.doFinal(text);
} catch (GeneralSecurityException gse) {
throw new RuntimeException(gse);
}
}
private static byte[] hexStr2Bytes(String hex) {
byte[] sourceArray = new BigInteger("10" + hex, 16).toByteArray();
byte[] targetArray = new byte[sourceArray.length - 1];
// Copy and paste the original array to the target array
// src: the source array. srcPos: the starting position of the source array to be copied. dest: the target array. destPos: the starting position of the target array to be copied. length: the length to be copied.
System.arraycopy(sourceArray, 1, targetArray, 0, targetArray.length);
return targetArray;
}
Sample:
User ID: ay16110581781387****
Secret key: 46bff10b9bf843fab194cf246bfedda8
QR code refresh time: 5 × 60 × 1000
The QR code information generated by the `generateTOTP` method: e4af****
Perform Base64 encoding of `ay16110581781387****|e4af23e6`.
The resulting string is as follows:
7kCzIejJVhfwYOGGJLr1iUUPRXP69AiNMGcMhowRSVA=
The QR code content is shown as follows:
{
"qrcode": "7kCzIejJVhfwYOGGJLr1iUUPRXP69AiNMGcMhowRSVA="
}
Device event messages are compatible with v1.0 format. If you want to subscribe to the v1.0 format, please contact Tuya’s staff. For more information about the integration process, see Device event format v1.0.
When an elevator control device is triggered, you will be notified of the pass event.
Parameter name | Data type | Description | Required |
---|---|---|---|
bizCode | String | The business code of a specified event. Default value: edge_device . |
Yes |
eventType | String | The type of a specified event. Default value: edge_report_data . |
Yes |
mode | String | The mode of a specified event. Default value: elevator-pass . |
Yes |
deviceId | String | The ID of a specified Tuya device. | Yes |
uid | String | The ID of a specified person that passes the access control device. Specify -1 for a stranger. |
Yes |
way | Integer | The access control method. Valid values:
|
Yes |
t | Long | The 13-digit timestamp of the time when a person passes. | Yes |
success | Integer | Indicates whether the operation is successful. Valid values:
|
Yes |
message | String | The description of a specified access control event. In case of a failure, an error message will be returned. | No |
passUrl | String | The temporary URL of a photo taken when a person passes. This photo can be downloaded through the URL. | No |
temp | String | The body temperature. | No |
startFloor | Integer | The floor on which the elevator starts. | No |
endFloor | Integer | The floor at which the elevator arrives. | No |
lifeNum | Integer | The serial number of a specified elevator shaft. | No |
extend | String | The extension field. | No |
{
"data": "{\"mode\":\"elevator-pass\",\"data\":\"{\\\"deviceId\\\":\\\"002dj00118fe34d9****\\\",\\\"t\\\":1612514362591,\\\"message\\\":\\\"success\\\",\\\"passUrl\\\":\\\"http://www.xxx.com/image.jpg\\\",\\\"uid\\\":\\\"ay16110581781387n***\\\",\\\"way\\\":4}\",\\\"success\\\":1}\"}",
"bizCode": "edge_device",
"eventType": "edge_report_data"
}
Is this page helpful?
YesFeedbackIs this page helpful?
YesFeedback