Build automations based on device online/offline status

If you have critically important devices in SmartThings, and you need to know if they ever go into an ‘offline’ state, then this Edge driver can help you build the needed automations in the post-Groovy world.

Be forewarned that this driver requires my edgebridge app running on an always-on computer with internet access. I know this isn’t ideal for a lot of people, but it is needed to access the SmartThings API. If you already use edgebridge, you may still need to update or create your edgebridge configuration file to provide your SmartThings token.

Please see this README for all the details for installing, configuring, and using this driver.


Please note that device Controls screen labels are still broken - particularly for iOS users. For those suffering from this, know that the button in the Main section on the Controls screen is for creating new devices (it may be labeled ‘Untitled’).


My thanks to @smartie for the original request for this function!

6 Likes

I believe you can also get the device numbers in my.smartthings.com on the detail page for each device.

3 Likes

Dang, you are right! I never noticed that. You have to scroll down to the bottom to see it. I will update my README file.

THANKS!

3 Likes

Damn Todd! Do you ever sleep?!

5 Likes

I installed this today and it seems to work very well. Thanks again for developing and sharing.

If you keep developing these great products you are going to force me to buy a RPi.

1 Like

@TAustin, I’m struggling with your EdgeBridge proxy, to push json payloads.

My test case is with a smart sound bar, creating an input for HDMI1 and an input for HDMI2. Right now I am testing via regular CLI using curl:

Running remotely on local LAN.

(IP addresses, tokens, etc. are all faked)
Works OK

curl -vv “http://192.168.1.18:8088/api/forward?url=https://api.smartthings.com/v1/devices/1a123ab1-abc1-1234-1a12-123a45b6789a/status

This proves connectivity is ok, and the basics of the proxy work, including the configuration file with the bearer token. Woohoo!

Fails

curl -vv “http://192.168.1.18:8088/api/forward?url=https://api.smartthings.com/v1/devices/1a123ab1-abc1-1234-1a12-123a45b6789a/commands” --header “Content-Type: application/json” --data-raw ‘{“commands”:[{“component”:“main”,“capability”:“mediaInputSource”,“command”:“setInputSource”,“arguments”:[“HDMI2”]}]}’

Curl Response - 422

Trying 192.168.1.18:8088…
Connected to 192.168.1.18 (192.168.1.18) port 8088 (#0)
POST /api/forward?url=https://api.smartthings.com/v1/devices/1a123ab1-abc1-1234-1a12-123a45b6789a/commands HTTP/1.1
Host: 192.168.1.18:8088
User-Agent: curl/7.79.1
Accept: /
Content-Type: text/json
Content-Length: 116
.
Mark bundle as not supporting multiuse
HTTP 1.0, assume close after body
HTTP/1.0 422 Unprocessable Entity
Server: SimpleHTTP/0.6 Python/3.10.6
Date: Thu, 08 Sep 2022 00:24:31 GMT
CONTENT-TYPE: text/xml; charset=“utf-8”
DATE: Thu, 08 Sep 2022 00:24:31 GMT
SERVER: edgeBridge
CONTENT-LENGTH: 0
.
Closing connection 0

Joy, then no joy! It just so happens that I’m working on an update to the edgebridge app and I think it may address what you are seeing, but I’m not positive. Let me do a little bit more testing, including trying to recreate your request. I should be able to get right back to you soon and maybe you can be an early tester for my updated version. What form file do you need, is plain Python script ok or do you need an executable?

I’m using the python script, deployed in an official python container.

I was playing around and added the payload and had that working for POST yesterday. I simply pull the data into a variable with json load, and then pass it into only the POST call.

I’ll test a little more then can share the changes I made for comparison too.

Thanks for letting me know this since I hardly use or even go to My SmartThings. So now I don’t need to use a computer with the CLI commands to get the device number to create my Android Tasker HTML routine API calls. I can just copy-and-paste the device numbers using Android alone. Sweet!

1 Like

@TAustin - I pushed my changes into a fork and made a PR for you, so you can easily review what I have done.

  • Added support to pass the --data-raw value into the externalized request
  • Added dockerfile and docker-compose example, to run it in a container

OK - I have not uploaded my own latest changes to github, as I’ve still been testing. Have a couple things to address. I’ll take a look at your PR. Happy to have you contribute, so thank you!!

Can’t believe I managed to get this working, thank you.
Your install info was great.

Running it on a little cheap fanless PC.
I’ve only added a few devices so far to monitor offline status. I’m creating a routine but is there somehow a way to notify me on exactly what device is offline?

Here’s my automation. If I have 10 devices on there and 1 goes offline, there’s no way to know which one from a notification is there?

image

Thanks.

I think you’ll have to create a unique routine per device.

Yeah ive created a group for 15 motion sensors and a group for 15 open/close sensors, at least that way I’ll know its a motion sensor or an open close sensor

Another question that you may know.
So I have it checking every 60 mins and I have my routines to send me a notification if any devices are offline.

If a device goes offline within that 60 minute period but comes back online before it, would it still flag it as offline because It did in fact go offline. Does that make sense?

Thanks.

It would not get flagged as offline in that case.

1 Like

Hi mate is this able to run on a Synology Nas?

This driver queries the SmartThings API to find out the health status of a known SmartThings device.

If you want to monitor whether your Synology NAS is up or not, unless you have it integrated with SmartThings already, then you’ll need a different approach (and a different driver).

If your Synology NAS supports UPnP, then you could use my LAN Device Monitor driver.

If you are ok with running a script on your server, then you could install my edgebridge app and use my edgebridge monitor driver. That periodically polls the edgebridge app to see if it answers, so you’d be using that as a surrogate health status.

Another approach would be to use my pinger app running on some other machine on your LAN, along with edgebridge, plus my LAN Presence Edge driver. This would give you a SmartThings device that shows whether your server is responding to basic PING requests.

hi would this work with mobile phones

I have a separate app that is meant to work with mobile phones.