I’m struggling to get the callback on sendHubCommand to actually work. I’m connecting to a WiFi enabled Arduino. When I send the command, the Arduino is receiving the http command and enabling the GPIO port that I’m expecting. The Arduino sends a response back with a status of the device, but I never get response in the DeviceHandler. Neither the parse or calledBackHandler methods ever get invoked. I have confirmed the response from the Arduino is responding using Postman.
The device is just a minimote so I have a push event on a button:
def push1() {
sendEvent(name: "lblPush2", value: "default", descriptionText: "", isStateChange: true, displayed: false)
sendEvent(name: "lblPush3", value: "default", descriptionText: "", isStateChange: true, displayed: false)
def deviceNetworkId = "84:F3:EB:B4:96:CE" // "192.168.1.160:80"
// The deviceNetworkId is the MAC address
def ip = "192.168.1.160:80"
sendEvent(name: "button", value: "pushed", data: [buttonNumber: 1, action: "pushed"], source: "COMMAND", descriptionText: "$device.displayName button 1 was pushed", isStateChange: true)
log.debug("Sending HTTP")
return sendHubCommand(new physicalgraph.device.HubAction("""GET HTTP/1.1 /?gpio=$buttonIndex\r\nHOST: $ip\r\n\r\n""", physicalgraph.device.Protocol.LAN, "${deviceNetworkId}"))
//pushed(1)
}
I’ve tried using sendHubCommand without saying return, then I’ve tried defining the optional param to explicitly set the call back to parse or calledBackHandler.
Parse method implemented:
def parse(description) {
log.debug(“parse called”)
//def msg = parseLanMessage(description)
//log.debug($description)
sendEvent(name: "lblPush2", value: "pushed", descriptionText: "", isStateChange: true, displayed: false)
}
calledBackHandler implemented:
void calledBackHandler(physicalgraph.device.HubResponse hubResponse) {
log.debug(“call back called”)
sendEvent(name: "lblPush3", value: "pushed", descriptionText: "", isStateChange: true, displayed: false)
}
In the parse and calledBackHandlers I put log lines and changed the state of 2 other buttons, just as debugging steps to see if it’s actually calling the methods. Neither the log lines show up in the IDE nor do the buttons change their state on the device, so I’m only left to assume the methods are not being called and/or the sendHubCommand doesn’t know how to handle a HTTP response. Anyone had any luck with something similar? I’ve followed probably over a dozen different posts trying various methods as well as Samsung’s documentation, or lack thereof, and I’m just not getting a response back into SmartThings.