Edgebridge

Glad you worked through the issues and things are working. :+1:t3:

I’m curious if you made a change or if the Android SmartThings App was updated. Either way, I now see the label of “Create New Device” instead of “Untitled”. Yay!

1 Like

TAustin,

I have a couple of questions about your Edgebridge. First, do you have some screenshot examples of a device utilizing this to trigger HTTP POST/GETs; I think I could utilize this for my Hunter Douglas PowerView shades. Second, has there been any improvement in the phonetrack application? I would love to use this to add presence detection of family members who visit for the holidays. Third, can this be used to trigger scripts on the computer running the bridge and vice-a-versa? My imagined use case would be to use this to feed a humidity level to my RPi, and my RPi would time stamp it, run a script, and potentially change a bathroom fan based on how much the humidity has changed and over what time frame.

Thanks,
B

Hi there. I’ll try to answer your questions but it may require some more understanding and explanation on both sides to sort through these…

I’m not sure what you are looking for in a screenshot. There are various applications using edgebridge to send info to an Edge driver in order to update a SmartThings device. A screenshot of a SmartThings device would look like any other.

There are example usecases outlined in this README file.

Can you explain a bit more what you want to do with your shades? Are they already in SmartThings and you want to be able to notify an external app of state changes? Or is it the other way around?

The phonetrack app has been pretty stable. People with Android phones report that it’s pretty solidly reliable. iPhone users a bit less so, but it depends on their wifi configuration and expected response times for when the phone leaves or returns.

Yes, you can use this to trigger things between an Edge driver and a script on your computer. On the computer side, all you need is a simple Python script of a few lines to be able to either send HTTP requests or set up a listening server. On the Edge side of things you could either use something like my webrequestor in combination with some automation routines, an existing Edge driver designed to work with Edgebridge, or do some custom Edge driver.

Your fan example is a good one in that you are doing some ‘SmartApp-like’ processing on your Pi based on a SmartThings device state, and then turning on/off a fan. You could use edgebridge to accomplish what you want to do. Another alternative I’ll mention, because it might provide a more flexible platform, is to use MQTT.

1 Like

Wow, that was a rapid response!

I guess what I was getting at with the screenshots request was some example of how to program something within the SmartThings API to accomplish what I am doing prior to attempting it, or more likely, what the script I would need to write on my RPi to accomplish these things.

For instance, for the shades, currently there is a LAN device at my home that I can send HTTP POST messages to and it triggers an RF communication to the shade to open, close, open to a certain position, etc. I was wondering what would have to be modified within your lantrigger to create devices for my shades.

As for triggering the RPi and the RPi triggering a device on SmartThings, do you have examples of the python scripts I would have to modify to accomplish my funnctionality?

Well now you’ve brought up yet another way you could interact with SmartThings from a application on your Pi - the SmartThings RESTful API. You can use that to issue commands to devices from your app using simple GET/POST requests from a script. That could look something like this:

url = 'https://api.smartthings.com/v1/devices/' + self.id + '/health'
headers = {}
headers['Authorization'] = 'Bearer ' + MYSMARTTHINGS_TOKEN
headers['Host'] = 'api.smartthings.com'
headers['Accept'] = '*/*'
headers['User-Agent'] = 'devstatmon'
			
r = requests.get(url, data='', headers=headers, timeout=5)

The shortcoming in just using the RESTful API is that there is no asynchronous notification to your app of state changes for a SmartThings device. In order to get that, you have to write your application as a SmartThings SmartApp and use their SDK to interact with SmartThings. You’ll have to code it in nodeJS, but can SUBSCRIBE to device state changes and get notified when they change. If you want to see an example SmartApp using this SDK, check out the tutorials here in this community, or you can look at one of my SmartApps here, which was written to run on a Raspberry Pi using ngrok. Maybe more than you want to get involved with…

Here is an example of a python app that periodically pings IP address and sends an http message to an Edge driver to update presence status.

An example of a Pi app GETTING triggered by an Edge driver would require a script that implements a simple server to listen at a certain port number. This scenario actually wouldn’t require Edgebridge. You could do any http request from SmartThings (either from webrequestor or custom device driver) directly to your app; you just have to know the IP and port.

If you want to create shade devices in SmartThings that send HTTP post messages to your shades, you could accomplish this in a few ways. With no programming, you could create a virtual shade device (use my vEdge driver), and in combination with my webrequestor driver you could create automation routines to trigger http requests based on the virtual shade states. More elegant solution would be to have a custom shade driver that accomplishes the same without the automations.

1 Like

That vEdge driver and webrequestor driver combo may not be an elegant solution, but it gets the job done with minimal effort on my part, and could be used to help me write a custom driver down the road that’s a bit more elegant.

Todd, I setup edgeBridge on a RPi4 and have it successfully connected as I see the edgeBridge Monitor device status as online. I ran the standalone phone presence script and it worked perfectly, but on the SmartThings version I’m getting a [Errno 111] Connection refused when it’s pinging the phones. Thoughts?

