Hi - I am trying to create a driver to open/command a door attached to a HikVision Facial Recognition device.
I read a couple of the discussions. My issue is similar to Tom's in this post.
The authentication instead of using digest, apparently still able to use the user:pwd@ip format still works. (for now).
I can send the command just fine via PostMan, and the door opens, but something in Hubitat is not sending the correct headers or body to the Hikvision device.
I sent the PUT also to webhook.site to see what I was sending in the request.
Everything looks OK (apparently), and I don't get any errors on the webhook.site either, I receive a 200 reponse.
Just a guess but I noticed in your Postman code that the xml contains double quotes around the values for version and xmlns, whereas in your code, you are using single quotes. Try replacing those with double quotes by using the escape character. For example,
HI @TomS - your observation did the trick! And even more, I removed the whole version='2.0' xmlns='http://www.isapi.org/ver20/XMLSchema' declaration, and worked the same too. But the definition of the body that contained the xml, worked without the [ ] .
Also - there was an error on the closure definition for the httpput which I fixed.
The complete code below for the function , and will link the code for the driver for anyone looking for HikVision door control to use it and improve anything if necessary !
Closure $parseResponse = { response ->
log.debug response.data
if (response.status == 200) {
sendEvent(name: "switch", value: "on", isStateChange: true)
sendEvent(name: "Door", value: "Open", isStateChange: true)
}
}
try { httpPut(parameterMap,$parseResponse)
}
catch (e) {
log.debug "Error Response : ${e.message}"
}
pauseExecution(5000) //time for door autoclose (must match the settings in the Hikvision config for autoclose. Time in ms)
off() // turn off-close door after time