Help receiving HTTP Events from Raspberry Pi

I have built a two door Garage Door controller using a Raspberry Pi. I can open close/doors using HubAction. It works well except I have to poll the status, what I need is real-time events when the door status changes.

On an event I want to make HTTP requests from the RPi to the Hub. Inbound HTTP Requests are mentioned very very briefly at the bottom here:

Not much info, but I’ve added a endpoint mapping to the device type:

mappings {
  path("/GarageController/1/status") {
    action: [
      GET: "updateStatus"

And I get a callback address like this (which I pass to the RPi using HTTP):

def ip= device.hub.getDataValue("localIP")
def port= device.hub.getDataValue("localSrvPortTCP")

This gives me e.g. which does suggest that this port is ready to go. But when the RPi makes the HTTP status request a TCP SYN is sent, there is no ACK (checked with Wireshark) - it’s closed.

Why isn’t open? How do I open it?

Has anybody got HTTP events working? Or ideas? Or is there an example close to this that uses incoming HTTP requests?



Just curious, if you actually called HubAction(method: "SUBSCRIBE", ...
I suspect this where the the inbound port might get open. This is guessing, of course. Documentation is horrible indeed.

I will try that. It’s an interesting thought.

Indeed that did result in the socket. However I am fairly certain this is for upnp subscriptions, whereas I want simple Inbound HTTP Requests. Still it’s progress.

UPnP events are sent as HTTP NOTIFY messages with SOAP payload. But I don’t think that the hub does any parsing. If true, then entire response should be base64-encoded and handed to the SmartApp in the location event. So with some luck you should be able to use GET or POST. Keep us posted (pun intended :slight_smile: )

Thanks for the help. But in the end I gave up and did it via OAuth instead. It is a rather long winded way to move a message two inches across a shelf, but it’s relatively well documented and didn’t take long to integrate and get working.

OAuth is not too painful on an RPi either.

Stumbled on this thread while I was banging my head against a brick wall trying to get Inbound HTTP to work! Anyway, I would appreciate it very much if you could post your code for how you got ST to listen to events from RPi. Thanks.

1 Like

It’s here:

It’s not quite fit for human consumption, but it has been running perfectly since I last visited this thread. The latency from RPi > Smartthings > Hub is < 1 second so perfectly acceptable for this application.

garageController.js line 102 onwards is the OAuth notification.

Note: there are some hardcoded modifications in upnp-ssdp.

1 Like

Any chance anyone has figured out how to call the local ip with get/post ? I really don’t want to have my LAN service calling via the WAN url.

@tracstarr: The WeMo Motion device code uses the LAN events…from what I can tell. I have been trying to figure it out, but so far it’s beyond my ability. Hopefully someone can figure this out.

Thanks, i’ll check it out. If it doesn’t cause me convulsions like everything else - I’ll post back my results.

Did anybody look further into the Wemo motion device type (or find some other bi-directional HTTP framework) as an example of push+pull Raspberry Pi integration?

I see a few other examples of Wemo UPNP listeners out there (not for ST). This is a good post that should help us decipher what the Wemo Motion template is doing in the Groovy/ST context.


Here’s an RPi library that might provide similar (to the WEMO) features:

PiPoint - A simple DLNA control point

I have been playing a little with this and it works for a day or two and then stops updating in ST. It uses UPNP/SSDP.

Are you seeing this message logged when you run the app in the IDE?

log.debug "subscribeToDevices() called"

I notice that he did a commit only a few hours ago with this comment:

Unschedule all jobs prior to rescheduling subscribeToDevices

It looks, from the comment, as if the author intended it to run every ten minutes. This was changed in the most recent commit too.

schedule("0 */10 * * * ?", "subscribeToDevices")

I’m not so cron-savvy so I might try this form in my app:

1 Like