Can you give me the whole error message? I’d like to see what line number it is occurring at. It could be when it is attempting to send the ping request to the phones, or it could be when it is trying to connect with edgebridge.

I assume you terminated the standalone version before you ran the SmartThings version?

Do you have any firewalls or anything else configured that might prevent the edgebridge connection? It doesn’t really make sense that the standalone version works, though, so I’m just trying eliminate other variables.

Never mind. Somehow I deleted the first square bracket on the configuration file and that was messing it up. I replaced it and voila it works perfectly. Thank you so much for developing this, I’ve wanted this functionality for a LONG time.

1 Like

Todd, what are your thoughts on making your lantrigger device a device with 50 momentary switches akin to your web requester device? Instead of spawning 50 devices you could have a single device that listens for 50 unique triggers coming from a single source and the post request instead of being …/trigger would be …/triggerN.

Also, you haven’t really publicized your rpi-st-device on here. Does that device allow you to read the state of devices from the RPi? I’m trying to detect the humidity in my bathroom for a routine that can’t be encoded in SmartThings. Right now I can imagine passing this information to my RPi with a series of routines that send the humidity via your web requester device; unfortunately I can’t pass dynamic variables with SmartThings routines, so I’ll have to have one routine for 52% humidity, one for 53%, etc.

It is definitely possible to do. But one thing to consider: just like there are SmartThings limits to the number of drivers and devices, there are also limits to the number of routines. In fact, it’s funny you bring this up because I’ve already had requests regarding webrequestor to have dedicated devices due to hitting the automation routine limit. So it’s kind of like you can’t win either way :slight_smile: . I’ll consider creating a ‘LAN Trigger Multi’ driver to do this, but it may be a couple weeks before I can get to it.

This package allows you to create device applications on your Pi that interface with SmartThings in a very different way - directly through their cloud server, instead of locally to an Edge driver. See the SmartThings description for this schema here.

Regarding your bathroom humidity project, so I am clear, do you already have a SmartThings-integrated device that is getting your humidity levels? And you want to pass them over to an app running on your Pi and do something with them? Then what does the Pi do with that data? Does it have to send something BACK to SmartThings or is it only a consumer of the data?

I have gotten a request to create a series of ‘virtual’ devices that can be configured to send http requests (similar to what I’ve done for MQTT). It sounds like you might find value in that, if it included a humidity device. An alternative is MQTT, which it really sounds like you should consider if you have various projects where you want to be sending data back and forth between an app on your Pi and SmartThings. I have a couple different MQTT solutions that could help you do this. It’s very simple to have a MQTT broker like Mosquitto running on your Pi that can provide this capability.

Otherwise, I think the problem you are pointing out with having to create separate routines for specific values, in conjunction with webrequestor, is a messy one indeed.

1 Like

Todd, thanks as always for your amazing work and continued support. I think MQTT will indeed be the way I go.

I currently have a combo temperature and humidity sensor in my bathroom near my shower head. I’m trying to detect when the shower turns on by detecting a rate of humidity increase, and not rely on absolute numbers as the baseline humidity fluctuates throughout the year. I envision a rule that detects when the humidity has risen by greater than or equal to 5% relative humidity in the span on 10 minutes or less.

I guess a custom SmartApp could take care of this, but I’m not familiar with programming those and would much rather write something in Python running on my RPi4.

I envision utilizing your Web Req Multi Master device to trigger (every time the humidity changes) a script running on the Pi that grabs the humidity from the appropriate sensor and time stamps it. Then it looks back and identifies what the humidity was 10 minutes ago, and if it’s increased enough would then trigger the appropriate bathroom fan on, which I can do with your LAN Device Trigger, although I could probably also do it via MQTT.

Todd, are your vEdge and webrequestor drivers open source? I’m trying to write a driver for the Hunter Douglas PowerView generation 1 & 2 shades, and it’d be much easier to write it if I could borrow chunks of code rather than learn Lua from scratch. Thanks!

Many of my solutions are available as open source in my github repository. Should be plenty of things there you can lift from!

2 Likes

You might be interested in this: [ST Edge] Web Requestor: a driver to issue local POST and GET HTTP requests - #340 by TAustin

@TAustin I’m successfully using the Edgebridge, with LanMotion and wondered if you would consider creating a ‘LanContactSensor’ driver. I read you implemented the contact sensor capability in Shelly Motion but it was removed… I have tried myself by taking LanMotion and converting it to a contact sensor and everything works but I cannot get ‘open’/‘close’ to present in the dashboard, it just states ‘Connected’, I think its something to do with the metadata (vid) being the same as LanMotion, I’m happy to learn but I’m not a developer and think I’m not far off my technical limit. I see (and appreciate) you’ve got lots going on and I only ask as I think this would be a fairly quick thing (for you) to do.

I could probably knock this out within the next few days. Let me get back to you.

You may have already seen this, but this limit was just raised this week from 200 to 1000. :sunglasses:

Smart Lighting (new plugin version) - #23 by vlad

3 Likes

Good to know, thanks!

1 Like