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

@laszlojakab , i tried other example scripts, even the official included in the SDK, they are all giving wrong values on Linux … too bad :frowning:
anyway, back to ISAPI , i upgraded the firmare to custom, the callstatus was working now on DS-KD8003 series, but the alertstream was not working
after getting in touch with Hikvision, they told me to factory reset, and YES

i now see incoming events , like door Open , or illegal card swiped!!

gonna ask the developer of PyHik, to add this in the official HikVision HA integration, so there can be more binary sensors created

	"ipAddress":	"",
	"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
1 Like

Guys, who is good creating rest sensor? i just need 1 thing, then the whole integration for Hikvision is complete
the alert stream for events, is an infinite file/output, i dont know how to get those values in HA :slight_smile:

created a new thread for this

hey @laszlojakab , i’m gonna submit a support request on the hikvision TPP portal, for sdk issues
I have an account there, as a company, if they want to more about the Linux SDK bug, can i give your contact details?


I think first of all we should create the same app in C++. If the same problems happen in C++ app then we can contact to HikVision support team. If no problem with C++ app then the problem should be in Python code which not related to the SDK so probably HikVision couldn’t (or won’t) help to us.

hey, i tried the C++ code, there is a sample file in the downloaded SDK package (consoledemo)
if you start that in terminal, option 3 is to get the alert events

i just added some print commandos to actually see the commands and types, they were wrong too

Guys, integrating the Alertstream in a sensor, is not possible, since its an endless file, so polling it is a nogo

i developed a python script, change offcourse the variables , like username/pass/ip/bearer token

i fire the script with an automation upon start event on Home Assistant


- alias: Hikvision Door Sensor
  initial_state: 'on'
    - platform: homeassistant
      event: start
    - service: shell_command.hikvision_stream_sensor

shell command: (the nohup below, makes the script fire in background

hikvision_stream_sensor: nohup python3 /config/python_scripts/hikvision_stream.py $1 > /dev/null 2>&1 &


from requests.auth import HTTPDigestAuth
from datetime import datetime
import requests
import time
import json
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
    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")
    print("Creating Sensor Failed")

while True:
        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")
            #Check for event
            if str_line.find('"subEventType":	25') != -1:
                result = str_line.find('eventState')
                print("Found event!")
                    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
                    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")
                    print("Updating sensor failed")
        if stream.status_code == 401 or stream.status_code == 403:
    except (ValueError,requests.exceptions.ConnectionError,requests.exceptions.ChunkedEncodingError) as err:
        print("Connection Failed")

Is it possible to get which room was called / which button was pressed on the outdoor station? There is not such property on the callStatus response body, but maybe there’s some chance on the alert stream?

Hmm, no the Alertstream doesn’t provide callstatus, maybe it’s possible with the SDK , SDK also provides info who opened the door

Hopefully someone can help me here.

I’ve got the DS-KD8003-IME1 running custom firmware V2.2.45 build 210721

I factory reset the device by going into iVMS, then system maintenance, and hit “restore all”.

Added back to the indoor station, reconnected, all working, implemented the rest sensor… except call status doesn’t change from “idle”.

What am I doing wrong? Did I do the correct factory reset?

Are you using the correct ISAPI url? I added one in first post… The callstatus url from 8003 is different then the others
The one in the rest sensor example is for other models, you need to change it to the one for 8003
Mine polling is setup to 3 , more then fast enough

Ah you’re right, I will change then test. Thanks!

That means HikVision support team should provide a working SDK with working C++ sample code.

yeah, i have a ticket open with Hikvision, i sended you a PM

btw, do you also want to work with the ISAPI ? would be nice to have this as an offcial integration into HA
you are a developer :slight_smile:
the Hikvision integrtation , is already based on the same ISAPI url, its just the type of events thats needs to be changed in pyhik , and offcourse some changes in hikvision integration, so more binary sensors are created …

Could anyone please share in what format does https://apiieu.hik-connect.com/v3/users/login/v2 expect username/password be submitted?

Tried to send “account” & “password” key in raw format and getting in return ..."ERROR_MSG": "filed 'password', rejected value[xxxxxx];"

Why do you want to go that road? Everything and more is now possible with ISAPI , and faster

My doorbell DS-KB8113-IM doesn’t support these ISAPI methods so I’m thinking about possible alternatives.

First tried to intercept network traffic from the doorbell to indoor station, but with no luck. Now trying with Hikvision app API.

Managed to implement door unlock method with minor modifications though :blush:

Ah ok , i don’t use the hikconnect API anymore, it was temporarily, now using ISAPI

I think you are better of with the SDK, it’s local and super fast and no polling needed

Do you know if Hikvision SDK can be used to get call button press events for my doorbell?

I never used it, but it supports it without the need to poll for status every second I will try that route

Yes, doorbell is supported

Test this one, currently only working for windows…

If it works, i have a c++ project for Linux , a working one