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.
Example: Consider this basic JSON payload sent to the edge device.
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:
See Also
- Adding and managing commands