Hikvision Doorbell / Videointercom integration

OK. Thanks.

Hi! We are currently running Hikvision-Addons app, and also using Asterisk 18.20 as inbound trunk via app_rtsp_sip.
And my main question is regarding asterisk extensions/pjsip configuration, since we are having an issue that the audio(ulaw) and video(h264) works for the Linhome app’s SIP account just fine, but for Hikvision indoor devices(DS-KH8520-WTE1) we are getting only audio(ulaw). I think that there might be a problem with our extensions.conf / pjsip.conf settings, can you verify this and? Since im not sure where to look at, at this point we tried everything.

Here is the pjsip.conf:

[tr-udp]
type=transport
protocol=udp
bind=0.0.0.0:5060
local_net=192.168.1.0/24
allow_reload=true

[9000]
type=endpoint
context=default
disallow=all
allow=ulaw,h264,vp8
transport=tr-udp
auth=auth9000
aors=9000
rtp_symmetric=yes
force_rport=yes
rewrite_contact=yes
direct_media=no

[auth9000]
type=auth
auth_type=userpass
password=pass
username=9000

[9000]
type=aor
max_contacts=2

[9001]
type=endpoint
context=default
disallow=all
allow=ulaw,h264,vp8
dtmf_mode=rfc4733
transport=tr-udp
auth=auth9001
aors=9001

[auth9001]
type=auth
auth_type=userpass
password=pass
username=9001

[9001]
type=aor
max_contacts=2

[outgoing]
type=endpoint
disallow=all
allow=ulaw,alaw,h264,vp8
from_domain=192.168.1.46

[hikvision]
type=aor
contact=sip:[email protected]:5060

[hikvision]
type=endpoint
context=default
disallow=all
allow=ulaw,alaw
allow=h264,vp8
aors=hikvision
direct_media=no

[hikvision]
type=identify
endpoint=hikvision
match=192.168.1.33

And here is our extensions.conf file:

[default]
exten => 10000000005,1,NoOp()
 same => n,Progress()
 same => n,Set(CHANNEL(hangup_handler_push)=default,finishcall,1(args)) 
 same => n,Set(GLOBAL(CHANNEL-IN)=${CHANNEL})
 same => n,System(/usr/bin/php "/config/asterisk/agi.php")
 same => n,Set(i=1)
 same => n,While($[${i} < 60])
 same => n,NoOp(Confbridge number of participants : ${CONFBRIDGE_INFO(parties,1)})
 same => n,GotoIf($["${CONFBRIDGE_INFO(parties,1)}" >= "1"]?startconf) 
 same => n,Wait(1) 
 same => n,Set(i=$[${i} + 1])
 same => n,EndWhile()
 same => n(startconf),ConfBridge(1,myconferenceroom,default_user) 
 same => n,Hangup() 

exten = rtsp,1,Answer()
 same => n,RTSP-SIP(rtsp://admin:[email protected]:554/Streaming/Channels/101,0,Hikvision,5060)
 same => n,Hangup()
 
exten => 9000,1,NoOp()
 same => n,Progress()
 same => n,Set(CHANNEL(hangup_handler_push)=default,finishcall,1(args))  
 same => n,Set(GLOBAL(CHANNEL-9000)=${CHANNEL}) 
 same => n,Dial(Local/9001@default,,G(join_caller))
 same => n(join_caller),ConfBridge(1,myconferenceroom,marked_user) 
 same => n,ConfBridge(1,myconferenceroom,admin_user)
 same => n,Hangup()  
 
exten => 9001,1,NoOp() 
 same => n,Progress()
 same => n,Set(CHANNEL(hangup_handler_push)=default,finishcall,1(args))  
 same => n,Set(GLOBAL(CHANNEL-9001)=${CHANNEL})
 same => n,Set(__DYNAMIC_FEATURES=door)
 same => n,Set(CALLERID(num)=Doorbell)
 same => n,Set(CALLERID(name)=Doorbell)
 same => n,Set(COUNT=1)
 same => n,While($[ ${COUNT} < 60 ])
 same => n,Set(codec=h264)
 same => n,Dial(PJSIP/outgoing/sip:[email protected])
 same => n,Set(HANGUPCAUSEKEYS=${HANGUPCAUSE_KEYS()})
 same => n,Set(HANGUP_CAUSE=${HANGUPCAUSE})
 same => n,Verbose(2, HANGUP_CAUSE=${HANGUPCAUSE})
 same => n,GotoIf($["${HANGUP_CAUSE}" == "21"]?exitdialplan)
 same => n,Wait(3) 
 same => n,SET(COUNT=$[${COUNT} + 1])
 same => n,EndWhile()
 same => n(exitdialplan),NoOp(Exiting dialplan: HANGUP_CAUSE=${HANGUPCAUSE}) 
 same => n,Hangup() 
 
exten => finishcall,1,NoOp() 
 same => n,System(/usr/sbin/asterisk -rx "confbridge kick 1 all")
 same => n,System(/usr/sbin/asterisk -rx "hangup request ${CHANNEL-IN}")  
 same => n,System(/usr/sbin/asterisk -rx "hangup request ${CHANNEL-9000}")
 same => n,System(/usr/sbin/asterisk -rx "hangup request ${CHANNEL-9001}")  
 same => n,Return()

I don’t have much experience with asterisk, really hope that someone can help me figure this out

Hi, indoor devices don’t support early media/video, …
But you need to register your trunk on indoor device, so you don’t need to setup SIP on the hikvision devices itself

Well, thats explains a lot. Sad that there is no such functionality for indoor devices. :confused: Would be really convenient. Even the most hacky way of doing it would be at least really nice to have.

Thanks for the answer anyways!
I also have a question regarding the h264 video for indoors, not taking about early media, since with our current Asterisk pjsip & extensions configuration, that I attached above, there is no video at all for indoor devices, but audio works fine. And on Linhome app we are receiving both audio and video. Or should I ask about this issue on the Asterisk forums?

No, you won’t get any support for that rtsp-app on asterisk forums, it’s an hacky script I used anyway to get this working… :slight_smile:

Video should normally work if you do a official 1-1 call from asterisk itself, I tested this before and it works, but never tried with rtsp-app

Best to setup the trunk on your indoor, or just quit using sip, and use two way audio with HA, with my frigate guide…

We are just experimenting with the rtsp_sip module at the moment, and plan to set up a trunk on the indoor later on, or do some sort of auto sip registration in the future. We cannot really quit SIP, since Asterisk plays a major role in our internal infrastructure, and HA is not really being used in our particular case.
I’m going to test 1-1 call on Monday and will share the results thereafter.
Thank you so much for the answer and guidance!

1 Like

Ok, I just post guides from my personal experience, if you can improve it, pls share… I just want to share what I can to help other users:+)

