I have a SmartThings DTH that controls a LAN device I’m trying to get ported over to a Hubitat Driver.
This is the original code section on ST:
def result = new physicalgraph.device.HubAction(
method: "GET",
path: "/?cmd=" + cmd,
headers: [
HOST: settings.ipAddress // Formatted as hostname:port
]
)
sendHubCommand(result)
I originally tried a few different methods of creating the HubAction object before finding a thread here that it’s not supported in Drivers.
Next thing I tried was using httpGet with the following code:
def params = [
uri: "http://${settings.ipAddress}", // Formatted as hostname:port
path: "/?cmd=${cmd}"
]
log.debug "params: ${params}"
try {
httpGet(params) { resp ->
resp.headers.each {
log.debug "Response: ${it.name} : ${it.value}"
}
log.debug "response contentType: ${resp.contentType}"
log.debug "response data: ${resp.data}"
}
} catch (e) {
log.error "something went wrong: $e"
}
I get the following logs:
dev:4 2018-03-01 16:28:45.894:debugresponse data: Bad Request
dev:4 2018-03-01 16:28:45.892:debugresponse contentType: text/html
dev:4 2018-03-01 16:28:45.890:debugResponse: Content-Length : 11
dev:4 2018-03-01 16:28:45.887:debugResponse: Connection : keep-alive
dev:4 2018-03-01 16:28:45.885:debugResponse: Date : Thu, 1 Mar 2018 16:28:46 GMT
dev:4 2018-03-01 16:28:45.882:debugResponse: Content-Type : text/html
I don’t have access to the services on the device to see the incoming request but I’m assuming either httpGet doesn’t work locally or the path parameters are not being sent correctly.
Any info available on getting local connections working in Drivers or is there a different way to go about this?
Thanks!