Last Updated on : 2024-06-24 04:09:27download
```mermaid sequenceDiagram title: IR Learning Actor User as User participant WeChat mini program as WeChat mini program participant Cloud as Cloud participant Universal IR remote control as Universal IR remote control participant IR device as IR device User ->> WeChat mini program: Request enabling IR learning mode WeChat mini program->> Cloud: infrared.learningState Cloud->>Universal IR remote control: -->Cloud: -->>WeChat mini program: Learning mode enabled successfully User->>Universal IR remote control: -->>Cloud: Report IR code WeChat mini program ->> Cloud: -->> WeChat mini program: Return IR code User->> WeChat mini program: Request disabling learning mode WeChat mini program->> Cloud: -->>Universal IR Remote Control: -->>Cloud: -->>WeChat mini program: Learning mode disabled successfully opt [Optional action] User->>WeChat mini program: Save learned IR code WeChat mini program->> Cloud: -->>WeChat mini program: Return remote_id of virtual remote control for the learning device User->>WeChat mini program: Update learned IR code WeChat mini program->>Cloud: -->>WeChat mini program: Return remote_id of virtual remote control for the learning device (same as value passed in) User->>WeChat mini program: Delete learned IR code WeChat mini program->> Cloud: -->>WeChat mini program: Return result of deletion (whether the deletion is successful) User->>WeChat mini program: Get learned and saved IR code WeChat mini program->> Cloud: -->>WeChat mini program: Return saved IR code User->>WeChat mini program: Send learned IR code WeChat mini program->>Cloud: infrared.learningCodeSend Cloud->>Universal IR remote control: Send IR code Universal IR remote control->>IR device: Send IR code end ```
Action | Description |
---|---|
infrared.learningState | Enable the learning mode. |
infrared.learningCode | Query the learned IR code. |
infrared.learningCodeSave | Save the learned IR code. |
infrared.learningCodeUpdate | Modify the learned IR code. |
infrared.learningCodeInfos | Get the IR code that is learned and saved. |
infrared.learningCodeDelete | Delete the learned IR code. |
infrared.learningCodeSend | Send the learned IR code. |
API description
Enable the learning mode for an IR gateway.
API endpoint
action: infrared.learningState
Request parameters
Parameter name | Type | Description | Required |
---|---|---|---|
infrared_id | String | The infrared device ID. | Yes |
state | String | Specifies whether to enable the learning mode. Valid values:true : yesfalse : no |
Yes |
Sample request
{
"action": "infrared.learningState",
"params": {
"infrared_id": "vdevo157924607038167",
"state": "true"
}
}
Response parameter
Parameter name | Type | Description |
---|---|---|
code | Integer | The response code. |
success | Boolean | Indicates whether the operation is successful. Valid values:true : success.false : failure. |
msg | String | The message that is returned if the request failed. The response is empty if the request is successful. |
result | Boolean | true is returned when the operation is successful. |
t | Long | The time when the learning mode was enabled. |
Sample response
{
"success": true,
"t": 1545135036437,
"result": true
}
API description
Get the IR code that is learned by an IR gateway in learning mode.
API endpoint
action: infrared.learningCode
Request parameters
Parameter name | Type | Description | Required |
---|---|---|---|
infrared_id | String | The infrared device ID. | Yes |
learning_time | String | The time when the learning mode was enabled. | Yes |
Sample request
{
"action": "infrared.learningCode",
"params": {
"infrared_id": "vdevo157924607038167",
"learning_time": "1545135036437"
}
}
Response parameter
Parameter name | Type | Description |
---|---|---|
code | Integer | The response code. |
success | Boolean | Indicates whether the operation is successful. Valid values:true : success.false : failure. |
msg | String | The message that is returned if the request failed. The response is empty if the request is successful. |
result | Object | The returned result. |
Description of result
Parameter name | Type | Description |
---|---|---|
success | Boolean | Indicates whether any IR code has been learned. |
code | String | The learned IR code. This parameter value is empty if success is false . |
Sample response
{
"result": {
"code": "xxxxxxx",
"success": true
},
"success": true,
"t": 1584019201214
}
API description
Save one or more IR codes that have been learned, and generate and return the remote ID.
API endpoint
action: infrared.learningCodeSave
Request parameters
Parameter name | Type | Description | Required |
---|---|---|---|
infrared_id | String | The infrared device ID. | Yes |
codes | List | The IR information to be saved. | Yes |
Description of codes
Parameter name | Type | Description |
---|---|---|
name | String | The name of the learned IR code. |
key_name | String | The button name of the learned IR code. |
code | String | The learned IR code. |
Sample request
{
"action": "infrared.learningCodeSave",
"params": {
"infrared_id": "vdevo157924607038167",
"codes": [
{
"name": "1584019201214",
"key_name": "Power supply",
"code": "xxxxxx"
},
{
"name": "15840193485764",
"key_name": "Volume up",
"code": "xxxxxxx"
}
]
}
}
Response parameter
Parameter name | Type | Description |
---|---|---|
code | Integer | The response code. |
success | Boolean | Indicates whether the operation is successful. Valid values:true : success.false : failure. |
msg | String | The message that is returned if the request failed. The response is empty if the request is successful. |
result | Object | The returned result. |
Description of result
Parameter name | Type | Description |
---|---|---|
remote_id | String | The remote control ID. |
Sample response
{
"success": true,
"t": 1545135036437,
"result": {
"remote_id":"xxxx"
}
}
API description
Modify an IR code that has been learned.
API endpoint
action: infrared.learningCodeUpdate
Request parameters
Parameter name | Type | Description | Required |
---|---|---|---|
infrared_id | String | The infrared device ID. | Yes |
codes | List | The IR information to be saved. | Yes |
Description of codes
Parameter name | Type | Description |
---|---|---|
name | String | The name of the learned IR code. |
key_name | String | The button name of the learned IR code. |
code | String | The learned IR code. |
Sample request
{
"action": "infrared.learningCodeUpdate",
"params": {
"infrared_id": "vdevo157924607038167",
"codes": [
{
"name": "1584019201214",
"key_name": "Power supply",
"code": "yyyyy"
}
]
}
}
Response parameter
Parameter name | Type | Description |
---|---|---|
code | Integer | The response code. |
success | Boolean | Indicates whether the operation is successful. Valid values:true : success.false : failure. |
msg | String | The message that is returned if the request failed. The response is empty if the request is successful. |
result | Object | The returned result. |
Description of result
Parameter name | Type | Description |
---|---|---|
remote_id | String | The remote control ID. |
Sample response
{
"success": true,
"t": 1545135036437,
"result": {
"remote_id":"xxxx"
}
}
API description
Get the remote control of the IR code that has been learned and saved.
API endpoint
action: infrared.learningCodeInfos
Request parameters
Parameter name | Type | Description | Required |
---|---|---|---|
infrared_id | String | The infrared device ID. | Yes |
remote_id | String | The remote control ID. | Yes |
Sample request
{
"action": "infrared.learningCodeInfos",
"params": {
"infrared_id": "vdevo157924607038167",
"remote_id": "xxxxxx"
}
}
Response parameter
Parameter name | Type | Description |
---|---|---|
code | Integer | The response code. |
success | Boolean | Indicates whether the operation is successful. Valid values:true : success.false : failure. |
msg | String | The message that is returned if the request failed. The response is empty if the request is successful. |
result | Object | The returned result. |
Description of result
Parameter name | Type | Description |
---|---|---|
code | String | The learned IR code. |
name | String | The name of the IR code. |
key_name | String | The button name of the learned IR code. |
id | Long | The ID of the learned IR code. |
remote_id | String | The remote control ID. |
Sample response
{
"result": [
{
"code": "xxxxx",
"id": 1294005,
"key_name": "Power supply",
"name": "1584011048645",
"remote_id": "xxxxx"
},
{
"code": "yyyyy",
"id": 1294008,
"key_name": "Volume up",
"name": "1584011186158",
"remote_id": "xxxxx"
}
],
"success": true,
"t": 1584019606407
}
API description
Delete the learned IR code.
API endpoint
action: infrared.learningCodeDelete
Request parameters
Parameter name | Type | Description | Required |
---|---|---|---|
infrared_id | String | The infrared device ID. | Yes |
id | String | The ID of the learned IR code. | Yes |
Sample request
{
"action": "infrared.learningCodeDelete",
"params": {
"infrared_id": "vdevo157924607038167",
"id": "1294009"
}
}
Response parameter
Parameter name | Type | Description |
---|---|---|
code | Integer | The response code. |
success | Boolean | Indicates whether the operation is successful. Valid values:true : success.false : failure. |
msg | String | The message that is returned if the request failed. The response is empty if the request is successful. |
result | Object | Indicates whether the operation is successful. |
Sample response
{
"success": true,
"t": 1545135036437,
"result": true
}
API description
Delete the learned IR code.
API endpoint
action: infrared.learningCodeSend
Request parameters
Parameter name | Type | Description | Required |
---|---|---|---|
infrared_id | String | The infrared device ID. | Yes |
remote_id | String | The remote control ID. Set the value to TUYA if no remote control is used. |
Yes |
code | String | The learned IR code. | Yes |
Sample request
{
"action": "infrared.learningCodeSend",
"params": {
"infrared_id": "vdevo157924607038167",
"remote_id": "xxxxxx",
"code": "xxxxxx"
}
}
Response parameter
Parameter name | Type | Description |
---|---|---|
code | Integer | The response code. |
success | Boolean | Indicates whether the operation is successful. Valid values:true : success.false : failure. |
msg | String | The message that is returned if the request failed. The response is empty if the request is successful. |
result | Boolean | Indicates whether the operation is successful. |
Sample response
{
"success": true,
"t": 1545135036437,
"result": true
}
Is this page helpful?
YesFeedbackIs this page helpful?
YesFeedback