I’ve searched and found a few related threads that had various clues, but I just can’t get it to work. Many other people also had problems, a few got it to work, I found all their code on github (by searching for unique strings from their posted snippets), but I can’t see why one would work when another would not, or what I need to do.
What I want to do is interface a SmartApp with my Hikvision NVR - it’d expose various child devices that would allow snapshots to be taken. Hikvision have a proprietary API so I already knocked together a quick C-based CGI app that can be pinged over HTTP for my server, to get the number of cameras, or a snapshot of a specific camera.
As an experiment, I plumbed it in for channel 0, and it worked perfectly - but obviously, this limits me to channel 0, as the hub won’t allow additional smart devices attempting to talk to the same port on the server.
Obviously, HubAction and friends are kind of vaguely documented, but the basics appear to be:
subscribe(location, null, locationHandler, [filterEvents:false])
def data = getHostPathForInfo()
def deviceNetworkId = getHostAddress()
def action = new physicalgraph.device.HubAction("""GET $data HTTP/1.1\r\nHOST: $deviceNetworkId\r\n\r\n""", physicalgraph.device.Protocol.LAN, "${deviceNetworkId}")
log.debug action
sendHubCommand(action)
Running this code does report the query in the debug log, and the server does indeed receive the request and reply with the number of cameras. However, locationHandler is never called.
Consulting various examples, for the last parameter, some people pass in “1234”, some pass in hex ip:hex port, some simply pass in hex ip, and some pass in the remote device’s MAC address. I can’t remember but at least one of these is the Philips Hue support, which I assume works! However, I’ve tried all of these parameters, and nothing ever happens.
Is there anything else i need to do? Am I going to have to just create a child device to do all the network stuff, and have the smart app mediate between the “real” (child) device and all of the actual “image capture” child devices?
Thanks in advance for any guidance anybody may have