Edgebridge

Hi @TAustin,

I uninstalled the LAN Motion driver, rebooted my Hub, reinstalled the driver and did a scan…

The device was discovered and I entered the settings and entered the “LAN Device Name” with the exact short name from Blue Iris in the Alerts → Actions → On Alert → Configure Web Request or MQTT screen:

I then entered the “LAN Device Address” as 192.168.2.182 and then the “Bridge Address” as 192.168.2.182:8077, which resulted in the EdgeBridge picking up the new device:

Sat Oct 15 00:11:23 2022  POST request received from: ('192.168.2.199', 46224)
Sat Oct 15 00:11:23 2022  Endpoint: /api/register?devaddr=192.168.2.182&edgeid=xxxxxxxx-xxxx-xxxx-8d38-45a96ead543d&hubaddr=192.168.2.199:50885
Sat Oct 15 00:11:23 2022  Request to register device at ('192.168.2.182', None)
Sat Oct 15 00:11:23 2022  Registration record ADDED
Sat Oct 15 00:11:23 2022  Response sent
Sat Oct 15 00:11:23 2022  Updated registrations: [{'devaddr': ('192.168.2.182', None), 'edgeid': 'xxxxxxxx-xxxx-xxxx-914f-b30b0db52e51', 'hubaddr': ('192.168.2.199', 44823)}, {'devaddr': ('192.168.2.182', None), 'edgeid': 'xxxxxxxx-xxxx-xxxx-8d38-45a96ead543d', 'hubaddr': ('192.168.2.199', 50885)}]

I confirmed that the .registrations file was updated with the new record.

I then triggered the Alert from within BI and received the following in the EdgeBridge log:

Sat Oct 15 00:12:37 2022  GET request received from: ('192.168.2.182', 56258)
Sat Oct 15 00:12:37 2022  Endpoint: /BSMNTMAIN/motion/active
Sat Oct 15 00:12:37 2022  >>>>> Forwarding to SmartThings hub
Sat Oct 15 00:12:37 2022  Sending POST: http://192.168.2.199:44823/192.168.2.182/GET/BSMNTMAIN/motion/active to 192.168.2.199:44823
Sat Oct 15 00:12:37 2022  FAILED sending message to Edge hub ('192.168.2.199', 44823)
Sat Oct 15 00:12:37 2022  >>>>> Forwarding to SmartThings hub
Sat Oct 15 00:12:37 2022  Sending POST: http://192.168.2.199:50885/192.168.2.182/GET/BSMNTMAIN/motion/active to 192.168.2.199:50885
Sat Oct 15 00:12:37 2022  FAILED sending message to Edge hub ('192.168.2.199', 50885)
Sat Oct 15 00:12:37 2022  Response sent

I also had the CLI logcat running during the test but nothing was logged.

Sorry to be a pain… but can you please help?

1 Like

Looks like you have things configured OK, edgebridge is unable to send the HTTP message back to the hub for some reason.

Do you have a firewall running or anything that could be blocking communications out of your server? Is there anything unusual about your network configuration?

@netcsk - do you see anything wrong with @Belgarion’s Blue Iris config?

The BI camera config looks correct to me. As you say, it seems like a network issue or possibly a mistyped ip address.

That said, I switched BI to mqtt in home assistant (works in much the same way though) so I can’t directly confirm anything.

Try running edgebridge using edgebridge -d and see if you get any additional messages in the log.

Thank you for the suggestion, but I already am running EdgeBridge with the -d argument.

@netcsk I am certain that the IP address is typed in correctly.

@TAustin I will check my firewall settings.

Thank you both for taking a look.

Also, this morning my .registrations file is back to 0 bytes and it appears that after a certain number of failures EdgeBridge is removing my registrations… is that normal? Do I have to remove/add my devices each time this happens?

Sat Oct 15 11:02:47 2022  **********************************************************************************
Sat Oct 15 11:02:47 2022  GET request received from: ('192.168.2.182', 58216)
Sat Oct 15 11:02:47 2022  Endpoint: /BSMNT/motion/active
Sat Oct 15 11:02:47 2022  >>>>> Forwarding to SmartThings hub
Sat Oct 15 11:02:47 2022  Sending POST: http://192.168.2.199:45329/192.168.2.182/GET/BSMNT/motion/active to 192.168.2.199:45329
Sat Oct 15 11:02:47 2022  FAILED sending message to Edge hub ('192.168.2.199', 45329)
Sat Oct 15 11:02:47 2022  >>>>> Forwarding to SmartThings hub
Sat Oct 15 11:02:47 2022  Sending POST: http://192.168.2.199:39113/192.168.2.182/GET/BSMNT/motion/active to 192.168.2.199:39113
Sat Oct 15 11:02:47 2022  FAILED sending message to Edge hub ('192.168.2.199', 39113)
Sat Oct 15 11:02:47 2022  Response sent
Sat Oct 15 11:02:47 2022  Scrubbing registration record: {'devaddr': ('192.168.2.182', None), 'edgeid': 'xxxxxxxx-xxxx-40e8-914f-b30b0db52e51', 'hubaddr': ('192.168.2.199', 45329)}
Sat Oct 15 11:02:47 2022  Scrubbing registration record: {'devaddr': ('192.168.2.182', None), 'edgeid': 'xxxxxxxx-xxxx-4882-8d38-45a96ead543d', 'hubaddr': ('192.168.2.199', 39113)}

Yes, this is expected and I was going to warn you about that! After 3 send failures the registration is scrubbed.

To force a fresh registration, change the device address to something else temporarily in the LAN Motion device settings. Then change it back. Alternatively you could create a new device altogether using the button at the bottom of the Controls screen (may be missing the proper label).

@TAustin, I learned that the hard way… :laughing:

Okay, so it was my firewall. Once I added the exclusion I was able to get the registrations to come through… though I did have to reboot the hub in order to get EdgeBridge to pick up the changes/additions.

I now have both the “active” and “inactive” motion alerts working from BI to SmartThings for all 9 of my cameras!! :boom: :clap:

Thank you VERY much for your help!

Now I am moving on to LAN Trigger (or Web Requestor) to get my BI profile changing to work based on ST routines… :crossed_fingers:

4 Likes

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.

2 Likes

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