I have a Hikvision DS-KH6320-TE1 indoor unit (non-WiFi version) installed in the apartment I recently purchased. This unit is connected to an unknown model of the main gate lock. Additionally, I’ve equipped the exterior of my apartment door with a DS-KD8003-IME1, which is connected to the aforementioned indoor unit.
Many users of the DS-KH6320-TE1 are already familiar with its functionality: when a call comes in, it requires manual disconnection or hanging up. Failing to do so will result in continuous ringing, followed by the system reverting to voice message mode. This happens even if you’ve already opened the door since the system lacks the ability to detect whether the door has been opened.
Given that the indoor unit operates on a separate network, direct connection is impossible, leaving me to depend on the Hikconnect app and platform for its operation.
To assist with this, I’ve implemented an excellent custom integration by @tomasbedrich. This integration allows me to receive sensor updates whenever there’s a call, which I’ve converted to a vdp_ringing
binary sensor using a template.
As for the disconnection process, I’ve utilized information from this forum to create a REST
sensor connection for Hikconnect’s sessionId
, as well as a REST_COMMAND
to engage the hangup API. This setup allows me to seamlessly interact with the system and manage incoming calls as needed.
sensor:
- platform: rest
resource: https://api.hik-connect.com/v3/users/login/v2
method: POST
name: HikConnectSesion
headers:
Content-Type: "application/x-www-form-urlencoded"
clientType: "55"
lang: "en-US"
featureCode: "deadbeef"
Content-Length: "77"
payload: !secret hikconnect_payload
value_template: "{{ value_json.loginUser.username }}"
json_attributes_path: "$.loginSession"
json_attributes:
- sessionId
For hikconnect_payload
, it should be in format of
account=<URL encoded username>&password=<urlencoded md5 hash of password>
rest_command:
hikconnect_hangup:
url: 'https://api.hik-connect.com/v3/devconfig/v1/call/{{ states("input_text.hikconnect_primary_device_serial") }}/operation?cmdId=3&handler=deadbeef'
method: PUT
headers:
sessionId: '{{ state_attr("sensor.hikconnectsesion", "sessionId") }}'
featureCode: 'deadbeef'
clientType: '55'
lang: 'en-US'
I’ve a Text
helper named hikconnect_primary_device_serial
to store the serial number of the device to hangup. You can get it from the Hikconnect integration.
Here is the automation.
alias: HikConnect - Hangup call when door is open.
description: ""
trigger:
- platform: state
entity_id:
- input_boolean.main_door
to: "on"
for:
hours: 0
minutes: 0
seconds: 1
condition: []
action:
- service: rest_command.hikconnect_hangup
data: {}
mode: single