IR Learning Capabilities

Last Updated on : 2024-06-24 04:09:27download

IR Learning Capabilities

API list

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.

Enable learning mode

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: yes
  • false: 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
    }
    

    Query learned IR code

    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
    }
    

    Save learned IR code

    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"
        }
    }
    

    Modify learned IR code

    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"
        }
    }
    

    Get learned and saved IR code

    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
    }
    

    Delete learned IR code

    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
    }
    

    Send learned IR code

    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
    }