Feature Request: Server-Sent Events

It would be great to have support for server-sent events (http://dev.w3.org/html5/eventsource/), which could allow SmartApps to forward events (temperature changed, contact opened/closed, motion detected/ceased, etc.) to clients, extending the existing endpoint capabilities. I believe this would also free up resources on the SmartThings Cloud, which are currently tied up by endpoint clients having to continuously poll for new data rather than simply waiting for server-sent events.

SmartThings Apps already are capable to forward events. IFTTT is a good example. It can send or receive to and from SmartThings.


IFTTT has to poll for new events by sending a GET request, doesn’t it?

That’s a perfectly reasonable way of handling events, but requires finding a sweet-spot for the polling interval. Even then, you’d either be wasting network resources when polling despite no relevant events have been created, or handling events with a delay if the interval is too large.

With Server-Sent Events, the ST cloud would notify the client of the new event, rather than relying on the client to continuously poll for new events.

Please, correct me if I am wrong and IFTTT does indeed do something “smarter” than polling for new events.

I don’t know what IFTTT does, but if you write your own API app (which is the paradigm used by the php endpoint tutorial), you can register for events you care about in your groovy app and when they fire, send http requests from the app to your custom endpoint.

The docs here have been extremely helpful to me in my own development, and they list, among other things, the standard REST request functions. I have not actually used them yet myself, though, so I can’t say for sure that they work…but the functionality I think you’re asking for is documented as already existing.

Try it out and let us know!

I’ve been trying to do the same, but I’m running into many painful issues. The most recent being the 15s app execution timeout. I was trying to register about 12 callbacks for attributes on sensors, and the app times out. Looks like theres some underlying problem with the execution speed of subscribe. This would prevent anyone from trying to create a relay app, to relay events for all devices out of ST.


If you want you can PM me your code. I may have an idea to streamline your callback issue.