Is it really possible to write a Device Type/SmartApp that talks to a LAN Device

I’ve read lots of the forums and many people attempting to connect to LAN devices on TCP and some on UDP on Hub V2 but on the whole it appears the community struggles. I think the underlining reason may be local processing not being available unless the SmartApp or Device Type is whitelisted by SmartThings. Threads that appear to work seem to open up local ports to the internet through their router affectively making it a cloud device.

So I would like to ask does this mean the community can’t develop LAN connecting devices because writing them are tricky without the ability to verify locally and/or debug. Has anyone managed to get a local processing SmartApp or Device Type published through SmartThings?

I want to communicate with a Raspberry Pi to relay messages to a UDP device but it looks like I might need to go the Zigbee/Zwave route with an additional module which clearly must run via the hub. I’m in the UK so the SmartThings Shield isn’t available.

1 Like

Officially, only HTTP is supported over LAN connection. And even that has its limitations.

1 Like

This is not officially supported but it works within the context of an App (for some reason it does not work within device type code). The following code snippet will send a string to a destination tcp port 1111 on ip address 1.1.1.1.

sendHubCommand(new physicalgraph.device.HubAction("Whatever string\n",
   physicalgraph.device.Protocol.LAN, toHexNetwork("1.1.1.1", 1111)))

private String toHexNetwork(ipad, port) {    
    String ipInHex = ipad.tokenize('.').collect {
        String.format('%02X', it.toInteger())
    }.join()

    String portInHex= String.format('%04X', port)
    return "${ipInHex}:${portInHex}"
}

@Tim_Flinders the limitation isn’t the local / cloud challenge, nor is it UDP. Unfortunately, its the ST parser functionality won’t process the response from your device unless it’s well formed HTTP (html, json, XML) and thus, won’t pass it into your device parse() function.

You can still execute blindly into the device though. If you check out my Yamaha or Sharp devices, they work that way.

thanks @Kristopher I’ll take a look at your Yamaha and Sharp devices. Obviously if you are talking to an amp on the LAN it must be running locally.

thanks @zraken I might have a go with this, be interesting to see if I can get a message across.

can you post a link to those? I cant find your Yamaha code in the published device type

2 Likes