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

yes, it is. I use Asterisk add-on with only changes from your readme file. I managed to extract some more logs, where I see the incoming call, but for some reason Asterisk is not accepting it

Jan 30 08:26:21 Asterisk: [Jan 30 09:26:21] #033[1;32mDEBUG#033[0m[488]: #033[1;37mres_pjsip/pjsip_distributor.c#033[0m:#033[1;37m393#033[0m #033[1;37mfind_dialog#033[0m: Could not find matching transaction for Request msg INVITE/cseq=20 (rdata0x7fafd8004ad8)
Jan 30 08:26:21 Asterisk: [Jan 30 09:26:21] #033[1;32mDEBUG#033[0m[488]: #033[1;37mres_pjsip/pjsip_distributor.c#033[0m:#033[1;37m471#033[0m #033[1;37mast_sip_get_distributor_serializer#033[0m: Calculated serializer pjsip/distributor-0000002f to use for Request msg INVITE/cseq=20 (rdata0x7fafd8004ad8)
Jan 30 08:26:21 Asterisk: [Jan 30 09:26:21] #033[1;32mDEBUG#033[0m[489]: #033[1;37mres_pjsip_endpoint_identifier_ip.c#033[0m:#033[1;37m253#033[0m #033[1;37mip_identify_match_check#033[0m: Source address XXX.XXX.146.121:5060 matches identify 'hikvision'
Jan 30 08:26:21 Asterisk: [Jan 30 09:26:21] #033[1;32mDEBUG#033[0m[489]: #033[1;37mres_pjsip_endpoint_identifier_ip.c#033[0m:#033[1;37m287#033[0m #033[1;37mcommon_identify#033[0m: Identify 'hikvision' SIP message matched to endpoint hikvision
Jan 30 08:26:21 Asterisk: [Jan 30 09:26:21] #033[1;32mDEBUG#033[0m[489]: #033[1;37mres_pjsip_session.c#033[0m:#033[1;37m4253#033[0m #033[1;37msession_on_rx_request#033[0m:  (null session) Request: INVITE 
Jan 30 08:26:21 Asterisk: [Jan 30 09:26:21] #033[1;32mDEBUG#033[0m[489]: #033[1;37mres_pjsip_session.c#033[0m:#033[1;37m4080#033[0m #033[1;37mhandle_new_invite_request#033[0m:  Request: 
Jan 30 08:26:21 Asterisk: [Jan 30 09:26:21] #033[1;32mDEBUG#033[0m[489]: #033[1;37mres_pjsip/pjsip_distributor.c#033[0m:#033[1;37m471#033[0m #033[1;37mast_sip_get_distributor_serializer#033[0m: Calculated serializer pjsip/distributor-0000002f to use for Request msg INVITE/cseq=20 (rdata0x7fafd8018988)
Jan 30 08:26:21 Asterisk: [Jan 30 09:26:21] #033[1;32mDEBUG#033[0m[489]: #033[1;37mchan_pjsip.c#033[0m:#033[1;37m2969#033[0m #033[1;37mchan_pjsip_session_begin#033[0m:  hikvision
Jan 30 08:26:21 Asterisk: [Jan 30 09:26:21] #033[1;32mDEBUG#033[0m[489]: #033[1;37mchan_pjsip.c#033[0m:#033[1;37m2973#033[0m #033[1;37mchan_pjsip_session_begin#033[0m:  Direct media no glare mitigation
Jan 30 08:26:21 Asterisk: [Jan 30 09:26:21] #033[1;32mDEBUG#033[0m[489]: #033[1;37mres_pjsip_session.c#033[0m:#033[1;37m3934#033[0m #033[1;37mnew_invite#033[0m:  hikvision
Jan 30 08:26:21 Asterisk: [Jan 30 09:26:21] #033[1;32mDEBUG#033[0m[489]: #033[1;37mres_pjsip_session.c#033[0m:#033[1;37m4014#033[0m #033[1;37mnew_invite#033[0m:  hikvision: Call (UDP:XXX.XXX.146.121:5060) to extension '10000000005' sending 100 Trying
Jan 30 08:26:21 Asterisk: [Jan 30 09:26:21] #033[1;32mDEBUG#033[0m[489]: #033[1;37mres_pjsip_session.c#033[0m:#033[1;37m4544#033[0m #033[1;37mhandle_outgoing_response#033[0m:  hikvision: Method is INVITE, Response is 100 Trying
Jan 30 08:26:21 Asterisk: [Jan 30 09:26:21] #033[1;32mDEBUG#033[0m[489]: #033[1;37mres_pjsip_session.c#033[0m:#033[1;37m4563#033[0m #033[1;37mhandle_outgoing_response#033[0m:  hikvision
Jan 30 08:26:21 Asterisk: [Jan 30 09:26:21] #033[1;32mDEBUG#033[0m[489]: #033[1;37mres_pjsip_session.c#033[0m:#033[1;37m4660#033[0m #033[1;37msession_inv_on_state_changed#033[0m:  hikvision Event: TSX_STATE  Inv State: INCOMING
Jan 30 08:26:21 Asterisk: [Jan 30 09:26:21] #033[1;32mDEBUG#033[0m[489]: #033[1;37mres_pjsip_session.c#033[0m:#033[1;37m4686#033[0m #033[1;37msession_inv_on_state_changed#033[0m: hikvision: Source of transaction state change is TX_MSG
Jan 30 08:26:21 Asterisk: [Jan 30 09:26:21] #033[1;32mDEBUG#033[0m[489]: #033[1;37mres_pjsip_session.c#033[0m:#033[1;37m4734#033[0m #033[1;37msession_inv_on_state_changed#033[0m:  
Jan 30 08:26:21 Asterisk: [Jan 30 09:26:21] #033[1;32mDEBUG#033[0m[489]: #033[1;37mres_pjsip_session.c#033[0m:#033[1;37m4778#033[0m #033[1;37msession_inv_on_tsx_state_changed#033[0m:  hikvision TSX State: Proceeding  Inv State: INCOMING
Jan 30 08:26:21 Asterisk: [Jan 30 09:26:21] #033[1;32mDEBUG#033[0m[489]: #033[1;37mres_pjsip_session.c#033[0m:#033[1;37m4967#033[0m #033[1;37msession_inv_on_tsx_state_changed#033[0m:  Nothing delayed
Jan 30 08:26:21 Asterisk: [Jan 30 09:26:21] #033[1;32mDEBUG#033[0m[489]: #033[1;37mres_pjsip_session.c#033[0m:#033[1;37m4198#033[0m #033[1;37msession_on_tsx_state#033[0m:  hikvision TSX State: Proceeding  Inv State: INCOMING
Jan 30 08:26:21 Asterisk: [Jan 30 09:26:21] #033[1;32mDEBUG#033[0m[489]: #033[1;37mres_pjsip_session.c#033[0m:#033[1;37m4202#033[0m #033[1;37msession_on_tsx_state#033[0m:  Topology: Pending: (null topology)  Active: (null topology)
Jan 30 08:26:21 Asterisk: [Jan 30 09:26:21] #033[1;32mDEBUG#033[0m[489]: #033[1;37mres_pjsip_session.c#033[0m:#033[1;37m4207#033[0m #033[1;37msession_on_tsx_state#033[0m:  
Jan 30 08:26:21 Asterisk: [Jan 30 09:26:21] #033[1;32mDEBUG#033[0m[489]: #033[1;37mres_pjsip_session.c#033[0m:#033[1;37m769#033[0m #033[1;37mhandle_incoming_sdp#033[0m:  hikvision: Media count: 0
Jan 30 08:26:21 Asterisk: [Jan 30 09:26:21] #033[1;32mDEBUG#033[0m[489]: #033[1;37mres_pjsip_session.c#033[0m:#033[1;37m960#033[0m #033[1;37mhandle_incoming_sdp#033[0m:  hikvision: Handled? no
Jan 30 08:26:21 Asterisk: [Jan 30 09:26:21] #033[1;32mDEBUG#033[0m[489]: #033[1;37mres_pjsip_session.c#033[0m:#033[1;37m4544#033[0m #033[1;37mhandle_outgoing_response#033[0m:  hikvision: Method is INVITE, Response is 488 Not Acceptable Here
Jan 30 08:26:21 Asterisk: [Jan 30 09:26:21] #033[1;32mDEBUG#033[0m[489]: #033[1;37mres_pjsip_session.c#033[0m:#033[1;37m4563#033[0m #033[1;37mhandle_outgoing_response#033[0m:  hikvision
Jan 30 08:26:21 Asterisk: [Jan 30 09:26:21] #033[1;32mDEBUG#033[0m[489]: #033[1;37mres_pjsip_session.c#033[0m:#033[1;37m4660#033[0m #033[1;37msession_inv_on_state_changed#033[0m:  hikvision Event: TSX_STATE  Inv State: DISCONNCTD
Jan 30 08:26:21 Asterisk: [Jan 30 09:26:21] #033[1;32mDEBUG#033[0m[489]: #033[1;37mres_pjsip_session.c#033[0m:#033[1;37m4686#033[0m #033[1;37msession_inv_on_state_changed#033[0m: hikvision: Source of transaction state change is TX_MSG
Jan 30 08:26:21 Asterisk: [Jan 30 09:26:21] #033[1;32mDEBUG#033[0m[489]: #033[1;37mres_pjsip_session.c#033[0m:#033[1;37m4734#033[0m #033[1;37msession_inv_on_state_changed#033[0m:  
Jan 30 08:26:21 Asterisk: [Jan 30 09:26:21] #033[1;32mDEBUG#033[0m[489]: #033[1;37mres_pjsip_session.c#033[0m:#033[1;37m4778#033[0m #033[1;37msession_inv_on_tsx_state_changed#033[0m:  hikvision TSX State: Completed  Inv State: DISCONNCTD
Jan 30 08:26:21 Asterisk: [Jan 30 09:26:21] #033[1;32mDEBUG#033[0m[489]: #033[1;37mres_pjsip_session.c#033[0m:#033[1;37m4800#033[0m #033[1;37msession_inv_on_tsx_state_changed#033[0m:  Disconnected
Jan 30 08:26:21 Asterisk: [Jan 30 09:26:21] #033[1;32mDEBUG#033[0m[489]: #033[1;37mres_pjsip_session.c#033[0m:#033[1;37m4198#033[0m #033[1;37msession_on_tsx_state#033[0m:  (null session) TSX State: Completed  Inv State: DISCONNCTD
Jan 30 08:26:21 Asterisk: [Jan 30 09:26:21] #033[1;32mDEBUG#033[0m[489]: #033[1;37mres_pjsip_session.c#033[0m:#033[1;37m4207#033[0m #033[1;37msession_on_tsx_state#033[0m:  
Jan 30 08:26:21 Asterisk: [Jan 30 09:26:21] #033[1;32mDEBUG#033[0m[489]: #033[1;37mres_pjsip_session.c#033[0m:#033[1;37m4063#033[0m #033[1;37mnew_invite#033[0m:  hikvision
Jan 30 08:26:21 Asterisk: [Jan 30 09:26:21] #033[1;32mDEBUG#033[0m[489]: #033[1;37mres_pjsip_session.c#033[0m:#033[1;37m4154#033[0m #033[1;37mhandle_new_invite_request#033[0m:  Request:  Session: hikvision
Jan 30 08:26:21 Asterisk: [Jan 30 09:26:21] #033[1;32mDEBUG#033[0m[489]: #033[1;37mres_pjsip_session.c#033[0m:#033[1;37m4272#033[0m #033[1;37msession_on_rx_request#033[0m:  (null session) Handled request INVITE  ? yes
Jan 30 08:26:21 Asterisk: [Jan 30 09:26:21] #033[1;32mDEBUG#033[0m[489]: #033[1;37mchan_pjsip.c#033[0m:#033[1;37m2990#033[0m #033[1;37mchan_pjsip_session_end#033[0m:  hikvision
Jan 30 08:26:21 Asterisk: [Jan 30 09:26:21] #033[1;32mDEBUG#033[0m[489]: #033[1;37mchan_pjsip.c#033[0m:#033[1;37m2993#033[0m #033[1;37mchan_pjsip_session_end#033[0m:  No channel
Jan 30 08:26:21 Asterisk: [Jan 30 09:26:21] #033[1;32mDEBUG#033[0m[489]: #033[1;37mres_pjsip_session.c#033[0m:#033[1;37m2912#033[0m #033[1;37msession_destructor#033[0m: hikvision: Destroying SIP session
Jan 30 08:26:21 Asterisk: [Jan 30 09:26:21] #033[1;32mDEBUG#033[0m[488]: #033[1;37mres_pjsip/pjsip_distributor.c#033[0m:#033[1;37m502#033[0m #033[1;37mdistributor#033[0m: Searching for serializer associated with dialog dlg0x7fafe8015a98 for Request msg ACK/cseq=20 (rdata0x7fafd8004ad8)
Jan 30 08:26:21 Asterisk: [Jan 30 09:26:21] #033[1;32mDEBUG#033[0m[488]: #033[1;37mres_pjsip/pjsip_distributor.c#033[0m:#033[1;37m471#033[0m #033[1;37mast_sip_get_distributor_serializer#033[0m: Calculated serializer pjsip/distributor-0000002f to use for Request msg ACK/cseq=20 (rdata0x7fafd8004ad8)
Jan 30 08:26:21 Asterisk: [Jan 30 09:26:21] #033[1;32mDEBUG#033[0m[489]: #033[1;37mres_pjsip_endpoint_identifier_ip.c#033[0m:#033[1;37m253#033[0m #033[1;37mip_identify_match_check#033[0m: Source address XXX.XXX.146.121:5060 matches identify 'hikvision'
Jan 30 08:26:21 Asterisk: [Jan 30 09:26:21] #033[1;32mDEBUG#033[0m[489]: #033[1;37mres_pjsip_endpoint_identifier_ip.c#033[0m:#033[1;37m287#033[0m #033[1;37mcommon_identify#033[0m: Identify 'hikvision' SIP message matched to endpoint hikvision
Jan 30 08:26:21 Asterisk: [Jan 30 09:26:21] #033[1;32mDEBUG#033[0m[489]: #033[1;37mres_pjsip_session.c#033[0m:#033[1;37m4778#033[0m #033[1;37msession_inv_on_tsx_state_changed#033[0m:  (null session) TSX State: Confirmed  Inv State: DISCONNCTD
Jan 30 08:26:21 Asterisk: [Jan 30 09:26:21] #033[1;32mDEBUG#033[0m[489]: #033[1;37mres_pjsip_session.c#033[0m:#033[1;37m4790#033[0m #033[1;37msession_inv_on_tsx_state_changed#033[0m:  Session ended
Jan 30 08:26:21 Asterisk: [Jan 30 09:26:21] #033[1;32mDEBUG#033[0m[489]: #033[1;37mres_pjsip_session.c#033[0m:#033[1;37m4198#033[0m #033[1;37msession_on_tsx_state#033[0m:  (null session) TSX State: Confirmed  Inv State: DISCONNCTD
Jan 30 08:26:21 Asterisk: [Jan 30 09:26:21] #033[1;32mDEBUG#033[0m[489]: #033[1;37mres_pjsip_session.c#033[0m:#033[1;37m4207#033[0m #033[1;37msession_on_tsx_state#033[0m:  
Jan 30 08:26:24 Asterisk: [Jan 30 09:26:24] #033[1;32mDEBUG#033[0m[575]: #033[1;37mmanager.c#033[0m:#033[1;37m7099#033[0m #033[1;37mprocess_message#033[0m: Running action 'Status'
Jan 30 08:26:24 Asterisk: [Jan 30 09:26:24] #033[1;32mDEBUG#033[0m[575]: #033[1;37mmanager.c#033[0m:#033[1;37m7099#033[0m #033[1;37mprocess_message#033[0m: Running action 'PJSIPShowEndpoint'
Jan 30 08:26:24 Asterisk: [Jan 30 09:26:24] #033[1;32mDEBUG#033[0m[575]: #033[1;37mmanager.c#033[0m:#033[1;37m7099#033[0m #033[1;37mprocess_message#033[0m: Running action 'PJSIPShowEndpoint'

