WebSockets in SmartDevices

I know a SmartDevice can use HTTP, any chance they can connect via WebSockets?

1 Like

Well, groovy supports websockets. So… maybe?

1 Like

No, no chance. Been there, done that.

2 Likes

On the LAN? Cloud? Or both?

I haven’t a clue, but love the question.
I know (?) some non-trivial part of the LAN networking protocols (TCP, HTTP, device discovery?) is implemented in firmware on the Hub, so no amount of Groovy can overcome limitations in the hub stack. I wish we had detailed specs, right?

For the same or similar reason, there’s no UDP support. It can’t just pass all the packets to the Smart Cloud and there’s more than just “wrapping” going on…

Hub V2 is Linux based, so it may be easier for ST to accommodate more modules and protocols.

1 Like

Cloud only, it’s to connect to another web service that only does WebSockets.

In that case, it must depend on what is allowed in the Groovy “Sandbox” the Community Developers are allowed to play-in. On the Developer Conference Calls, etc., we’ve asked for a list of all the permitted library modules that we can load, but not been given an answer.

http://docs.smartthings.com/en/latest/introduction/groovy-the-smartthings-programming-language.html#groovy-sandboxing

1 Like

What API is it?

Also depending on how the api is set up you may run into the execution timeout issues if the API is intended to be a streaming thing.

2 Likes

It can be done, just major limitations. Might need to route the requests through a smartapp and only via IP address via local hubaction, but it can be done. Even UDP.

1 Like

I was able to hook into the Water Furnace API, which is WebSocket only, and mess with it.

It’s not device friendly since it’s a constant connection. To get around this I’ve setup a local app that “proxies” the data so it doesn’t beat up ST. Basically it takes a simple Get request, does a few small WebSocket calls & returns the data back.

Kind of an HTTP -> WS -> HTTP proxy. Just to play around with it.

2 Likes

Could you share the code ?