Would like to check device every XX minutes for offline status

There is a new API and subscription type for health status of devices (‘offline’ status) in the next-gen SmartThings platform. I suspect this would be the best way to query for this data going forward with SmartThings killing off Groovy and its associated way of checking health status.

I believe you could query the API endpoint directly in an HTTP Action, but of course that would require polling the endpoint. If there’s enough interest in it, I believe we could build the event driven version of it natively into SharpTools.

4 Likes

Not sure if others need it or not. I just have a flaky Z-Wave water valve (Watercop version) that drops off. I even tried to get a new faceplate, but “supply chain issues” they can’t help right now.

Thanks.

1 Like

I think this would be helpful. A lot of us use the Notify Me When(?) SmartThings app to check if something is offline and since it’s Groovy it’s probably going away. It would be nice to have a way to check offline status. If some of my devices go offline, it usually means that the breaker switch tripped in the garage and I need to check ASAP because otherwise the stuff in the freezer will melt! :laughing:

1 Like

You can use this Edge driver in ST for offline notifications.

That’s an option. However, it requires that another app be running all the time on a computer connected to the internet, something for which I can’t guarantee.

Yes, the inability of ST to send requests to non-local endpoints is frustrating and somewhat mystifying, and is the reason that driver requires the intermediate “edgebridge” running on a RPi or such.

For now, here’s a simple SharpTools flow to get the status of an individual device. You only need the DeviceID (which you can get from my.smarthings.com by clicking on an individual device in that window and an access token which you can get from https://account.smartthings.com/tokens

This flow can easily be looped to repeat at regular intervals.

ETA: I included the “Set Variable” action only to show the specific value for the $context.response.data variable. You don’t necessarily need to do this.

3 Likes

Great. Thanks for the rule. I’ve been messing a bit with the API (using Postman) to see what info I get and what it can do. This will be helpful.

2 Likes

Is it possible to turn a device on/off using this webhook

Yes, the general syntax is

https://api.smartthings.com/v1/devices/“my device ID”/command

1 Like

Thanks for this info!
Is there a way to pull a list of DevID’s or is it simply a manual (look at IDE / write it down / add to ST Rule’s GET) process, repeated for each device in the network?

You can make a GET request to https://api.smartthings.com/v1/devices (along with an Authorization header and Bearer token), which will give you detailed information about all of your devices, including the the deviceId and name for each of them (in JSON format).

You can then parse the JSON response however you choose to create a comprehensive list of IDs and names. I have way too many devices and am too lazy to get the IDs one at a time. :smirk:

1 Like

If you hate JSON as much as I do, you can parse the CLI output:

smartthings devices:status > foo.csv

Open the csv in Excel and do a Text to Columns using │ as the delimiter. It’ll wind up like this:

That’s a good idea. I haven’t messed with the CLI too much, as I’ve been primarily focused on being sure I was in good shape for the groovy deprecation. Just as an aside, I parsed the JSON output from the GET request in Excel as well using Data | Get Data | From File | From JSON. It made the process simple.

I’ll have to try that! Parsing the output is often the biggest pain!

They are also available in SharpTools.

  1. Open your User Page
  2. Tap the … next to your location
  3. Scroll down and tap on your device
  4. Flip the advanced toggle on and review the Device ID field*

*One exception here is multicomponent devices which show in the format deviceId:componentId

1 Like

It’s very quick and simple to do in Excel, although if you’re new to parsing JSON this way it might not be entirely intuitive. This video might help.

1 Like

I set this method up for a loop. This seems to be exactly what I was looking for. Thanks!

1 Like

Our example is we have a hot water circulation pump, we turn it on every 20 minutes for 5 minutes.

1 Like

It sounds like those are your two events. Or at least one event with delays in the rule.

trigger - circ pump turns off
flow - wait 20 minutes, turn circ pump on, wait 5 minutes, turn circ pump off

Sounds kind of important though, so I might add a separate rule as a backup. Maybe triggers on the circ pump staying on or off longer than you expect as a failsafe. Or use a daily check at a certain time with an if condition to see if it’s stayed on or off for too long and restart things.