I see this line might be the reason

handle_incoming_sdp#033[0m:  hikvision: Media count: 0

Have you tried disabling video by removing it from the trunk and/or sip endpoint? Just remove the video codecs… And only allow ulaw and alaw…

Video doesnt work anyway

yeah, I tried that too

and you are running asterisk on same local network/subnet as the indoor device?
or why are you masking the Ip’s ?
maybe its just an firewall port issue? for audio/video traffic you also need RTP ports to be open?

have you also configured an from_domain ?

also , are you calling to test an sip softphone ? or are you using the lovelace card as endpoint?
see here:

I primarily use Asterisk in the cloud, but I’m receiving exact same request/response and error in my local installation as well. So networking part shouldn’t be a problem here.

I configured 3 extensions, one for the Lovelace card, another one for my soft phone, and one for hikvision. I’m able to make a call from soft phone.
I have from_domain=asterisk.com configured for two of the extensions, but not for hikvision.

When I examine the INVITE request, I don’t see any mentions of the media descriptor, is that normal?
Do you possibly have an example of working INVITE message?

Its indeed strange, I still have the backup of the opensips addon if you want it…

I created a thread before on asterisk about video issue, you can find invite message there and also compare it…

It must be a codec issue

True setting up the from domain too, I have it also on my Hikvision trunk, seems I didn’t copy paste it in method 2 on the readme page…

