English
English
简体中文
Contact Us
Register
Log In
layoutIndex

Smart Lock Basic API

Last Updated on : 2022-10-21 08:22:09download

Smart lock basic API encapsulates common methods regarding offline passwords, online passwords, member management, and more features. These methods apply to smart devices such as camera locks and smart video locks.

Functional description

Class name Description
TuyaSmartLockApi Smart lock class that encapsulates basic API methods.

Offline passwords

API description

Checks whether the current type of password can be repeatedly used. This API method applies to camera locks and smart video locks.

- (void)isCurrentOfflinePasswordAvailableWithDevId:(NSString *)devId
                                           pwdType:(NSInteger)pwdType
                                           success:(TYSuccessID)success
                                           failure:(nullable TYFailureError)failure;

Parameters

Parameter Description
devId The device ID.
pwdType The type of password. Valid values:
  • 0: a password that can be used as many times as needed before it expires
  • 1: a one-time password
  • 9: a clearing code
success The success callback.
failure The failure callback.

Example

- (void)isCurrentOfflinePasswordAvailableAPITest{
    [self.lockAPI isCurrentOfflinePasswordAvailableWithDevId:@"6ce91a406cebe66b1f1gep"
                                                     pwdType:1
                                                     success:^(id result) {
						//TODO
    } failure:^(NSError *error) {
						//TODO
    }];
}

API description

Returns a list of offline passwords. This API method applies to camera locks and smart video locks.

- (void)getOfflinePasswordListWithDevId:(NSString *)devId
                                pwdType:(NSString *)pwdType
                                 status:(NSInteger)status
                                 offset:(NSInteger)offset
                                  limit:(NSInteger)limit
                                success:(TYSuccessID)success
                                failure:(nullable TYFailureError)failure;

Parameters

Parameter Description
devId The device ID.
pwdType The type of password. Valid values:
  • 0: a password that can be used as many times as needed before it expires
  • 1: a one-time password
  • 9: a clearing code
status The status of the password.
  • 1: generated to be used
  • 0: already used once
  • -1: expired
offset The page number.
limit The maximum number of entries to be returned per page. Default value: 50.
success The success callback.
failure The failure callback.

Example

- (void)getOfflinePasswordListAPITest{
    [self.lockAPI getOfflinePasswordListWithDevId:@"6c05de1dbb2e4fef15z4va"
                                          pwdType:@"0,1,9"
                                           status:-1
                                           offset:0
                                            limit:20
                                          success:^(id result) {
						//TODO
    } failure:^(NSError *error) {
						//TODO
    }];
}

API description

Returns a list of available offline passwords that can be used unlimited times. This API method applies to camera locks and smart video locks.

- (void)getReavailableOfflinePasswordWithDevId:(NSString *)devId
                                       success:(TYSuccessID)success
                                       failure:(nullable TYFailureError)failure;

Parameters

Parameter Description
devId The device ID.
success The success callback.
failure The failure callback.

Example

- (void)getReavailableOfflinePasswordAPITest{
    [self.lockAPI getReavailableOfflinePasswordWithDevId:@"6ce91a406cebe66b1f1gep"
                                                 success:^(id result) {
						//TODO
    }
                                                 failure:^(NSError *error) {
						//TODO
    }];
}

API description

Adds an offline temporary password. This API method applies to camera locks only. Product code: wf_jtmspro.

- (void)addPhotoLockOfflinePasswordWithDevId:(NSString *)devId
                                     pwdType:(NSString *)pwdType
                                    gmtStart:(NSInteger)gmtStart
                                  gmtExpired:(NSInteger)gmtExpired
                                     pwdName:(NSString *)pwdName
                                 countryCode:(NSString *)countryCode
                                      mobile:(NSString *)mobile
                                     success:(TYSuccessID)success
                                     failure:(nullable TYFailureError)failure;

Parameters

Parameter Description
devId The device ID.
pwdType The type of password. Valid values:
  • 0: a password that can be used as many times as needed before it expires
  • 1: a one-time password
  • 9: a clearing code
gmtStart The start time of the validity period.
gmtExpired The end time of the validity period.
pwdName The password name.
countryCode The country code of the mobile phone number for the lock user.
mobile The mobile phone number.
success The success callback.
failure The failure callback.

Example

- (void)addPhotoLockOfflinePasswordAPITest{
    [self.lockAPI addPhotoLockOfflinePasswordWithDevId:@"6ce91a406cebe66b1f1gep"
                                               pwdType:@"1"
                                              gmtStart:0
                                            gmtExpired:[[NSDate date] timeIntervalSince1970]
                                               pwdName:@"kandi test"
                                           countryCode:@""
                                                mobile:@""
                                               success:^(id result) {
						//TODO
    } failure:^(NSError *error) {
						//TODO
    }];
}

