Skip to content

Scripts ​

Write, simulate and enable a message handler.

Create and enable a script ​

Open External communications → Scripts → Add. The script determines what happens to a received message. For your first test, use the sample handler.js. It recognizes the temperature and humidity sample report and replies with the same sequence number. Download the communication examples (ZIP)

  1. Paste the contents of handler.js into the editor. The editor supplies the surrounding function.
  2. Save and enable the script. Turn on script logging while testing and set a cutoff time if needed.
  3. For a device with a different protocol, open Script reference in the editor for reply, thing-model parsing and outbound RPC examples.

Simulate a message ​

Select Simulate and test the script with a data-received event (onMessage). For the example handler, Base64-encode the sample report, put it in payload.data and set payload.encoding to base64. Inspect the returned reply action and check its sequence number. Simulation does not send a message to the device.

Select this script under Bindings. During live testing, look up the script in Logs.