I have an ISY944 used to monitor my Smart Meter via Zigbee. (SmartThings cannot natively connect to Smart Meters). I am attempting to write a device handler to import data from the ISY REST interface every few seconds. I have had no luck getting callbacks to work. I expect after sendHubCommand I will see the script drop into calledBackHandler but it never does. I’d welcome any advice as to what I am doing wrong?
def energyRefresh() {
log.debug "Executing 'energyRefresh'"
getEnergy("calledBackHandler")
log.debug "END of 'energyRefresh'"
}
def getEnergy(String calledBackHandler) {
log.debug "Entered getEnergy()..."
sendHubCommand(new physicalgraph.device.HubAction([
method: "GET",
path: "/rest/emeter/metering/",
headers: [HOST: "$settings.userName:$settings.password@$settings.uri:80"]],
getNetworkId("$settings.uri","80"), [callback: calledBackHandler]))
}
void calledBackHandler(physicalgraph.device.HubResponse hubResponse) {
log.debug "Entered calledBackHandler()..."
def msg = parseLanMessage(description)
def headersAsString = hubResponse.header // => headers as a string
def headerMap = hubResponse.headers // => headers as a Map
def body = hubResponse.body // => request body as a string
def status = hubResponse.status // => http status code of the response
def json = hubResponse.json // => any JSON included in response body, as a data structure of lists and maps
def xml = hubResponse.xml // => any XML included in response body, as a document tree structure
def data = hubResponse.data // => either JSON or XML in response body (whichever is specified by content-type header in response)
log.debug "Status code: [${status}]"
log.debug "Body: [${xml}]"
}