I had issues before when not setting up from domain, especially when the addon hostname was starting with a digit… It’s not allowed in asterisk… And addon hostnames are random

I checked your invite message from Hikvision and it has media streams declared:

m=audio 9654 RTP/AVP 0 8 101
m=video 9654 RTP/AVP 96

the invite I receive doesn’t have it…:confused:

then its still strange that OpenSips was working for you ?

i did a quick google search, and most of them are about codec/media issues
just a wild guess; why for testing allow all codes? instead of only allowing 2 and disallow all the rest ?

I tried different combinations with codecs yesterday and it didn’t work.

I have now tested in opensips again, and I’m getting identical INVITE message, call comes through, but no audio.
I also don’t understand why my Hikvision uses User-Agent: eXosip/3.6.0 in the message header, while yours has User-Agent: HKVS/2.0.0

I’ve posted same question in Asterisk community and they say that my INVITE message lacks media stream and Asterisk requires it.

Now I’m wondering why my indoor station doesn’t send the media stream. Possibly, older models work differently.

Would be nice to inspect the network traffic between my doorbell and indoor station and see how it delivers audio/video.

hm, it should work , basicly its just plain SIP, i know there is a lot of hardcoded stuff, you dont have audio, i dont have video, and i’m sure its present , because other indoor extensions can display it
i troubleshooted this, also that thread i posted on asterisk and find out that the hardware uses also fixed ports for audio and video as well

