Is there a "correct" way to impliment health check on a cloud connected device (ST_Anything in this case)

So I can’t find a solid answer but I have done a hack that seems to be working. I started by adding health check to a Z-Wave device and that is working correctly. If it’s offline it does report as such and when it comes back on it clears. Here is what I did for a custom RGBGenie Z-Wave RGB controller DTH:

Add the capability:

capability "Health Check"

Make sure it registers itself whenever installed or updated. The time here is 122 minutes (2 * 60 seconds * 60 seconds + 2 * 60 seconds). I’ve seen some DTH’s use a flat value (7320 seconds) and some use the long format:

def updated() {
	initialize()
}

def installed() {
	initialize()
}

def initialize() {
     sendEvent(name: "checkInterval", value: 2 * 60 * 60 + 2 * 60, displayed: false, data: [protocol: "zwave", hubHardwareId: device.hub.hardwareID, offlinePingable: "1"])
     response(refresh())
}

Add a ping function that does something so ST sees a response:

def ping() {
	refresh()
}

In the above case the refresh routine reports back some value (dimmer level or something) so ST sees this and is happy. If it doesn’t see it then it gets marked offline after a couple tries.

Now there isn’t much info on the cloud connected devices but I looked at the EcoBee sensor and thermostat DTH’s and came up with this:

At the very beginning of the DTH:

import groovy.json.JsonOutput

Add the capability:

capability "Health Check"

Make sure it registers itself whenever installed or updated:

def updated() {
	initialize()
}

def installed() {
	initialize()
}

def initialize() {
	sendEvent(name: "DeviceWatch-Enroll", value: JsonOutput.toJson([protocol: "cloud", scheme:"untracked"]), displayed: false)
	updateDataValue("EnrolledUTDH", "true")
}

Then whenever data is updated make sure to let the cloud know it’s online:

sendEvent(name: "DeviceWatch-DeviceStatus", value: "online")

So now my ST_Anything devices show up correctly in the new app and work great. But if they actually went offline is there anyway of knowing? Again the “cloud” DTH health check is just a copy from ST’s own EcoBee and I don’t see any time outs or anything. In fact the scheme:“untracked” part is pretty worrying. I have a controller with this code right now that’s been in a box for two days offline but show online and I’m assuming that’s why.

What am I missing or is there a better DTH to look at?

Device health is largely undocumented at this time. There are some samples you can use depending on if your device is zwave, ZigBee or cloud. You’re on the right track, however is you’re using a zwave device you need to use the zwave and not cloud scheme.

It will be replaced with a local solution for zwave and ZigBee devices in future. The cloud roadmap is not as clear at this time.

This is kinda sad. The last time I looked into this was over 9 months ago and it seems nothing has changed other then ST has updated some of their DTH’s to work. If they are updating stuff there has to be some documentation. I can’t imagine all their programmers are just winging it. Well…I hope not.

Yeah if you see my examples I am. The Z-Wave one works great, actually works exactly like it’s supposed to. I just don’t understand how the cloud one will ever be marked offline without any timing parameters. For the EcoBee it’s because the cloud side makes a call every 5 minutes and they have notes about that in the DTH but I don’t actually see how to correctly program one so if there is no status after say 4 hours mark it offline.