DS-KD8003 - DS-KV8113 - DS-KV8213 - DS-KV6113 - DS-KV8413 and .... integration Hikvision HikConnect Video intercom doorbell

Hi, this thread is all about the possibility to integrate commands in HA, Local commands, but i also now added commands for Cloud, based on HikConnect APP, see below
Confirmed devices : DS-KV8413, KD8003 and DS-KV8113 KV8213 DS-KV6113

What is working so far …
Video Stream rtsp:

rtsp://user:[email protected]168.0.xx:554/ch1/main/av_stream
rtsp://user:[email protected]:554/Streaming/Channels/101
rtsp://user:[email protected]:554/Streaming/Channels/102
rtsp:/user:[email protected]:554/cam1/h264

ISAPI command : Open a door / Relay

To open an electrical door (relay 1 or 2)
curl -i --digest -u admin:xxx -X PUT -d '<RemoteControlDoor><cmd>open</cmd></RemoteControlDoor>' http://192.168.0.xx/ISAPI/AccessControl/RemoteControl/door/1

ISAPI command : Doorpress event
To capture a doorpress event for 8003 owners : (custom firmware is needed AND FACTORY RESET )

curl -i --digest -u admin:xxxx http://192.168.0.70/ISAPI/VideoIntercom/callStatus?format=json&channelType=tripartitePlatform

for other models:

curl -i --digest -u admin:xxx http://192.168.x.x/ISAPI/VideoIntercom/callStatus?format=json

Should give as output : “idle” , “ring” , “onCall”

{
"CallStatus":{
"status": "idle"
}}

Based on :

Example Rest Sensor

- platform: rest
  name: Doorbell Status
  authentication: digest
  username: admin
  password: <password>
  scan_interval: 1
  resource: http://192.168.0.XXX/ISAPI/VideoIntercom/callStatus?format=json
  value_template: "{{ value_json.CallStatus.status }}"

ISAPI command : Event stream
For events like door opened/illegal badge swiped … , also for DS-KD8003 owners, the CUSTOM firmware is needed
this command, should give a stream, example ISAPI below

"curl -i --digest -u admin:xxx http://192.168.0.70/ISAPI/Event/notification/alertStream"

{
	"ipAddress":	"192.168.0.70",
	"portNo":	80,
	"protocol":	"HTTP",
	"dateTime":	"Wed, 28 Jul 2021 20:36:29 GMT",
	"activePostCount":	1,
	"eventType":	"AccessControllerEvent",
	"eventState":	"active",
	"eventDescription":	"Access Controller Event",
	"AccessControllerEvent":	{
		"deviceName":	"DS-KD8003",
		"majorEventType":	5,
		"subEventType":	25
	}
}

example script, to intregate this alert stream , see also post 527

from requests.auth import HTTPDigestAuth
from datetime import datetime
import requests
import time
import json
#Variables
username = "admin"
password = "XXX"
url = "http://YOUR_IP/ISAPI/Event/notification/alertStream"
headers = {
    'Authorization': 'Bearer ¨XXXXX',
    'content-type': 'application/json',
}
url_states = "http://localhost:8123/api/states/"
sensor_name = "sensor.hikvision_door"

#Creating Sensor
try:
    timestamp = str(datetime.now())
    data = json.dumps({'state': 'off', 'attributes': {'Time': timestamp}})
    response = requests.post(url_states + sensor_name, headers=headers, data=data)
    print("Creating Sensor on start script")
except:
    print("Creating Sensor Failed")


while True:
    try:
        stream = requests.get(url, stream=True, auth=HTTPDigestAuth(username, password))
        print("Status code: " , stream.status_code)
        for line in stream.iter_lines(chunk_size=1):
            str_line = line.decode("utf-8", "ignore")
            print(str_line)
            #Check for event
            if str_line.find('"subEventType":	25') != -1:
                result = str_line.find('eventState')
                print("Found event!")
                try:
                    timestamp = str(datetime.now())
                    data = json.dumps({'state': 'on', 'attributes': {'Time': timestamp}})
                    response = requests.post(url_states + sensor_name, headers=headers, data=data)
                    print("Door Open")
                    #put the sensor "on" for 5 seconds
                    time.sleep(5)
                    timestamp = str(datetime.now())
                    data = json.dumps({'state': 'off', 'attributes': {'Time': timestamp}})
                    response = requests.post(url_states + sensor_name, headers=headers, data=data)                    
                    print("Door Closed")
                    continue
                except:
                    print("Updating sensor failed")
                    continue
        if stream.status_code == 401 or stream.status_code == 403:
            time.sleep(5) 
    except (ValueError,requests.exceptions.ConnectionError,requests.exceptions.ChunkedEncodingError) as err:
        print("Connection Failed")
        continue

**SDK Project **
Another cool project is using the SDK, here is a great project created by @laszlojakab

See here for add-on

There is also now an HikConnect integration based on cloud and work in progress:

8 Likes

I have this model, at the moment I’ve been able to integrate the camera through the RTSP stream.
Did you buy it eventually? How far have you got with the integration in Home Assistant?

Yeah bought it ,together with indoor…
No integration possible i think, but I have the camera stream in HA.

And on indoor station, i have an relay connected to my ESP board, so when someone presses the doorbell i can work with notifications and also start recording with synology and steam video to google hub…

Also, i was able to setup those stations with a SIP PBX server, it you don’t want to use Hikconnect app…
Because I was unable to find to change a ringtone there… Also if you use Hikconnect, it always activates speaker mode… So there is always an echo for the person outside

I haven’t been able to get the URL for the still image. Have you used the hack explained in the other thread?

Nah , don’t need it, i am using a synology surveillance system, so I have the camera exposed from there…

The use of a SIP server is interesting. What did you install?

I am testing with FreePBX

Alltough, at the end i don’t see any advantage using sip, if you are satisfied with hikconnect app

I’m still in the middle of testing everything.
I had updated the outdoor station to the latest firmware 2.2.3 which was meant to support ONVIF, but HA did not recognize the camera. Did you experience the same?

Didn’t try onvif, rtsp works fine for me

Alright. And in terms of motion detection of the intercom camera, do you have motion events sent to HA from your surveillance system?

No, i disabled motion events, i only record 3 min on a doorpress event… I have other camera outside with motion enabled :slight_smile:

What indoor system have you bought?

I went for 2 DS-KH8350-WTE1 and 2 DS-KH6320-WTE1 indoor stations (it’s a 4 apartments building)

Ah ok, cool

I bought the 9310 model, based on android, to run HA :slight_smile:
But seems the requirements are just too low to run any app, mine will be replaced by a newer model soon

I stayed away from it right because it was not very flexible :slight_smile:
Also, apartments owners just needed an easy to use video intercom system, nothing more.

It’s the same screen, just with with 1 more option that doesn’t work :slight_smile:

How exactly did you hook up to the indoor station to get the doorbell button pressed event?

There is a function in ivms “calling linkage”, then you can define an output relay, that will trigger on a doorpress button

guys, first step into integration, with command below you can open the door from HA :

change offcourse password and ip

curl -i --digest -u admin:xxx -X PUT -d '<RemoteControlDoor><cmd>open</cmd></RemoteControlDoor>' http://192.168.0.xx/ISAPI/AccessControl/RemoteControl/door/1

3 Likes

Great Fabio!
this is working also on DS-KV8113-WME1, with both door locks output!
In my case “door/2” is a gate

it’s months i was looking for something working on this Hikvision series.
Mirco