API description

Names an offline password. This API method applies to camera locks only. Product code: wf_jtmspro.

- (void)setPhotoLockOfflinePasswordNameWithDevId:(NSString *)devId
                                           pwdId:(NSInteger )pwdId
                                         pwdName:(NSString *)pwdName
                                          mobile:(NSString *)mobile
                                         success:(TYSuccessID)success
                                         failure:(nullable TYFailureError)failure;

Parameters

Parameter Description
devId The device ID.
pwdId The password ID.
pwdName The password name.
mobile The mobile phone number.
success The success callback.
failure The failure callback.

Example

- (void)setPhotoLockOfflinePasswordNameAPITest{
    [self.lockAPI setPhotoLockOfflinePasswordNameWithDevId:@"6ce91a406cebe66b1f1gep"
                                                     pwdId:3586192
                                                   pwdName:@"CESHIxxx"
                                                    mobile:@""
                                                   success:^(id result) {
						//TODO
    } failure:^(NSError *error) {
						//TODO
    }];
}

API description

Returns the clearing code of a specified offline temporary password. This API method applies to camera locks only. Product code: wf_jtmspro.

- (void)getPhotoLockOfflineEmptyCodeWithDevId:(NSString *)devId
                                        pwdId:(NSInteger )pwdId
                                      success:(TYSuccessID)success
                                      failure:(nullable TYFailureError)failure;

Parameters

Parameter Description
devId The device ID.
pwdId The password ID.
success The success callback.
failure The failure callback.

Example

- (void)getPhotoLockOfflineEmptyCodeAPITest{
    [self.lockAPI getPhotoLockOfflineEmptyCodeWithDevId:@"6ce91a406cebe66b1f1gep"
                                                  pwdId:3586192
                                                success:^(id result) {
						//TODO
    } failure:^(NSError *error) {
						//TODO
    }];
}

API description

Adds an offline temporary password. This API method applies to smart video locks only. Product code: videolock_1w_1.

- (void)addVideoLockOfflinePasswordWithDevId:(NSString *)devId
                                     pwdType:(NSString *)pwdType
                                    gmtStart:(NSInteger)gmtStart
                                  gmtExpired:(NSInteger)gmtExpired
                                     pwdName:(NSString *)pwdName
                                 countryCode:(NSString *)countryCode
                                      mobile:(NSString *)mobile
                                     success:(TYSuccessID)success
                                     failure:(nullable TYFailureError)failure;

Parameters

Parameter Description
devId The device ID.
pwdType The type of password. Valid values:
  • 0: a password that can be used as many times as needed before it expires
  • 1: a one-time password
  • 9: a clearing code
gmtStart The start time of the validity period.
gmtExpired The end time of the validity period.
pwdName The password name.
countryCode The country code of the mobile phone number for the lock user.
mobile The mobile phone number.
success The success callback.
failure The failure callback.

Example

- (void)addVideoLockOfflinePasswordAPITest{
    [self.lockAPI addVideoLockOfflinePasswordWithDevId:@"6c05de1dbb2e4fef15z4va"
                                               pwdType:@"1"
                                              gmtStart:0
                                            gmtExpired:[[NSDate date] timeIntervalSince1970]
                                               pwdName:@"KANDI TEST xxx"
                                           countryCode:@""
                                                mobile:@""
                                               success:^(id result) {
						//TODO
    } failure:^(NSError *error) {
						//TODO
    }];
}

API description

Names an offline password. This API method applies to smart video locks only. Product code: videolock_1w_1.

- (void)setVideoLockOfflinePasswordNameWithDevId:(NSString *)devId
                                 unlockBindingId:(NSInteger )unlockBindingId
                                         pwdName:(NSString *)pwdName
                                         success:(TYSuccessID)success
                                         failure:(nullable TYFailureError)failure;

Parameters

Parameter Description
devId The device ID.
unlockBindingId The password ID.
pwdName The password name.
success The success callback.
failure The failure callback.

Example

- (void)setVideoLockOfflinePasswordNameAPITest{
    [self.lockAPI setVideoLockOfflinePasswordNameWithDevId:@"6c05de1dbb2e4fef15z4va"
                                           unlockBindingId:5684380
                                                   pwdName:@"KANDI TEST"
                                                   success:^(id result) {
       //TODO
    } failure:^(NSError *error) {
       //TODO
    }];
}

API description

Returns the clearing code of a specified offline temporary password. This API method applies to smart video locks only. Product code: videolock_1w_1.

