Multiple hubaction commands in one function and parsing the response

no that’s not the point. You have to encode the address in hexa, remove the dot etc…

here is a code I use in a device I wrote:

def refresh() {
log.debug “Executing refresh”

def host = internal_ip 
def port = internal_port
def hosthex = convertIPtoHex(host)
def porthex = convertPortToHex(port)
//log.debug "The device id before update is: $device.deviceNetworkId"
device.deviceNetworkId = "$hosthex:$porthex" 

//log.debug "The device id configured is: $device.deviceNetworkId"

def path = internal_query_path
//log.debug "path is: $path"

def headers = [:] 
headers.put("HOST", "$host:$port")

try {
def hubAction = new physicalgraph.device.HubAction(
method: “GET”,
path: path,
headers: headers
)
state.requestCounter=1
return hubAction

}
catch (Exception e) {
	log.debug "Hit Exception $e on $hubAction"
}

}

You have to encode the IP and port using this function. This is also in the ST documentation

And you can check this: What Happened to deviceNetworkId? - #122 by heythisisnate

Example, for my device having 192.168.1.49 and port 80, the string that you pass to the sendhubcommand is: c0a80131:0050

1 Like