sendHubCommand and polling, health check, no errors in live logging

My roomba DTH relies on polling your local server every x minutes (you can set the interval in the app)

As a user pointed out, I need to implement a health check to show the device as offline if the server or robot is unresponsive.

Here’s the problem. I tried inputting a bogus IP address that doesn’t exist for my server, and found that the sendHubCommand still ran my polling, and did not return any sort of error.

Here is what I’ve tried and the result:

Without an error I can’t make an if statement.

The documentation on sendHubCommand isn’t super clear. What should I be doing in order to check the connectivity? How can I make it return an error?

My alternative solution is to ping the server and robot with every polling interval and if either doesn’t respond with 200 to do sendEvent(name: ‘healthStatus’, value: ‘offline’)

Any better ideas? That seems needlessly complicated and ridiculous.

You don’t actually need to change the healthStatus. The way SmartThings works is if no event is received between two ping intervals, it assumes the device is offline. If at anytime it receives an event it marks the device online. So if your device stops responding, just make sure the DTH isn’t sending any events to the platform and it happens for 2 ping intervals it’ll mark the device offline. The point of ping, is to evoke a response (event) from the device. This if your hubresponse doesn’t have any information to report, it shouldn’t send an event and platform should mark it offline.

@RBoy
So in other words if there is no hubresponse I should stop sending sendHubCommand to poll the api? Do I need to include the health check capability for this to work and mark it offline?
And do you have an example I could look at?