- (void)getVideoLockOfflineEmptyCodeWithDevId:(NSString *)devId
                              unlockBindingId:(NSInteger )unlockBindingId
                                         name:(NSString *)name
                                      success:(TYSuccessID)success
                                      failure:(nullable TYFailureError)failure;

Parameters

Parameter Description
devId The device ID.
unlockBindingId The password ID.
name The name of the clearing code.
success The success callback.
failure The failure callback.

Example

- (void)getVideoLockOfflineEmptyCodeAPITest{
    [self.lockAPI getVideoLockOfflineEmptyCodeWithDevId:@"6c05de1dbb2e4fef15z4va"
                                        unlockBindingId:5694232
                                                   name:@"KANDI TEST"
                                                success:^(id result) {
       //TODO
    } failure:^(NSError *error) {
       //TODO
    }];
}

Online passwords

API description

Returns a list of online temporary passwords. This API method applies to camera locks only. Product code: wf_jtmspro.

- (void)getPhotoLockTemporaryPasswordWithDevId:(NSString *)devId
                                       success:(TYSuccessID)success
                                       failure:(nullable TYFailureError)failure;

Parameters

Parameter Description
devId The device ID.
success The success callback.
failure The failure callback.

Example

- (void)getPhotoLockTemporaryPasswordAPITest{
    [self.lockAPI getPhotoLockTemporaryPasswordWithDevId:@"6ce91a406cebe66b1f1gep"
                                                 success:^(id result) {
       //TODO
    } failure:^(NSError *error) {
       //TODO
    }];
}

API description

Returns the serial number of a smart video lock. This API method applies to smart video locks only. Product code: videolock_1w_1.

- (void)getVideoLockSnNumberWithDevId:(NSString *)devId
                                 dpId:(NSInteger)dpId
                              success:(TYSuccessID)success
                              failure:(nullable TYFailureError)failure;

Parameters

Parameter Description
devId The device ID.
dpId The value of dpId for an unlocking method.
success The success callback.
failure The failure callback.

Example

- (void)getVideoLockSnNumberAPITest{
    [self.lockAPI getVideoLockSnNumberWithDevId:@"6c05de1dbb2e4fef15z4va"
                                           dpId:69
                                        success:^(id result) {
       //TODO
    } failure:^(NSError *error) {
       //TODO
    }];
}

API description

Returns a list of online temporary passwords. This API method applies to smart video locks only. Product code: videolock_1w_1.

- (void)getVideoLockTemporaryPasswordWithDevId:(NSString *)devId
                                     authTypes:(NSArray *)authTypes
                                       success:(TYSuccessID)success
                                       failure:(nullable TYFailureError)failure;

Parameters

Parameter Description
devId The device ID.
authTypes The authorization type.
success The success callback.
failure The failure callback.

Example

- (void)getVideoLockTemporaryPasswordAPITest{
    [self.lockAPI getVideoLockTemporaryPasswordWithDevId:@"6c05de1dbb2e4fef15z4va"
                                               authTypes:@[@"LOCK_OFFLINE_TEMP_PWD",@"LOCK_TEMP_PWD"]
                                                 success:^(id result) {
						//TODO
    } failure:^(NSError *error) {
						//TODO
    }];
}

API description

Adds an online temporary password. This API method applies to camera locks only. Product code: wf_jtmspro.

- (void)addPhotoLockTemporaryPasswordWithDevId:(NSString *)devId
                                          name:(NSString *)name
                                         phone:(NSString *)phone
                                 effectiveTime:(NSInteger)effectiveTime
                                   invalidTime:(NSInteger)invalidTime
                                      password:(NSString *)password
                                      schedule:(NSString *)schedule
                                   countryCode:(NSString *)countryCode
                                     availTime:(NSInteger)availTime
                                       success:(TYSuccessID)success
                                       failure:(nullable TYFailureError)failure;

Parameters

Parameter Description
devId The device ID.
name The password name.
phone The mobile phone number.
effectiveTime The start time of the validity period.
invalidTime The end time of the validity period.
password The password.
schedule The schedule in which the password can be used.
countryCode The country code of the mobile phone number for the lock user.
availTime The number of times the password can be used.
success The success callback.
failure The failure callback.

Example

- (void)addPhotoLockTemporaryPasswordAPITest{
    [self.lockAPI addPhotoLockTemporaryPasswordWithDevId:@"6ce91a406cebe66b1f1gep"
                                                    name:@"pwd1111"
                                                   phone:@""
                                           effectiveTime:1659333273374
                                             invalidTime:1659938073374
                                                password:@"1234567"
                                                schedule:@"[{\"allDay\":true,\"effectiveTime\":360,\"invalidTime\":1080,\"workingDay\":127}]"
                                             countryCode:@"86"
                                               availTime:0
                                                 success:^(id result) {
       //TODO
    } failure:^(NSError *error) {
       //TODO
    }];
}