Have a look on that asterisk thread again, in first screenshot, where i traced the original trace of the hardware , notice the audio and video ports … they are on 9654 for audio and video and source was 9854 and 9856
0.70 is my outdoor, 0.72 is an indoor extension (now setup with asterisk), and 0.71 is the primary indoor where i do register asterisk on

Maybe the ports is the reason, asterisk uses different ports … like 10000 to 20000
i have tested Linphone on desktop, that SIP client is able to setup source ports as well, when i enabled here 9856 for video, i was able to see video coming in, but i never succeeded to setup fixed ports on asterisk, because it uses ranges

maybe as a test for you, just run the script on port 5061 , then on your same host where you run the script, install linphone for windows, and reister on your indoor with 10000000005 and password, and register on your indoor panel on port 5065 , then afterwards, goto network settings, and change the listening ports, for SIP : 5060 , for audio, try 9654

then make a call, and see you can answer with linphone?

1 Like

From what I understood, Asterisk expects that all SIP messages are strictly according to spec and it expects that INVITE should always contain at least one media stream. Otherwise it would reject the invitation.

My door station already knows where to get audio and video streams and doesn’t care about the attributes in INVITE message.
At the same time, it looks like newer stations send valid SIP messages and list media streams in the invitation making it possible to work with Asterisk.

