Device health in legacy apps

This question has developed out of a thread on the webCoRE forum.

Although very little about device health has ever been documented, it used to be the case that the DeviceWatch-DeviceStatus attribute of the Health Check capability was updated with the online/offline status of a device, and I believe the same was also true of healthStatus. It was possible for legacy apps to subscribe to this attribute and so trigger automations based on the changes, and yes I am particularly talking about webCoRE and pistons.

That seems to have all stopped on October 5th. I assume healthStatus and DeviceWatch-DeviceStatus can still be used to set the connectivity status of untracked or cloud based devices, it certainly seems to still be possible to get the current status using device.getStatus() in legacy apps (aka $status in webCoRE), and new integrations can presumably use the Health API. However, if there is still a way for legacy apps to subscribe to changes in the connectivity status, it isn’t leaping out at me.

I can well imagine having overlooked something as none of this stuff has really ever been explained to the punters. So have I?

1 Like

I wonder if the cloud update mentioned in the beta firmware post never happened?

@BarryA can you confirm the cloud update above occured?

1 Like

I’m looking to add device health to my roomba dth, but since it’s connecting via an intermediary server I’ve had to build a way to ping the actual robot just to make sure it’s connected to wifi. I can get the actual IP of the robot from the API.
The idea is that your server is likely always online, but the robot may lose WiFi connectivity due to battery etc.
I also found that my sendHubEvent for polling the API still ran even if the server was set to a nonsensical IP. I’m not sure how to make it return something indicating that it failed? Should I just ping the server also?

Can I do sendEvent(“healthStatus”, value: “offline”) ? Is this correct?

I don’t think I need to use DeviceWatch-Enroll because I’ve already set it up to regularly check the device status, and I don’t need to set the checkInterval because I’m just using the regular polling interval (I’m pinging the device before every API poll).

Is there anything wrong with this setup for implementing devicehealth?
I got the idea from this DTH
https://community.smartthings.com/t/release-http-online-sensor/142198

def checkConnection(){
	log.debug "Checking connection status..."
    state.tryCount = state.tryCount + 1
    log.debug "state.tryCount: ${state.tryCount}"
    if (state.tryCount > 3) {
    	log.debug "Connection is offline"
        //Display offline in UI
    	sendEvent(name: 'healthStatus', value: 'offline' )
	}

  	def command = getPingCommand()
    sendHubCommand(command)
}
//TODO Parse results of connection check
def parseCheckConnection(description) {
    log.debug "Parsing connection status results"
    
    def msg = parseLanMessage(description)
    log.debug "Connection status: ${msg.status}"
    
    if (msg.status == 200) {
        state.tryCount = 0
        log.debug "Connection is online"
        sendEvent(name: 'healthStatus', value: 'online' )
	}
}

//TODO Setup the ping command 
def getPingCommand() {
    def result = new physicalgraph.device.HubAction(
        method: "GET",
        path: "/",
        headers: [
            HOST: getRobotAddress()
        ]
    )
    
    return result
}