API description

Adds an online temporary password. This API method applies to smart video locks only. Product code: videolock_1w_1.

- (void)addVideoLockTemporaryPasswordWithDevId:(NSString *)devId
                                          name:(NSString *)name
                                      password:(NSString *)password
                                 effectiveTime:(NSInteger)effectiveTime
                                   invalidTime:(NSInteger)invalidTime
                                     availTime:(NSInteger)availTime
                                            sn:(NSInteger)sn
                                      schedule:(NSString *)schedule
                                      symbolic:(BOOL)symbolic
                                      dpTunnel:(NSInteger)dpTunnel
                                       success:(TYSuccessID)success
                                       failure:(nullable TYFailureError)failure;

Parameters

Parameter Description
devId The device ID.
name The password name.
password The password content.
effectiveTime The start time of the validity period.
invalidTime The end time of the validity period.
availTime The number of times the password can be used.
sn The serial number of the temporary password.
schedule The schedule in which the password can be used.
symbolic Specifies whether a data point (DP) needs to be sent.
dpTunnel The channel through which a DP is sent. Valid values:
  • 1: The app sends the DP.
  • 2: The cloud sends the DP.
  • 3: The app or cloud sends the DP.
success The success callback.
failure The failure callback.

Example

- (void)addVideoLockTemporaryPasswordAPITest{
    [self.lockAPI addVideoLockTemporaryPasswordWithDevId:@"6c05de1dbb2e4fef15z4va"
                                                    name:@"kandi-1"
                                                password:@"5678212"
                                           effectiveTime:1659333273
                                             invalidTime:1659938073
                                               availTime:0
                                                      sn:41
                                                schedule:@"[{\"allDay\":true,\"effectiveTime\":360,\"invalidTime\":1080,\"workingDay\":127}]"
                                                symbolic:NO
                                                dpTunnel:2
                                                 success:^(id result) {
						//TODO
    } failure:^(NSError *error) {
						//TODO
    }];
}

API description

Renames a temporary password. This API method applies to camera locks only. Product code: wf_jtmspro.

- (void)updatePhotoLockTemporaryPasswordNameWithDevId:(NSString *)devId
                                                pwdId:(NSInteger )pwdId
                                                 name:(NSString *)name
                                              success:(TYSuccessID)success
                                              failure:(nullable TYFailureError)failure;

Parameters

Parameter Description
devId The device ID.
pwdId The password ID.
name The new name of the password.
success The success callback.
failure The failure callback.

Example

- (void)updatePhotoLockTemporaryPasswordNameAPITest{
    [self.lockAPI updatePhotoLockTemporaryPasswordNameWithDevId:@"6ce91a406cebe66b1f1gep"
                                                          pwdId:4575053
                                                           name:@"kandi-test-1"
                                                        success:^(id result) {
						//TODO
    } failure:^(NSError *error) {
						//TODO
    }];
}

API description

Renames a temporary password. This API method applies to smart video locks only. Product code: videolock_1w_1.

- (void)updateVideoLockTemporaryPasswordNameWithDevId:(NSString *)devId
                                      unlockBindingId:(NSInteger )unlockBindingId
                                                 name:(NSString *)name
                                              success:(TYSuccessID)success
                                              failure:(nullable TYFailureError)failure;

Parameters

Parameter Description
devId The device ID.
unlockBindingId The password ID.
name The new name of the password.
success The success callback.
failure The failure callback.

Example

- (void)updateVideoLockTemporaryPasswordNameAPITest{
    [self.lockAPI updateVideoLockTemporaryPasswordNameWithDevId:@"6c05de1dbb2e4fef15z4va"
                                                unlockBindingId:5664269
                                                           name:@"kandi-test-1"
                                                        success:^(id result) {
						//TODO
    } failure:^(NSError *error) {
						//TODO
    }];
}

API description

Deletes a temporary password. This API method applies to camera locks and legacy all-in-one smart locks. Product code: wf_jtmspro and wf_ms.

- (void)deletePhotoLockTemporaryPasswordWithDevId:(NSString *)devId
                                            pwdId:(NSInteger )pwdId
                                          success:(TYSuccessID)success
                                          failure:(nullable TYFailureError)failure;

Parameters

Parameter Description
devId The device ID.
pwdId The password ID.
success The success callback.
failure The failure callback.

Example

