DTH for Lan connected PC

Hi all,
I’m looking to create a DTH which will forward all events hitting the SmartThings Hub to a HTTP server running on a LAN-connected PC.

Is this feasible?
Is there an example, or something similar which would serve as a starting point?
Could this work in an offline scenario where the ST cloud is unavailable, but the LAN is still up?


The communications and server part exist (would require Header modification for exact data) using NodeJS. The Hubitat Groovy code for server comms was:

private sendCmdtoHub(command, hubCommand, action){
	def headers = [:]
    def deviceIP = getDataValue("deviceIP")
    def gatewayIP = getDataValue("gatewayIP")
	headers.put("HOST", "$gatewayIP:8082")	//	Same as on Hub.
	headers.put("tplink-iot-ip", deviceIP)
	headers.put("tplink-command", command)
	headers.put("action", action)
	headers.put("command", hubCommand)
	sendHubCommand(new physicalgraph.device.HubAction([headers: headers], device.deviceNetworkId, [callback: hubResponseParse]))

The response method:

def hubResponseParse(response) {
	def action = response.headers["action"]
	def cmdResponse = parseJson(response.headers["cmd-response"])
	if (cmdResponse == "TcpTimeout") {
		log.error "$device.name $device.label: Communications Error"
		sendEvent(name: "switch", value: "offline", descriptionText: "ERROR at hubResponseParse TCP Timeout")
		sendEvent(name: "deviceError", value: "TCP Timeout in Hub")
		sendEvent(name: "DeviceWatch-DeviceStatus", value: "offline", displayed: false, isStateChange: true)
	} else {
		sendEvent(name: "deviceError", value: "OK")
		sendEvent(name: "DeviceWatch-DeviceStatus", value: "online", displayed: false, isStateChange: true)
		actionDirector(action, cmdResponse)

You can actually add /delete from headers.put to meet your needs.

You will need Node.js (free) on your server. The code I use on the server is below (it is overkill for your needs, but you will get the idea). location:


The link also has instructions on setting up. old, but they worked.

1 Like