HTTPS requests to local devices using HubAction?


(Shafiur Rahman) #1

Hello, I was trying to control some devices with HTTPS API in my local network using virtual switches. I’ve seen examples for http requests using HubAction. Is there any way I can send the requests using https? Certificate validation isn’t necessary (same as ‘curl -k’). I don’t want to expose the IPs to the WAN.
Is there any way to achieve what I want? Thank you.


(Minollo) #2

Considering the hub and your devices are all in your LAN, why do you need HTTPS? You don’t need to expose ports to the WAN.
That said, I did try in the past making https hubactions work, but I failed. There may well be a way to do it.


(Dave Gutheinz) #3

I do this in my unofficial Samsung Audio integration using HubAction. It comes across the LAN as a HTTP (vice HTTPS). See thread: {BETA} Samsung Audio including TTS with Voices

The command path is:

smartPhone -> SmartThings ‘Device’ -> SmartThings Hub -> device

Response path is: device -> SmartThings Hub -> SmartThings ‘Device’ ‘action’ parse method.

The Setup:

def on() {
	SetPowerStatus("1")
	sendEvent(name: "switch", value: "on")
    play()
    updateDisplay()
}

The device-code (already in url format).

def SetPowerStatus(powerStatus, action = "generalResponse") {
	sendCmd("/UIC?cmd=%3Cname%3ESetPowerStatus%3C/name%3E" +
			"%3Cp%20type=%22dec%22%20name=%22powerstatus%22%20val=%22${powerStatus}%22/%3E",
			action)
}

The hub-action command

private sendCmd(command, action){
	def deviceIP = getDataValue("deviceIP")
	def cmdStr = new physicalgraph.device.HubAction([
		method: "GET",
		path: command,
		headers: [
			HOST: "${deviceIP}:55001"
		]],
		null,
		[callback: action]
	)
	sendHubCommand(cmdStr)
}

Dave


(Shafiur Rahman) #4

The devices have only HTTPS API? I have no control over it. I need a chain of GET/PUTs to the devices to do the tasks I want, which I am now doing from AWS Lambda using port forwarding, but the latency is too long for my taste.
I thought doing the exchanges locally would make it much faster.


(Shafiur Rahman) #5

Thanks Dave, I tried this example. It works with a HTTP endpoint. But with my devices, the callback method is never invoked since they only respond to HTTPS.


(Dave Gutheinz) #6

I have a device handler - smaart app combo that uses node.js on the my LAN. Requires a “server - hub” running the Node.js app. This could do it for you and I have the base code (for TCP (Node.js also supports HTTPS). Example is at

The path is simple: phone App -> SmartThings Cloud -> hub -> node.js server (using HTTP) -> device

Then reversed. You could do the reverse path.

I also have some depreciated code that provided the bridge only.

These were developed because hubAction does not support TCP nor UDP (sound familiar?). Maybe this will help.