- (void)deletePhotoLockTemporaryPasswordAPITest{
    [self.lockAPI deletePhotoLockTemporaryPasswordWithDevId:@"6ce91a406cebe66b1f1gep"
                                                      pwdId:4575053
                                                    success:^(id result) {
						//TODO
    } failure:^(NSError *error) {
						//TODO
    }];
}

API description

Deletes a temporary password. This API method applies to smart video locks only. Product code: videolock_1w_1.

- (void)deleteVideoLockTemporaryPasswordWithDevId:(NSString *)devId
                                  unlockBindingId:(NSInteger )unlockBindingId
                                         symbolic:(BOOL)symbolic
                                         dpTunnel:(NSInteger)dpTunnel
                                          success:(TYSuccessID)success
                                          failure:(nullable TYFailureError)failure;

Parameters

Parameter Description
devId The device ID.
unlockBindingId The password ID.
symbolic Specifies whether a DP needs to be sent.
dpTunnel The channel through which a DP is sent. Valid values:
  • 1: The app sends the DP.
  • 2: The cloud sends the DP.
  • 3: The app or cloud sends the DP.
success The success callback.
failure The failure callback.

Example

- (void)deleteVideoLockTemporaryPasswordAPITest{
    [self.lockAPI deleteVideoLockTemporaryPasswordWithDevId:@"6c05de1dbb2e4fef15z4va"
                                            unlockBindingId:5664211
                                                   symbolic:YES
                                                   dpTunnel:1
                                                    success:^(id result) {
						//TODO
    } failure:^(NSError *error) {
						//TODO
    }];
}

Member management

API description

Calculates the number of lock panel members. This API method applies to camera locks only. Product code: wf_jtmspro.

- (void)getPhotoLockMemberCountWithDevId:(NSString *)devId
                                 success:(TYSuccessID)success
                                 failure:(nullable TYFailureError)failure;

Parameters

Parameter Description
devId The device ID.
success The success callback.
failure The failure callback.

Example

- (void)getPhotoLockMemberCountAPITest{
    [self.lockAPI getPhotoLockMemberCountWithDevId:@"6ce91a406cebe66b1f1gep"
                                           success:^(id result) {
						//TODO
    } failure:^(NSError *error) {
						//TODO
    }];
}

API description

Returns a list of lock panel members. This API method applies to camera locks only. Product code: wf_jtmspro.

- (void)getPhotoLockMemberPanelListWithDevId:(NSString *)devId
                                     success:(TYSuccessID)success
                                     failure:(nullable TYFailureError)failure;

Parameters

Parameter Description
devId The device ID.
success The success callback.
failure The failure callback.

Example

- (void)getPhotoLockMemberPanelListAPITest{
    [self.lockAPI getPhotoLockMemberPanelListWithDevId:@"6ce91a406cebe66b1f1gep"
                                               success:^(id result) {
						//TODO
    } failure:^(NSError *error) {
						//TODO
    }];
}

API description

Adds a lock panel member. This API method applies to camera locks only. Product code: wf_jtmspro.

- (void)addPhotoLockPanelMemberWithDevId:(NSString *)devId
                                    name:(NSString *)name
                                  avatar:(NSString *)avatar
                                     sex:(NSString *)sex
                                birthday:(NSInteger)birthday
                                  height:(NSInteger)height
                                  weight:(NSInteger)weight
                         localHeightUnit:(NSString *)localHeightUnit
                                 success:(TYSuccessID)success
                                 failure:(nullable TYFailureError)failure;

Parameters

Parameter Description
devId The device ID.
name The username.
avatar The avatar.
sex The gender of the member. Valid values:
  • 0: unknown
  • 1: male
  • 2: female
birthday The timestamp of the member’s birthday.
height The height of the member.
weight The weight of the member.
localHeightUnit The unit of the height. Valid values:
  • CM: cm
  • INCH: inch
success The success callback.
failure The failure callback.

Example

- (void)addPhotoLockPanelMemberAPITest{
    [self.lockAPI addPhotoLockPanelMemberWithDevId:@"6ce91a406cebe66b1f1gep"
                                              name:@"kandi.test"
                                            avatar:@""
                                               sex:@""
                                          birthday:1
                                            height:174
                                            weight:120
                                   localHeightUnit:@"cm"
                                           success:^(id result) {
						//TODO
    } failure:^(NSError *error) {
						//TODO
    }];
}

API description

Updates the information about a lock panel member. This API method applies to camera locks only. Product code: wf_jtmspro.

- (void)updatePhotoLockPanelMemberWithDevId:(NSString *)devId
                                     userId:(NSString *)userId
                                   userName:(NSString *)userName
                                     avatar:(NSString *)avatar
                                    success:(TYSuccessID)success
                                    failure:(nullable TYFailureError)failure;

Parameters

