Device.ondisconnect how to identify the device when running on multiple imps?

Hello i have 3 imps devices with the same code. When one does down i have this code but how do i identify in the sms sent what device is down ?

device.ondisconnect(function() {
local url = “
local apiKey = “xxx”
local apiSecret = “xxx9”
local fromNumber = “xxx”
local toNumber = “xxxxxx788560”
local message = “IMP - B3 disconected”

local payload = {
  "api_key": apiKey,
  "api_secret": apiSecret,
  "from": fromNumber,
  "to": toNumber,
  "text": message

local request =, { "Content-Type": "application/json" }, http.jsonencode(payload))

request.sendasync(function(response) {
  if (response.statuscode == 200) {
  } else {
    server.error("Error:", response.body)


You could have the device call hardware.getdeviceid(), forward that with agent.send() when it first connects and then append it to your message.

This topic was automatically closed after 60 days. New replies are no longer allowed.