Server Sent Event. Is it possible?

It’s not enough to just render a page with the right content type. The server needs to actually keep the connection open indefinitely.

As far as I know, SmartThings only provides a REST endpoint. There isn’t a way for you to use WebSockets or even Server Sent Events. There is still a chance that this is just completely undocumented, undiscovered functionality that is already provided, but I wouldn’t hold my breath for it.

Maybe you can come up with some form of true long polling. Not sure how you would do it without executing at least the REST callback, or the event handlers asynchronously.

Lastly, you could just try banging on the REST endpoint every second or so. Possibly have a GET handler called /hasnewevents to act as a very lightweight gating mechanism before you trigger a full refresh on the client side. Not sure to what degree the ST cloud will tolerate this, though.

EDIT: The lack of SSE or WebSockets btw is exactly why I did it this way with having the app backend live on a remote host that is easily reachable by the SmartApp.

1 Like