In the Zoho IoT application, data sent from the gateway/smart device can be enhanced further. This includes decoding raw payload into a usable JSON format and performing additional computations and enrich by calling external API's. This is achieved using the Message Formatter and Message Handler.
Payloads sent by the device can be of any format. These formats need to be converted to readable values in the form of JSON to be further processed in the application. Zoho IoT applications provide the option to include a decoder as an uplink message formatter for a device product.
Note: Message formatting is supported for LoRa node devices connected using LoRa datastreams.
Message formatters are predefined for some sensors showcased in the device product gallery, and there is no limit for its usage. For other sensors, users can implement their own formatter using custom functions. Please note, the number of executions for decoding with custom function is limited. To enable unrestricted decoding executions directly within the Zoho IoT application, please contact our support team at support@zohoiot.com.
Note: Custom functions for uplink handler i.e the decoder supports JavaScript Lite.
For example, consider the Milesight AM103 device that sends payloads in Hexadecimal format. The uplink message formatter linked to the AM103 device product will decode the hex message as given below:
Here, the device sends the payload in the hexadecimal format:
017564 03671801 04686D 077DC501
The Output of the formatter will be:
{
"battery": 100,
"co2": 453,
"temperature": 28,
"humidity": 54.5
}
Here is a sample code used as a decoder.
This JSON object is then used by the Zoho IoT application to process further like parse the values for the configured datapoints, etc.
The maximum processing time for functions is 2 seconds. For further details, please contact
support@zohoiot.com.
Message Handler
After a message is received and formatted(optional), complex computations can be performed, and external APIs can be called if needed and enrich the received data using message handler. Zoho IoT applications provide the option to include a message handler for a device model/device instance.
Note: The message handler can use a custom function written in the Deluge language, and the payload received by the message handler must be a JSON payload.
For example, based on the temperature data received from the AM103 device, you can call a weather API to get the external temperature. Next, calculate the delta value between the internal room temperature and the external temperature, and add the new value to the JSON payload.
Input Payload for message handler:
{
temp_c : 27
}
Output Payload by message handler:
{
temp_c : 27,
temp_out : 40
temp_del : 13
}
The maximum processing time for functions is 2 seconds. For further details, please contact
support@zohoiot.com.
Message Handler Model and Instance Customization
A message handler can be defined for a device model, and all devices created from this model will utilize the specified message handler. If a particular device instance needs a different handler, users have the option to override the default model message handler.
Fair Usage Policy
The fair usage policy outlines the limitations to Message Handler and Message Formatter functions for our application's trial plan.This is to ensure balanced system performance. These limits apply individually to each registered device rather than to the application as a whole.
Feature | Function Processing Time | Time Window | Max Request allowed |
Message Handler | 500ms | 2 hours | 75 |
Message Formatter | 50ms | 2 hours | 35 |
See Also