Can I send UDP commands?

Hi Guys,

I’m wanting to send out some UDP commands - I’m quite happy for them to be blind and I’m not bothered about catching any returned data.

Is this possible in SH?

I currently have some code like below, but I’m not seeing anything on a local terminal running nc:

def off() { def cmd = "001,!R${settings.roomId}D${settings.deviceId}F0" def ip = "${settings.ip}:9760" log.debug "Executing 'off':\r\n${cmd}\r\nHOST: $ip\r\n\r\n" def hubCmd = new physicalgraph.device.HubAction("${cmd}\r\nHOST: $ip\r\n\r\n", physicalgraph.device.Protocol.LAN) hubCmd.options = [type:"LAN_TYPE_UDPCLIENT"] sendHubCommand(hubCmd) }

Recommended reading:
https://community.smartthings.com/search?q=udp

Which one specifically?

Some suggest it can’t be done, others say it’s not supported, the top one states it can be done but I can’t get the code to work.

I’ve even seen something stating that it’s available but unsupported.

Does anyone have the definitive answer to this?

The official answer is it’s not supported, there are code samples in the threads, feel free to try them out. At best it will be one way like TCP, so you won’t get a response back. I don’t know of any actual working UDP device types, but that doesn’t mean it’s not possible, it just means it hasnt been done… yet.

And that’s exactly the point of this thread. I was asking if anyone has the answer. I expect it to be possible (although happy to be proven wrong), just not documented or supported.

I’ve tried some of the code snippets, as per the code in my original question but to no avail.

I’m stuck, and without some input from someone in the know I’m probably going to have to knock up a web service as a middle man.

Best to have a middle ware handle UDP for the time being, current UDP support appears to be broken, undocumented and unsupported (if / when it works).

Create a simple restful API that sends your UDP commands and run it on a PI or something easy to manage and your life will be a lot happier.

Thanks @pstuart - I’m trying to have the fewest dependencies possible.

I’ve written a simple REST api which sends out UDP and added a DeviceType to call my local lan API. It all works, but it’s stuff I’d much rather do on the ST unit directly.

I have some small amount of experience here that may help some of you. LWRF Remote servers are inconsistent to say the least. Local control is preferred at all times even going so far to setup a VPN rather than relying on the LWRF server.

Some years ago I played with Raspberry Pi SBCs, linux and this : http://www.tinkerfailure.com/lightwaverf-php-script/ along with Tasker to enable a voice activated Smart Home thing, you’ve no doubt have seen on Youtube. This script will act as the perfect http to UDP ‘bridge’ and can simply be run on a Raspberry Pi Zero costing no more than £10 and using hardly any electricity.

Having said that, the lights and power sockets are one way so if ST can send UDP, that’ll do for now.