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
**Addons **
See here for add-on , it can capture all events, and also open a door, no need for ISAPI (older devices supported now)
New Opensips addon released!! Pickup with a SIP Card!!!
All kind of other commands below: …
Video Stream rtsp:
rtsp://user:[email protected]: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
There is also now an HikConnect integration based on cloud and work in progress: