# Build automations based on device online/offline status

**URL:** <https://community.smartthings.com/t/build-automations-based-on-device-online-offline-status/247216>\
**Category:** Community Created Drivers\
**Tags:** requires\_server, project\_power, edge-device, edge\_misc\
**Created:** [September 2, 2022, 11:03pm UTC](https://community.smartthings.com/t/build-automations-based-on-device-online-offline-status/247216 "2022-09-02T23:03:27Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![TAustin](https://yyz2.discourse-cdn.com/smartthings/user_avatar/community.smartthings.com/taustin/32/45058_2.png) [@TAustin](https://community.smartthings.com/u/TAustin)\
**Post date:** [September 2, 2022, 11:03pm UTC](https://community.smartthings.com/t/build-automations-based-on-device-online-offline-status/247216/1 "2022-09-02T23:03:27Z")

</div>

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](https://github.com/toddaustin07/edgebridge) 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](https://github.com/toddaustin07/onlinestatusmon/blob/main/README.md) 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!

---

<div class="post-metadata">

**Author:** ![Paul\_Oliver](https://yyz2.discourse-cdn.com/smartthings/user_avatar/community.smartthings.com/paul_oliver/32/195152_2.png) [@Paul\_Oliver](https://community.smartthings.com/u/Paul_Oliver)\
**Post date:** [September 3, 2022, 12:32am UTC](https://community.smartthings.com/t/build-automations-based-on-device-online-offline-status/247216/2 "2022-09-03T00:32:15Z")

</div>

I believe you can also get the device numbers in [my.smartthings.com](http://my.smartthings.com) on the detail page for each device.

---

<div class="post-metadata">

**Author:** ![TAustin](https://yyz2.discourse-cdn.com/smartthings/user_avatar/community.smartthings.com/taustin/32/45058_2.png) [@TAustin](https://community.smartthings.com/u/TAustin)\
**Post date:** [September 3, 2022, 1:54am UTC](https://community.smartthings.com/t/build-automations-based-on-device-online-offline-status/247216/3 "2022-09-03T01:54:47Z")

</div>

> [@Paul\_Oliver](#):
>
> you can also get the device numbers in [my.smartthings.com](http://my.smartthings.com) on the detail page for each device

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!

---

<div class="post-metadata">

**Author:** ![Automated\_House](https://yyz2.discourse-cdn.com/smartthings/user_avatar/community.smartthings.com/automated_house/32/99641_2.png) [@Automated\_House](https://community.smartthings.com/u/Automated_House)\
**Post date:** [September 3, 2022, 3:46am UTC](https://community.smartthings.com/t/build-automations-based-on-device-online-offline-status/247216/4 "2022-09-03T03:46:54Z")

</div>

Damn Todd! Do you ever sleep?!

---

<div class="post-metadata">

**Author:** ![Paul\_Oliver](https://yyz2.discourse-cdn.com/smartthings/user_avatar/community.smartthings.com/paul_oliver/32/195152_2.png) [@Paul\_Oliver](https://community.smartthings.com/u/Paul_Oliver)\
**Post date:** [September 6, 2022, 6:31pm UTC](https://community.smartthings.com/t/build-automations-based-on-device-online-offline-status/247216/5 "2022-09-06T18:31:21Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![christian\_turner](https://avatars.discourse-cdn.com/v4/letter/c/47e85d/32.png) [@christian\_turner](https://community.smartthings.com/u/christian_turner)\
**Post date:** [September 8, 2022, 12:45am UTC](https://community.smartthings.com/t/build-automations-based-on-device-online-offline-status/247216/6 "2022-09-08T00:45:43Z")

</div>

@TAustin, I’m struggling with your [EdgeBridge](https://github.com/toddaustin07/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](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](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](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

---

<div class="post-metadata">

**Author:** ![TAustin](https://yyz2.discourse-cdn.com/smartthings/user_avatar/community.smartthings.com/taustin/32/45058_2.png) [@TAustin](https://community.smartthings.com/u/TAustin)\
**Post date:** [September 8, 2022, 6:26am UTC](https://community.smartthings.com/t/build-automations-based-on-device-online-offline-status/247216/7 "2022-09-08T06:26:15Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![christian\_turner](https://avatars.discourse-cdn.com/v4/letter/c/47e85d/32.png) [@christian\_turner](https://community.smartthings.com/u/christian_turner)\
**Post date:** [September 8, 2022, 12:19pm UTC](https://community.smartthings.com/t/build-automations-based-on-device-online-offline-status/247216/8 "2022-09-08T12:19:55Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![DaWeav](https://yyz2.discourse-cdn.com/smartthings/user_avatar/community.smartthings.com/daweav/32/109130_2.png) [@DaWeav](https://community.smartthings.com/u/DaWeav)\
**Post date:** [September 8, 2022, 1:11pm UTC](https://community.smartthings.com/t/build-automations-based-on-device-online-offline-status/247216/9 "2022-09-08T13:11:06Z")

</div>

> [@Paul\_Oliver](#):
>
> I believe you can also get the device numbers in [my.smartthings.com](http://my.smartthings.com) on the detail page for each device.

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!

---

<div class="post-metadata">

**Author:** ![christian\_turner](https://avatars.discourse-cdn.com/v4/letter/c/47e85d/32.png) [@christian\_turner](https://community.smartthings.com/u/christian_turner)\
**Post date:** [September 13, 2022, 10:36pm UTC](https://community.smartthings.com/t/build-automations-based-on-device-online-offline-status/247216/11 "2022-09-13T22:36:36Z")

</div>

@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

---

<div class="post-metadata">

**Author:** ![TAustin](https://yyz2.discourse-cdn.com/smartthings/user_avatar/community.smartthings.com/taustin/32/45058_2.png) [@TAustin](https://community.smartthings.com/u/TAustin)\
**Post date:** [September 14, 2022, 3:08am UTC](https://community.smartthings.com/t/build-automations-based-on-device-online-offline-status/247216/12 "2022-09-14T03:08:25Z")

</div>

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!!

---

<div class="post-metadata">

**Author:** ![jjmucker](https://avatars.discourse-cdn.com/v4/letter/j/ecccb3/32.png) [@jjmucker](https://community.smartthings.com/u/jjmucker)\
**Post date:** [October 27, 2022, 10:18am UTC](https://community.smartthings.com/t/build-automations-based-on-device-online-offline-status/247216/13 "2022-10-27T10:18:16Z")

</div>

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](https://global.discourse-cdn.com/smartthings/original/3X/e/5/e564620ad8098405e46b8e86fb9a70e83e61b2fc.png)

Thanks.

---

<div class="post-metadata">

**Author:** ![TAustin](https://yyz2.discourse-cdn.com/smartthings/user_avatar/community.smartthings.com/taustin/32/45058_2.png) [@TAustin](https://community.smartthings.com/u/TAustin)\
**Post date:** [October 27, 2022, 3:53pm UTC](https://community.smartthings.com/t/build-automations-based-on-device-online-offline-status/247216/14 "2022-10-27T15:53:41Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![jjmucker](https://avatars.discourse-cdn.com/v4/letter/j/ecccb3/32.png) [@jjmucker](https://community.smartthings.com/u/jjmucker)\
**Post date:** [October 27, 2022, 4:03pm UTC](https://community.smartthings.com/t/build-automations-based-on-device-online-offline-status/247216/15 "2022-10-27T16:03:49Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![jjmucker](https://avatars.discourse-cdn.com/v4/letter/j/ecccb3/32.png) [@jjmucker](https://community.smartthings.com/u/jjmucker)\
**Post date:** [October 31, 2022, 7:48pm UTC](https://community.smartthings.com/t/build-automations-based-on-device-online-offline-status/247216/16 "2022-10-31T19:48:13Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![TAustin](https://yyz2.discourse-cdn.com/smartthings/user_avatar/community.smartthings.com/taustin/32/45058_2.png) [@TAustin](https://community.smartthings.com/u/TAustin)\
**Post date:** [October 31, 2022, 11:31pm UTC](https://community.smartthings.com/t/build-automations-based-on-device-online-offline-status/247216/17 "2022-10-31T23:31:02Z")

</div>

It would not get flagged as offline in that case.

---

<div class="post-metadata">

**Author:** ![jjmucker](https://avatars.discourse-cdn.com/v4/letter/j/ecccb3/32.png) [@jjmucker](https://community.smartthings.com/u/jjmucker)\
**Post date:** [November 8, 2022, 8:00am UTC](https://community.smartthings.com/t/build-automations-based-on-device-online-offline-status/247216/18 "2022-11-08T08:00:19Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![TAustin](https://yyz2.discourse-cdn.com/smartthings/user_avatar/community.smartthings.com/taustin/32/45058_2.png) [@TAustin](https://community.smartthings.com/u/TAustin)\
**Post date:** [November 8, 2022, 5:56pm UTC](https://community.smartthings.com/t/build-automations-based-on-device-online-offline-status/247216/19 "2022-11-08T17:56:56Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![montyfert](https://yyz2.discourse-cdn.com/smartthings/user_avatar/community.smartthings.com/montyfert/32/187267_2.png) [@montyfert](https://community.smartthings.com/u/montyfert)\
**Post date:** [November 8, 2022, 7:22pm UTC](https://community.smartthings.com/t/build-automations-based-on-device-online-offline-status/247216/20 "2022-11-08T19:22:24Z")

</div>

> [@TAustin](#):
>
> pinger app running on some other machine on your LAN, along with edgebridge, plus my LAN Presence

hi would this work with mobile phones

---

<div class="post-metadata">

**Author:** ![TAustin](https://yyz2.discourse-cdn.com/smartthings/user_avatar/community.smartthings.com/taustin/32/45058_2.png) [@TAustin](https://community.smartthings.com/u/TAustin)\
**Post date:** [November 8, 2022, 7:25pm UTC](https://community.smartthings.com/t/build-automations-based-on-device-online-offline-status/247216/21 "2022-11-08T19:25:50Z")

</div>

I have a [separate app](https://github.com/toddaustin07/phonepresence) that is meant to work with mobile phones.

[Next page](https://community.smartthings.com/t/build-automations-based-on-device-online-offline-status/247216.md?page=2)
