I’m pleased to announce that the Watson IoT Platform now includes a new API for monitoring device connectivity.

Device Status

Often you need to know whether a device or set of devices are on-line or off-line.  You need to know when they last connected and why they were disconnected.  The new API allows you to query a specific device, or query across a number of devices.

You can filter and ask for a list of all the devices that are currently connected.¬† This is really useful if you’re building dashboards or creating reports.

For example, here is a query for the status of my device TemperatureSensor_1:

GET https://ortc78.internetofthings.ibmcloud.com/api/v0002/clientconnectionstates/d:ortc78:TemperatureSensor:TemperatureSensor_1

I get the response back:

{
"id": "d:ortc78:TemperatureSensor:TemperatureSensor_1",
"clientType": "device",
"connectionStatus": "connected",
"lastConnectTime": "2018-09-27T08:40:54.456Z",
"lastDisconnectTime": "2018-09-27T08:40:37.493Z",
"lastActivityEvent": "mqttPublish",
"lastActivityTime": "2018-09-27T08:40:54.456Z",
"mqttConnectProtocol": "3.1.1"
}

I can see it’s connected, when it connected, the last time it disconnected, the last activity it performed and which level of the protocol it’s using.

I can also issue a query like this to find the status of all connections to the platform:

GET https://ortc78.internetofthings.ibmcloud.com/api/v0002/clientconnectionstates?_limit=100&_sort=-lastActivityTime

I’ve also included some parameters to sort by the last activity time and set the number of results I want returned, as it could potentially be a long list.

Documentation

You can find full details in the documentation for the Monitoring Client Connectivity feature.

Swagger doc for the API

Give it a try – let us know what you think!

Join The Discussion

Your email address will not be published. Required fields are marked *