Hi all,
I am trying to subscribe to detect when the state of my device goes from online to offline but I am confused to what capability to subscribe to and where to update them. The device handler I am using is located here.
Reading the documentation on Health Check when I issue a GET request to the endpoint
/devices/<deviceId>/health
This is actually updating my device status to online or offline, it returns something like the response below
{
"deviceId": "daf43d66-6c3b-4553-80af-6a0b1cf97418",
"state": "OFFLINE",
"lastUpdatedDate": "2020-11-26T20:08:08.217Z"
}
Which capability is this tied to in my device handler?
How should I update the capability in the device handler?
Where should I update in the device handler?
The device handler does have the capability "Health Check"
in its definition but it is not updated anywhere in the device handler. However the above endpoint still seems to updating my device.
When I issue a request to get the status of a device at the endpoint
https://api.smartthings.com/v1/devices/{Device_ID}/status
I can see the status of the Health Check
capabaility, one of its attributes is healthStatus
but it has a constant value of null
.
"healthCheck": {
"checkInterval": {
"value": 1860,
"unit": "s",
"data": {
"protocol": "zwave",
"hubHardwareId": "0036",
"offlinePingable": "0",
"deviceScheme": "TRACKED"
},
"timestamp": "2020-11-26T13:11:50.222Z"
},
"healthStatus": {
"value": null,
"data": {},
"timestamp": "2020-11-26T13:14:39.628Z"
},
"DeviceWatch-Enroll": {
"value": null,
"timestamp": "2020-11-26T13:14:36.830Z"
},
"DeviceWatch-DeviceStatus": {
"value": null,
"data": {},
"timestamp": "2020-11-26T13:14:39.657Z"
}
}
I do set the checkInterval
in the installed
function. (This was there by default in the original device handler I haven’t changed it)
def installed() {
log.debug "installed()..."
sendEvent(name: "checkInterval", value: 1860, displayed: false, data: [protocol: "zwave", hubHardwareId: device.hub.hardwareID, offlinePingable: "0"])
response(refresh())
}
The end goal is to subscribe to the devices capability which monitors its status if its online/offline using the Node SDK but I’d like to know how and where this is updating in the device handler.
Any help on Health Check or Health Status is welcome!