get_hw_cmds

To get the list of commands available for a unit or a device type, or to get the command templates, use the core/get_hw_cmds method.

Copied!
svc=core/get_hw_cmds&params={
  "deviceTypeId": <long>,
  "unitId": <long>,
  "template": <bool>,
  "lang": "<text>"
}

Parameters

Parameter Description
deviceTypeId Device type ID.
unitId Unit ID.
template Flag. If set to 1, the response contains a JSON with the command template data. The parameter is optional.
lang Language into which the values of title and label are translated. The parameter is optional.

You can specify only one of the deviceTypeId and unitId parameters or both. The search begins with the device type ID and, if it fails, continues with the unit ID. If you want to omit a parameter, set it to 0.

Response

If template is 0 or not specified, the response contains the list of available commands:

Copied!
{
  "<text>": [   /* Link type: GSM, TCP, UDP, VRT. */
    "<text>",   /* Command type. */
    ...
  ],
  ...
}

If template is 1, the command template is returned. It can contain a custom set of fields. An example of a JSON is given below:

Copied!
{
  "<cmd_template_name>": {   /* Name. */
    "icon": <text>,          /* Icon. */
    "props": [               /* Properties. */
      {
        "label": <text>,     /* Property label. */
        "type": <text>,      /* Type. */
        "validate": <text>,  /* Validation rule. */
        "value": [           /* Key-value array. */
          {
            "n": <text>,     /* Key. */
            "v": <text>      /* Value. */
          },
          ...
        ],
        "default": <text>,   /* Default value (for example, the IP address port). */
        "title": <text>,     /* Title. */
        "maxlength": <uint>  /* Maximum length. */
      },
      ...
    ]
  },
  ...
}

If the request fails, an error code is returned.

Error codes

Error code Description
4 One of the following errors:
  • Wrong input parameters.
  • Failed to fetch the device type by deviceTypeId or by unitId.
  • The device type isn’t available in the billing plan.
  • The device type has no command templates (if template is 1).
6 Failed to fetch the current user.

If you find a mistake in the text, please select it and press Ctrl+Enter.