Parameter Description
devId The device ID.
userId The user ID.
userName The username.
avatar The avatar.
success The success callback.
failure The failure callback.

Example

- (void)updatePhotoLockPanelMemberAPITest{
    [self.lockAPI updatePhotoLockPanelMemberWithDevId:@"6ce91a406cebe66b1f1gep"
                                               userId:@"000001wt8r"
                                             userName:@"kandi.test.1"
                                               avatar:@""
                                              success:^(id result) {
						//TODO
    } failure:^(NSError *error) {
						//TODO
    }];
}

API description

Deletes the information about a lock panel member. This API method applies to camera locks only. Product code: wf_jtmspro.

- (void)deletePhotoLockPanelMemberWithDevId:(NSString *)devId
                                     userId:(NSString *)userId
                                    success:(TYSuccessID)success
                                    failure:(nullable TYFailureError)failure;

Parameters

Parameter Description
devId The device ID.
userId The user ID.
success The success callback.
failure The failure callback.

Example

- (void)deletePhotoLockPanelMemberAPITest{
    [self.lockAPI deletePhotoLockPanelMemberWithDevId:@"6ce91a406cebe66b1f1gep"
                                               userId:@"000001wt8r"
                                              success:^(id result) {
						//TODO
    } failure:^(NSError *error) {
						//TODO
    }];
}

API description

Returns details of a lock panel member. This API method applies to camera locks only. Product code: wf_jtmspro.

- (void)getPhotoLockPanelMemberDetailWithDevId:(NSString *)devId
                                        userId:(NSString *)userId
                                       success:(TYSuccessID)success
                                       failure:(nullable TYFailureError)failure;

Parameters

Parameter Description
devId The device ID.
userId The user ID.
success The success callback.
failure The failure callback.

Example

- (void)getPhotoLockPanelMemberDetailAPITest{
    [self.lockAPI getPhotoLockPanelMemberDetailWithDevId:@"6ce91a406cebe66b1f1gep"
                                                  userId:@"000001wt8r"
                                                 success:^(id result) {
						//TODO
    } failure:^(NSError *error) {
						//TODO
    }];
}

Others

API description

Initiates synchronization of unlocking methods.

- (void)syncDataWithDevId:(NSString *)devId
                    dpIds:(NSArray<NSString *> *)dpIds
                  success:(TYSuccessID)success
                  failure:(nullable TYFailureError)failure;

Parameters

Parameter Description
devId The device ID.
dpIds Returns a list of unlocking methods to be synchronized. The returned result is an array of numbers.
success The success callback.
failure The failure callback.

Example

- (void)syncDataAPITest{
    [self.lockAPI syncDataWithDevId:@"6cc849sydtyuum28"
                              dpIds:@[@"12",@"15"]
                            success:^(id result) {
						//TODO
    } failure:^(NSError *error) {
						//TODO
    }];
}

API description

Checks whether to enable remote unlocking with voice.

- (void)isSetRemoteVoiceUnlockWithDevId:(NSString *)devId
                                success:(TYSuccessID)success
                                failure:(nullable TYFailureError)failure;

Parameters

Parameter Description
devId The device ID.
success The success callback.
failure The failure callback.

Example

- (void)isSetRemoteVoiceUnlockAPITest{
    [self.lockAPI isSetRemoteVoiceUnlockWithDevId:@"6cc849sydtyuum28"
                                          success:^(id result) {
						//TODO
    } failure:^(NSError *error) {
						//TODO
    }];
}

API description

Enables or disables remote unlocking with voice. A voice password is specified. This API method can also be used to update the voice password.

- (void)setRemoteVoiceUnlockWithDevId:(NSString *)devId
                                 open:(BOOL)open
                                  pwd:(NSString *)pwd
                              success:(TYSuccessID)success
                              failure:(nullable TYFailureError)failure;

Parameters

Parameter Description
devId The device ID.
open Specifies whether to enable this feature.
pwd The password for unlocking with voice.
success The success callback.
failure The failure callback.

Example

- (void)setRemoteVoiceUnlockAPITest{
    [self.lockAPI setRemoteVoiceUnlockWithDevId:@"6cc849sydtyuum28"
                                           open:YES
                                            pwd:@"4324"
                                        success:^(id result) {
						//TODO
    } failure:^(NSError *error) {
						//TODO
    }];
}

API description

Returns the rotation angle of a device.

- (void)getDeviceRotateWithDevId:(NSString *)devId
                         success:(TYSuccessID)success
                         failure:(nullable TYFailureError)failure;

Parameters

Parameter Description
devId The device ID.
success The success callback.
failure The failure callback.

Example

