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

Hmm, don’t thing that ISAPI command is making a ring, it’s to get a call signal , if the doorbutton was pressed…

Maybe setup a voicemail? Or maybe a conference?

I think you need to find some answer command in asterisk it should be possible…

I have sip tracés avaible, where I initiate a call from indoor to outdoor station , where it answers too… If you want them, I can share it… Maybe you can ask on community asterisk forum

Another way, is to setup two-way audio, there is a ISAPI command for that, then you can speak to the outdoor station…

If you perhaps have a Synology system, the SS application supports two-way audio, I tested before, I was able to speak without setting up a call

ah well, the trace would be nice.

I don’t have a synology system…

Any hints on what the command for a two-way audio is? I have the ISAPI 2.6 (May 2020) manual and don’t see it.

oh cool, I found an earlier post in this thread

cool. did anyone write a lovelace card for this? seems pretty easy :slight_smile:

Hey

  1. for two way audio using ISAPI:
PUT /ISAPI/System/TwoWayAudio/channels/1/open
PUT /ISAPI/System/TwoWayAudio/channels/1/audioData
... send data ...
PUT /ISAPI/System/TwoWayAudio/channels/1/close

The data, thats the difficult part, i think you need some encoded files, never tried it, but you can maybe look on some other forums for hikvision cameras, should be the same… but it will take you some time to develop it…

  1. i thought i had a SIP log where i initiate a call from indoor to outdoor, but seems its just sending a SIP options package to request the RTSP stream

maybe another way…
The outdoor station is also running a PBX server, it runs on port 5065 (private hik SIP server protocol)
If you would had indoor stations like, me . i traced them, they register on the outdoor station (the primary one) …
So try with linphone or whatever sip softphone client registering on your outdoor IP on port 5065 …
Use this as username : 10010100000

then try to call from outdoor to nr “1” , then your softphone should ring…
then call back to outdoor station, maybe it works :slight_smile:

if that works, you can use Asterisk to setup an trunk, then you can use your softphone clients make an call using the trunk as outbound

well i think I figured out the format so it shouldn’t be too bad. maybe I’ll have something this evening if I’m not too busy with work today

Mine doesnt seem to work, I’ve got the ds-kv6113-wpe1 and when I call it from another SIP extension it just returns an unavailable SIP code (from memory).

Great, keep me posted , also interested in this, could be usefull indeed

In first post I have added a link with a zip with all ISAPI documents

Great. I got audio playback. Sort of a pain but more or less it seems to want whatever audio codec you configured (ulaw or alaw), and then you need to send it at the sample rate of the actual file. So 8000Hz means you better send 8000 samples per second, no more, no less, otherwise you get garbled audio.

So I guess the idea is this: write a simple server that handles the two way audio. If you give it some audio it’ll drop it into ffmpeg, transcode it into ulaw/alaw at a reasonable bitrate. And then to do intercom expose a websocket.

For HA integration, make a lovelace card which plays the rtsp stream (or not if its laggy, maybe just use webrtc or something else) and dumps data into the websocket for microphone.

Only issue is if someone presses the doorbell and how to capture that, I think make a fake SIP server and register, then it should be easy to catch the ring and hang up right away.

cool, looking forward to it
Why dont you use my Addon, it can capture a doorpress event using the SDK
or the ISAPI callstatus ? its based on polling…

btw, maybe one more issue… i think you can only start two way audio using ISAPI, when there is no one pressing the button… when i tested it before, when someone pressed the doorbutton, seems the speaker is already in use, and if you then talk using two way audio, there is no audio out…
it only works when the outdoorstation is in idle

You need to kill the callsignal first, but on your device you can do it also with an ISAPI , using the callsignal command, i have the 8003 , it doesnt work on mine device… but i can use the hikconnect command to kil the callsignal

ah. I think I looked into the addon (there’s one that uses some hikvision libs, I cant use that, my system is arm64) -

Polling is okay but I think it should be fairly straightforward to make a SIP server that just hangs up whenever a call is initiated too. We’ll find out… thanks for your help so far!

ah ok, yeah it should be indeed possible with Asterisk, you can use the unfinished asterisk integration, its a work in progress… or you can use a python script to hangup, i’m using that

If you hang up the call directly, the Doorbell plays an annoying loud hangup tone.

I made Asterisk answer the call directly without routing it anywhere, playback a fake ringing tone to the person at the door and then wait before then forwarding it to my mobile. HA hangs up the call via ARI if I am at home and HA plays a doorbell sound through my Google Homes. This is 100% silent to the user at the door.

exten => _6XXX,1,Dial(PJSIP/${EXTEN})
exten => 04xxxxxxxx,1,Ringing()
exten => 04xxxxxxxx,n,Wait(1)
exten => 04xxxxxxxx,n,Answer(500)
exten => 04xxxxxxxx,n,Wait(4)
exten => 04xxxxxxxx,n,Dial(PJSIP/${EXTEN}@mytrunk,20)
exten => 04xxxxxxxx,n,Hangup()

That’s indeed a workaround…

Have you tested before to actually call the outdoor station? I never got that to work…

I think maybe It only works using ISAPI and two way audio or with SDK, would be great to add this to the webrtc card… To actually speak to the visitor when no call is in progress…

if you want , i also have a python sip script, i used it before to register on my indoor as an extension
The script is able to register offcourse, it can also capture a invite (ring) event and able to update an sensor in HA using a curl command

You can also use it to register directly on your outdoor, so you dont need asterisk at all to recieve an SIP event…

Use this as username : 10010100000

look at line 415+ for the arguments you can use

Yes, when I call the doorbell’s number, I just get a SIP unavailable code back to the client, it doesn’t work on mine.

Which is a pity, as I had a scenario where someone turned up and didnt press the button (I have motion activated cameras), and then left again with a package despite being told to drop the item off. Had I been able to call it, I could have told them to leave it as I asked.

Okay, well I spent a few hours over the weekend on it…

I have a fake SIP server now; it setups the SIP and RTP session… it gets an INVITE and then immediately sends BYE when the session is setup. It also updates MQTT so I get notifications and can handle button presses in HA.

The server also exposes an HTTP endpoint, I can send it an audio file and it gets transcoded by ffmpeg to PCM at the appropriate sample rate and played using ISAPI. When the doorbell is pressed, the fake SIP server picks up and hangs up, and the stream is resumed after 1s.

Just got to figure out how to mux, make a lovelace card and deal with input (maybe not? maybe stick with LL-HLS from the RTSP stream and a “push to speak” button which sends audio down to my server…