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:
This gives me e.g. 192.168.0.101:39500 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.
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 )
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.
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.
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.
@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.
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.