Hi.
Eventually I did something else which works perfect. I used the original 12V DC line which was unused as the intercom now works over POE. I have hooked this line from the door sensor directly to the RPi GPIO, enabled the RPi_GPIO integration (and bouncing) and now I have a simple binary_sensor that shows the door status.
In any case I have ordered NC magnetic sensors as it was just few $ on Ali.

ah, thats indeed a great idea!

Too bad that there is no “door closed” event, i wonder why hikvision doesnt implement that
Maybe there is an ISAPI command that we can use to poll the state, alltough i dont like the polling

Hello,

I’m new to the forum, I’m French so please excuse my translated English…
I’ve read almost everything and yet, I’m stuck …

I have a DS-KV8113-WME1(B) but I don’t understand how to see the video stream.
Is it possible to have step by step, what to install, what file to make and put in the /config …
I’ve tried lots of things but being a beginner, I must be doing something wrong :frowning:
Thanks

How does it know whether the door is open or closed? All it does is send an electrical signal for a given period of time.

Hi, the addon doesnt provide an camera stream with mqtt, you need to use the “Generic camera integration”, and then use the RTSP stream, on first post i have added examples of the RTSP streams you can use

If you have an electric slot, indeed you dont know if the door is open/closed, its indeed just a pulse

But some users use magnet or have it wired differently and use the A1 relays, to know the state of the door

1 Like

That’s what I thought I understood.
Well… I can’t do it, I don’t understand a thing :frowning: :frowning: Thank you very much.

I’ve got my buttons, everything works, but the feed… is a black screen :frowning:

Are you sure the stream is working, have you tested it with something like VLC player?

I have to admit I don’t understand much about the streams :D, no I haven’t tried with VLC.
I’m going to have a look at all this… and try to figure it out.

Thanks

1 Like

I tried rejecting a call (i have a DS-KV8113-WME1) and i am getting the error below.

2023-10-29 00:03:31.661 | INFO     | mqtt_input:_reject_call_callback:298 - Received reject command for doorbell: Main Door
2023-10-29 00:03:31.673 | ERROR    | mqtt_input:_reject_call_callback:310 - Error while rejecting call: ('Error while calling ISAPI /ISAPI/VideoIntercom/callSignal?format=json', 11, 'The data sent to the device is illegal, or the data received from the device error.  E.g. The input data is not supported by the device for remote configuration.')

Same error with hung up command.
Any ideas?? Thanks in advance

Thanks for your advice on VLC, I’ve now done it. It was much easier than I thought :slight_smile:

1 Like

Hi, the callsignal command is not supported on all devices, do you also have an indoor station? Try configure an indoor station on the addon config and send it to indoor…

Also remember, the callsignal command only works when there is a real call

Also if you want to use the hangup command, you first need to send answer, to make the device stop ringing, and then send the hangup, to make it idle again

Testing SIP h264 video / ulaw audio from outdoor to indoor currently, and it seems to work fine on a 1-1 call.
The strange thing is that when using the rtsp_sip module, video does not work at all, even after the “early media” step has passed, so when the call has already been answered and is in progress, but audio works.

Not sure why its happening. I don’t know how familiar you are with the rtsp_sip module’s code, saw that you have opened some issues in the tommyjlong’s app_rtsp_sip repository, maybe you have some idea as to why this is happening?