- (void)getDeviceRotateAPITest{
    [self.lockAPI getDeviceRotateWithDevId:@"6ce91a406cebe66b1f1gep"
                                   success:^(id result) {
						//TODO
    } failure:^(NSError *error) {
						//TODO
    }];
}

API description

Returns a list of albums. This API method applies to smart video locks only.

- (void)getAlbumListWithDevId:(NSString *)devId
                      success:(TYSuccessID)success
                      failure:(nullable TYFailureError)failure;

Parameters

Parameter Description
devId The device ID.
success The success callback.
failure The failure callback.

Example

- (void)getAlbumListAPITest{
    [self.lockAPI getAlbumListWithDevId:@"6ce91a406cebe66b1f1gep"
                                success:^(id result) {
						//TODO
    } failure:^(NSError *error) {
						//TODO
    }];
}

API description

Returns the latest device log entry.

- (void)getLatestDeviceLogWithDevId:(NSString *)devId
                           userType:(NSInteger)userType
                             userId:(NSString *)userId
                            success:(TYSuccessID)success
                            failure:(nullable TYFailureError)failure;

Parameters

Parameter Description
devId The device ID.
userType The type of user. Valid values:
  • 0: home member
  • 1: lock panel member
userId The user ID.
success The success callback.
failure The failure callback.

Example

- (void)getLatestDeviceLogAPITest{
    [self.lockAPI getLatestDeviceLogWithDevId:@"6ce91a406cebe66b1f1gep"
                                     userType:1
                                       userId:[TuyaSmartUser sharedInstance].uid
                                      success:^(id result) {
						//TODO
    } failure:^(NSError *error) {
						//TODO
    }];
}

API description

Returns device log entries.

- (void)getDeviceLogsWithDevId:(NSString *)devId
                 logCategories:(NSString *)logCategories
                       userIds:(NSString *)userIds
           onlyShowMediaRecord:(BOOL)onlyShowMediaRecord
                     startTime:(NSInteger)startTime
                       endTime:(NSInteger)endTime
                    lastRowKey:(NSString *)lastRowKey
                      userType:(NSInteger)userType
                        userId:(NSString *)userId
                         limit:(NSInteger)limit
                       success:(TYSuccessID)success
                       failure:(nullable TYFailureError)failure;

Parameters

Parameter Description
devId The device ID.
logCategories The log category.
userIds The list of users in the log entries to be returned.
onlyShowMediaRecord Specifies whether to only return the log entries with images.
startTime The start time of the period to be queried.
endTime The end time of the period to be queried.
lastRowKey The parameter for paging.
userType The type of user. Valid values:
  • 0: home member
  • 1: lock panel member
userId The lock panel user ID.
limit The maximum number of entries to be returned per page.
success The success callback.
failure The failure callback.

Example

- (void)getDeviceLogsAPITest{
    // The type of log. 1. `operation`: operation log. 2. `unlock_record`: unlocking log. 3. `close_record`: locking log. 4. `alarm_record`: alarm log.
    [self.lockAPI getDeviceLogsWithDevId:@"6ce91a406cebe66b1f1gep"
                           logCategories:@"unlock_record"
                                 userIds:nil
                     onlyShowMediaRecord:NO
                               startTime:0
                                 endTime:[[NSDate date] timeIntervalSince1970]*1000
                              lastRowKey:nil
                                userType:0
                                  userId:nil
                                   limit:10
                                 success:^(id result) {
						//TODO
    } failure:^(NSError *error) {
						//TODO
    }];
}

API description

Binds a log entry with a user.

- (void)bindHistoryLogToUserWithDevId:(NSString *)devId
                               userId:(NSString *)userId
                            unlockIds:(NSArray *)unlockIds
                              success:(TYSuccessID)success
                              failure:(nullable TYFailureError)failure;

Parameters

Parameter Description
devId The device ID.
userId The user ID.
unlockIds The list of unlocking methods
success The success callback.
failure The failure callback.

Example

- (void)bindHistoryLogToUserAPITest{
    [self.lockAPI bindHistoryLogToUserWithDevId:@"6ce91a406cebe66b1f1gep"
                                         userId:[TuyaSmartUser sharedInstance].uid
                                      unlockIds:@[@"12-01",@"13-02"]
                                        success:^(id result) {
						//TODO
    } failure:^(NSError *error) {
						//TODO
    }];
}

API description

Specifies whether remote unlocking is supported.

- (void)remoteUnlockAvailableWithDevId:(NSString *)devId
                               success:(TYSuccessID)success
                               failure:(TYFailureError)failure;

Parameters

Parameter Description
devId The device ID.
success The success callback.
failure The failure callback.

Example

