Hi there,
i’m brand new to ST and trying to build a test device handler, that will just ask an HTTP web site. for now i’m not even able to get the hubaction to execute. and show anything in the log.
is there anything missing/or I need activated to see something coming to the parse, or ensure hubaction iis executed ?
preferences {
section(“When the following is turned on and off…”) {
input name: “master”, title: “Which Switch?”, type: “capability.switch”, required: true
}
}
Parse is called when a real device is communicating something, that will not happen. You need to invoke doSomething from on or off or something similar. The best way to have control is to specify a callback handler on the sendhubcommand.
tried it, the thing is I don’t get any single packet flowing from the hub to the web server. can you share an absolutely basic request to get a response from a web server ?
and still can’t see any ppacket flowing from the hub, getting to my web server.
is there any basic ting i’m missing? like enabling dev. mode or something similar ?
At the end of your sendHubCommand you are missing one final important parameter, the IP and Port in Hex. So after …LAN, HexIP:HexPort))
At least that worked for me a long time ago. Thus is the old post that helped me:
Edit: search the community for the Java toHexString method that can help you convert the IP. Here is an example from one SmartApp. Remember both IP and Port need to be in Hex.
Thanks,
tested as well by adding the ipaddress in hex, but seems nothing can get out of this hub. the weird thing is that I tried through Internet (after publishing the server on the web), by using httpget. and everything works perfectly.
You can still set the DNI in code, however it takes a little work if you’re trying to do so from within the “updated()” routine in a Device Handler. Here is my workaround for setting the DNI. I have to schedule the DNI to be updated using the “runIn” command. Must be either a race condition or a calling context issue.
Note, the “updated()” routine gets called twice every time you save the settings of the device, thus there is a workaround for that as well to prevent it running if it already ran within the last 5 seconds.
Note: “mac” is set as a “preference” as follows:
preferences {
input "ip", "text", title: "Arduino IP Address", description: "IP Address in form 192.168.1.226", required: true, displayDuringSetup: true
input "port", "text", title: "Arduino Port", description: "port in form of 8090", required: true, displayDuringSetup: true
input "mac", "text", title: "Arduino MAC Addr", description: "MAC Address in form of 02A1B2C3D4E5", required: true, displayDuringSetup: true
}
def updated() {
if (!state.updatedLastRanAt || now() >= state.updatedLastRanAt + 5000) {
state.updatedLastRanAt = now()
log.debug "Executing 'updated()'"
runIn(3, "updateDeviceNetworkID")
sendEvent(name: "numberOfButtons", value: numButtons)
}
else {
// log.trace "updated(): Ran within last 5 seconds so aborting."
}
}
def updateDeviceNetworkID() {
log.debug "Executing 'updateDeviceNetworkID'"
if(device.deviceNetworkId!=mac) {
log.debug "setting deviceNetworkID = ${mac}"
device.setDeviceNetworkId("${mac}")
}
//Need deviceNetworkID updated BEFORE we can create Child Devices
//Have the Arduino send an updated value for every device attached. This will auto-created child devices!
refresh()
}
To see my full Device Handler example for communicating with an Arduino via the hub, see below. Please note that I am not communicating with a standard web server, but rather a custom app running on an Arduino.