Then in my situation I can’t connect Asterisk directly and should probably look for other SIP clients

hmm, that makes sense indeed , so game over? or maybe replace one indoor station with a newer model ? its only the primary one thats important

1 Like

I hope its not a game over yet :slight_smile:

First I need to check if newer indoor stations are compatible with my doorbell DS-KB8112. It is quite a troublesome model where many things don’t even work as advertised.

I’m also thinking to dig a bit more into other SIP tools/opensips and see if it can inject RTP-streams

Yeah, my goal was indeed to manually inject video in the RTP , by converting for example the rtsp with ffmpeg, but seems I was alone on internet that wanted to do this, so I gave up and created the baresip approach and injecting the rtsp video as a conference user…

But I want to help getting this stuff to work!!

1 Like

Opensips has some great tools to manipulate sip, I used that first to send the XML needed for Hikvision…

But later on, I was just wrong, it was not needed if I added the SN manually with ivms (new models)
The script approach is indeed for older models , basically doing the same thing as opensips

But didn’t find a way or didn’t searched hard enough to manipulate the RTP

Hi Fabio, many thnx again for your add-on to get my doorbell working (DS_KV6113) with HA !

Below you find my yaml tekst:

alias: deurbel aan
description: ""
trigger:
  - platform: state
    entity_id:
      - sensor.hikvision_callstatus
condition: []
action:
  - service: media_player.play_media
    target:
      entity_id: media_player.nesthub2692
    data:
      media_content_id: media-source://media_source/local/deurbel2.mp3
      media_content_type: audio/mpeg
    metadata:
      title: deurbel2.mp3
      thumbnail: null
      media_class: music
      children_media_class: null
      navigateIds:
        - {}
        - media_content_type: app
          media_content_id: media-source://media_source
  - delay:
      hours: 0
      minutes: 0
      seconds: 1
      milliseconds: 0
  - service: tts.google_translate_say
    data:
      entity_id: media_player.nesthub2692
      message: Er staat iemand voor de deur
      language: nl
      cache: true
mode: single

One question I still have is how to integrate your callsignal service you noted in the starting point of this post. I see the lines to send the callsignal command to my outdoor station… But where do I have to put these lines ? Just into the configuration.yaml or in a separate file ? Do I have to save this as a service…I’m pretty lost here…hope you help me out here…still learning. I have a Zigbee sensor at the door that should trigger this callsignal command (same solution as you have)

By the way: I have just opened a Paypal account for some sponsoring for your appreciated work :wink:

1 Like