- (void)remoteUnlockAvailableAPITest{
    [self.lockAPI remoteUnlockAvailableWithDevId:@"6c75c3ahtsybmyx7"
                                         success:^(id result) {
						//TODO
    }
                                         failure:^(NSError *error) {
						//TODO
    }];
}

API description

Updates information about a custom temporary password.

- (void)updateBLELockTemporaryPasswordWithDevId:(NSString *)devId
                                           name:(NSString *)name
                                       password:(NSString *)password
                                unlockBindingId:(NSInteger )unlockBindingId
                                  effectiveTime:(NSInteger)effectiveTime
                                   invalidTime:(NSInteger)invalidTime
                                          phase:(NSInteger)phase
                                      schedule:(NSString *)schedule
                                      symbolic:(BOOL)symbolic
                                      dpTunnel:(NSInteger)dpTunnel
                                       success:(TYSuccessID)success
                                       failure:(nullable TYFailureError)failure;

Parameters

Parameter Description
devId The device ID.
name The name of the password.
password The password content.
unlockBindingId The password ID.
effectiveTime The time when the password takes effect.
invalidTime The time when the password expires.
phase The status of the password. Valid values: 2: normal. 4: frozen.
schedule The schedule in which the password can be used.
symbolic Specifies whether a DP needs to be sent.
dpTunnel The channel through which a DP is sent. Valid values: 1: The app sends the DP. 2: The cloud sends the DP. 3: Both the app and the cloud send the DP.
success The success callback.
failure The failure callback.

Example

- (void)updateBLELockTemporaryPasswordAPITest{
    [self.lockAPI updateBLELockTemporaryPasswordWithDevId:@"6c75c3ahtsybmyx7"
                                                     name:@"test"
                                                 password:@"1234567"
                                          unlockBindingId:6071699
                                            effectiveTime:1665306701584
                                              invalidTime:1665316701584
                                                    phase:2
                                                 schedule:@"[{\"allDay\":true,\"effectiveTime\":360,\"invalidTime\":1080,\"workingDay\":127}]"
                                                 symbolic:YES
                                                 dpTunnel:1
                                                  success:^(id result) {
						//TODO
    }
                                                  failure:^(NSError *error) {
						//TODO
    }];
}

API description

Verifies the validity of the parameters for a specified temporary password.

- (void)validateBLELockTemporaryPasswordWithDevId:(NSString *)devId
                                             name:(NSString *)name
                                            phone:(NSString *)phone
                                  unlockBindingId:(NSInteger)unlockBindingId
                                    effectiveTime:(NSInteger)effectiveTime
                                      invalidTime:(NSInteger)invalidTime
                                         password:(NSString *)password
                                         schedule:(NSString *)schedule
                                      countryCode:(NSString *)countryCode
                                          success:(TYSuccessID)success
                                          failure:(nullable TYFailureError)failure;

Parameters

Parameter Description
devId The device ID.
name The name of the password.
phone The mobile phone number.
unlockBindingId The password ID.
effectiveTime The time when the password takes effect.
invalidTime The time when the password expires.
password The password.
schedule The schedule in which the password can be used.
countryCode The country code of the mobile phone number for the lock user.
success The success callback.
failure The failure callback.

Example

- (void)validateBLELockTemporaryPasswordAPITest{
    [self.lockAPI validateBLELockTemporaryPasswordWithDevId:@"6c75c3ahtsybmyx7"
                                                       name:@"kandi-ttt"
                                                      phone:@"13625814876"
                                            unlockBindingId:6072231
                                              effectiveTime:1665306701584
                                                invalidTime:1665316701584
                                                   password:@"123456"
                                                   schedule:@"[{\"allDay\":true,\"effectiveTime\":360,\"invalidTime\":1080,\"workingDay\":127}]"
                                                countryCode:@"86"
                                                    success:^(id result) {
						//TODO
    }                                               failure:^(NSError *error) {
						//TODO
    }];
}

API description

Reports operation logs.

- (void)uploadBLELockOperationLogWithDevId:(NSString *)devId
                                   logType:(NSString *)logType
                                      data:(NSString *)data
                                   success:(TYSuccessID)success
                                   failure:(nullable TYFailureError)failure;

Parameters

Parameter Description
devId The device ID.
logType The type of log.
data The request parameters.
success The success callback.
failure The failure callback.

Example

- (void)uploadBLELockOperationLogAPITest{
    [self.lockAPI uploadBLELockOperationLogWithDevId:@"6c75c3ahtsybmyx7"
                                             logType:@"remote_unlock_setting"
                                                data:@[@(NO)].tysdk_JSONString
                                             success:^(id result) {
						//TODO
    } failure:^(NSError *error) {
						//TODO
    }];
}