Commands executed in Zoho IoT applications send a payload as a JSON message containing essential information. A command key within the payload enables the edge device to identify the specific command and trigger the appropriate actions.
Note: This command key is based on the name defined during the programming of the edge device. Altering the key values can result in device malfunction or unintended behaviour.
Command payload structure:
For example, consider this sample JSON payload sent to the edge device to turn on the light.
Command payload example :
Configuring Command Key
When creating a command, the command key is specified in the Command Key field. You can configure the command key in two ways: as a Direct Parsing String or as an Edge Key.
Direct Parsing String
The Direct Parsing Key refers to the key used in the JSON message's key-value pair.
For example, if "power" is entered in the Command Key field, the following JSON message will be generated when the command is executed.
Edge Key Parsing
Edge Parsing is similar to Direct String Parsing, but with an added information: the edge key specified in the edge name field of an instance (device, asset, location) is prefixed to the generated JSON message.
For instance, if "power" is used as the command key and "ac_1" as the edge name, the resulting JSON file will include the edge name to the key, forming "ac_1.power", and this payload will be sent to the edge device.
Values
Values in the JSON message are determined by the command executed. The generated value can be Boolean, Decimal, Integer, or Percentage, depending on the user's configuration of the command.
For example, consider a payload for controlling the speed of a smart fan. In this, a command uses a command key: set_speed and slider input type with the following configurations: Slider Datatype is set to percentage, the minimum value is 10%, the maximum value is 100%, and the increments are in steps of 10%. When the command is executed with the slider set at 50%, the following payload is generated:
Acknowledgement Payload
When the device receives a command from the Zoho IoT application, it must send an acknowledgement message within 10 seconds to confirm successful receipt. This acknowledgement must adhere to the following JSON structure:

A sample implementation is provided below.
The status codes corresponding to various events are listed below:
1000 : Acknowledged (Message delivered to device)
1001 : Execution Success (Command executed successfully on device)
4000 : Execution Failure (Command execution on device failed)
4001 : Method Not Found (Device does not recognize the command type)
4002 : Executing Previous Command (Device is busy processing a previous command)
4003 : Insufficient Inputs (Issues understanding the command body contents)
4004 : Device Connectivity Issues (Problem communicating with the device)
4005 : Partial Execution (Some actuators succeeded, others encountered issues)
4006 : Already in Target State (Device or actuator is already in the desired state)
See Also