HikVision doorbell cURL command not working from Home Assistant only

Dear All,

Since 4 January, I don’t know why but the following cURL command is no longer working from Home Assistant, although it used to work with no issues until then. The command purpose is to open a gate/relay embedded in a HikVision DS-KV6113-WPE1(B) doorbell:

curl -i --digest -u admin:password -X PUT -d '<RemoteControlDoor><cmd>open</cmd></RemoteControlDoor>' http://192.168.0.72/ISAPI/AccessControl/RemoteControl/door/1

The command works fine from other computers in the same LAN and the door opens (see the HTTP/1.1 200 OK response in the second text block):

MacComputer$ curl -i --digest -u admin:password -X PUT -d '<RemoteControlDoor><cmd>open</cmd></RemoteControlDoor>' http://192.168.0.72/ISAPI/AccessControl/RemoteControl/door/1
HTTP/1.1 401 Unauthorized
Date: Sun, 15 Jan 2023 20:49:59 GMT
Server: webs
Content-Length: 235
Connection: close
X-Frame-Options: SAMEORIGIN
Cache-Control: no-store
Pragma: no-cache
WWW-Authenticate: Digest qop="auth", realm="DS-DE07BCFB", nonce="----------JkY2ZhOTFmNGM0ZDc1ODg4NTFiYWEyZWE=", stale="false", opaque="", domain="::"
Content-Type: application/xml

HTTP/1.1 200 OK
Date: Sun, 15 Jan 2023 20:49:59 GMT
Server: webs
Content-Length: 295
Connection: close
X-Frame-Options: SAMEORIGIN
Cache-Control: no-store
Pragma: no-cache
Content-Type: application/xml

<?xml version="1.0" encoding="UTF-8"?>
<ResponseStatus version="1.0" xmlns="http://www.std-cgi.com/ver10/XMLSchema">
<requestURL>/ISAPI/AccessControl/RemoteControl/door/1</requestURL>
<statusCode>1</statusCode>
<statusString>OK</statusString>
<subStatusCode>ok</subStatusCode>
</ResponseStatus>

However, if I issue the command from Home Assistant Terminal, response is the following:

[core-ssh ~]$ curl -i --digest -u admin:password -X PUT -d '<RemoteControlDoor><cmd>open</cmd></RemoteControlDoor>' http://192.168.0.72/ISAPI/AccessControl/RemoteControl/door/1
HTTP/1.1 401 Unauthorized
Date: Mon, 16 Jan 2023 13:57:58 GMT
Server: webs
Content-Length: 235
Connection: close
X-Frame-Options: SAMEORIGIN
Cache-Control: no-store
Pragma: no-cache
WWW-Authenticate: Digest qop="auth", realm="DS-DE07BCFB", nonce="----------IzMGVjMDhhYjM5M2UyZTViY2EwODIyZWU=", stale="false", opaque="", domain="::"
Content-Type: application/xml

HTTP/1.1 401 Unauthorized
Date: Mon, 16 Jan 2023 13:57:58 GMT
Server: webs
Content-Length: 397
Connection: close
X-Frame-Options: SAMEORIGIN
Cache-Control: no-store
Pragma: no-cache
Content-Type: application/xml

<?xml version="1.0" encoding="UTF-8"?>
<ResponseStatus version="1.0" xmlns="http://www.std-cgi.com/ver10/XMLSchema">
<requestURL>/ISAPI/AccessControl/RemoteControl/door/1</requestURL>
<statusCode>4</statusCode>
<statusString>Invalid Operation</statusString>
<subStatusCode>invalidOperation</subStatusCode>
<errorCode>1073741830</errorCode>
<errorMsg>invalid operation</errorMsg>
</ResponseStatus>

This has been working for months with no issues, so I am wondering whether any of the latest HA updates has changed the way that cURL commands are being handled from Home Assistant. Any advice, please?

1 Like

I finally fixed the problem by checking doorbell communication with a browser. After some tests, I managed to get the following command which works with no issues. I cleaned it up a bit removing some headers which do not change command behaviour. Do feel free to try removing some other headers which probable don’t modify command results either. I am just too lazy to do it at the moment:

curl --digest -u admin:[PASSWORD] 'http://[DOORBELL_IP]/ISAPI/AccessControl/RemoteControl/door/1' -X 'PUT' -H 'Cache-Control: no-cache' -H 'Connection: keep-alive' -H 'Content-Type: application/x-www-form-urlencoded; charset=UTF-8' -H 'DNT: 1' -H 'If-Modified-Since: 0' -H 'Origin: http://[DOORBELL_IP]' -H 'Pragma: no-cache' -H 'Referer: http://[DOORBELL_IP]/' --data-raw '<RemoteControlDoor xmlns="http://www.isapi.org/ver20/XMLSchema" version="2.0"><cmd>open</cmd></RemoteControlDoor>' --compressed --insecure

On top of this, while I was doing some tests from the Live View page within the doorbell backend, I realized that there are two additional commands that can be useful for certain situations. I haven’t ever seen such commands in any forum, website nor the ISAPI protocol documentation:

COMMAND FOR OPENING THE GATE RELAY AND KEEP IT OPEN

curl --digest -u admin:[PASSWORD] 'http://[DOORBELL_IP]/ISAPI/AccessControl/RemoteControl/door/1' -X 'PUT' -H 'Cache-Control: no-cache' -H 'Connection: keep-alive' -H 'Content-Type: application/x-www-form-urlencoded; charset=UTF-8' -H 'DNT: 1' -H 'If-Modified-Since: 0' -H 'Origin: http://[DOORBELL_IP]' -H 'Pragma: no-cache' -H 'Referer: http://[DOORBELL_IP]/' --data-raw '<RemoteControlDoor xmlns="http://www.isapi.org/ver20/XMLSchema" version="2.0"><cmd>alwaysOpen</cmd></RemoteControlDoor>' --compressed --insecure

COMMAND TO RESTORE THE GATE RELAY

curl --digest -u admin:[PASSWORD] 'http://[DOORBELL_IP]/ISAPI/AccessControl/RemoteControl/door/1' -X 'PUT' -H 'Cache-Control: no-cache' -H 'Connection: keep-alive' -H 'Content-Type: application/x-www-form-urlencoded; charset=UTF-8' -H 'DNT: 1' -H 'If-Modified-Since: 0' -H 'Origin: http://[DOORBELL_IP]' -H 'Pragma: no-cache' -H 'Referer: http://[DOORBELL_IP]/' --data-raw '<RemoteControlDoor xmlns="http://www.isapi.org/ver20/XMLSchema" version="2.0"><cmd>resume</cmd></RemoteControlDoor>' --compressed --insecure

Hope this information helps!

2 Likes

I was wrong. Problem was not fixed. Commands are fine, because they work if I issue them from another computer. They worked for a few days from within HA, but now they do not work from if I issue such commands from the HA Terminal (they still work from another computer). I am starting to think that there is some sort of IP banning at some point that is causing this problem. Any advice?

Same here. :confused:

Command works from mac terminal bash, but not from linux.

Thank you! Good to know that I am not the only one experiencing this problem. Eventually, I removed all manual commands from the config, and I installed the HikVision Add-On, which it is working fine for the moment. Anyway, I would like to know the reason for the manual commands not to be working when they are executed from the HA system.

this is indeed the reason, but you already find my addon :slight_smile:

Thank you, the always open and resume command have been extremely useful for my use case.