Getting a response back from sendHubCommand()

So, after a lot of feeling around, I have been able to get HubActions to fire from device types, but I’ll be damned if I can figure out the juju to make sendHubCommand for HTTP from a SmartApp work.

subscribe(location, null, handlerMethod, [filterEvents:false])

…doesn’t ever seem to give me back my LAN response, and I am not sure why. Before I punt on this and do something stupid like create a device just to make network requests, it anybody has some idea on what the problem is, that would be keen.

1 Like

That seems right. Have you logged the calls into handlerMethod to see what you’re getting? You need to parse the response in the method, but it should be getting called with whatever the hubAction returns.

Can you post a small test app showing what you’re trying to do?

Yeah. Literally the only thing I am getting back from my handler method is the “register” action for the smart app. I can see the request/response hitting my http server, so I know that is at least firing, but I am never getting my result back as a local event. :confused:

Here is the minimalist test I put together to try and debug this. (I added the runAt because I thought maybe there was something where I needed to wait for the register even to come back before I could even send the hub command:

def initialize() {
	log.debug "Initialize."
    subscribe(location, null, lanResponseHandler, [filterEvents:false])
    runIn(10, scan)

def scan(){
	def result = new physicalgraph.device.HubAction(
            method: "GET",
            path: "/rest/device/list",
            headers: [
                    HOST: "",
    log.debug result.toString()

def lanResponseHandler(evt) {
	log.debug "entering lanResponceHandler"
    log.debug ""

That seems correct to me :frowning:

Did you ever get this to work?

def initialize() {
subscribe(location, “ssdpTerm.ssdp:all”, ssdpHandler, [filterEvents:false])
// subscribe(location, “ssdpTerm.urn:schemas-upnp-org:device:Basic:1”, ssdpHandler)
// subscribe(location, “ssdpTerm.urn:schemas-upnp-org:device:ZonePlayer:1”, ssdpHandler, [filterEvents:false])
log.debug "initialized subscribed"

void ssdpDiscover() {
log.debug "LAN look"
sendHubCommand(new physicalgraph.device.HubAction(“lan discovery ssdp:all”, physicalgraph.device.Protocol.LAN))
// sendHubCommand(new physicalgraph.device.HubAction(“lan discovery urn:schemas-upnp-org:device:ZonePlayer:1”, physicalgraph.device.Protocol.LAN))

void ssdpHandler(evt) {
log.debug "ssdp handler called"
def description = evt.description
def hub = evt?.hubId

def parsedEvent = parseEventMessage(description)
parsedEvent << ["hub":hub]

def devices = getDevices()
String ssdpUSN = parsedEvent.ssdpUSN.toString()
if (!devices."${ssdpUSN}") {
    devices << ["${ssdpUSN}": parsedEvent]


I feel I’m close…
Not working yet, but no errors

Have you ever gotten this to work? I am trying the same thing