Device health in legacy apps

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
}