Hikvision Doorbell / Videointercom integration

Hey Fabio, I’m noticing sometimes the plugin is reporting it’s still Ringing, even when it is not!

Look how many time my doorbell is crashed on ringing stats! I dunno the reason
image

It stays on ringing and doesn’t come back to idle?
Can you show me logs on GitHub when the issue occurs? I think it goes only back in case of dismissed/reject/answered

1 Like

Of course. I will post there. Unfortunately now the log is gone because of motion sensors. I’ll post asap

Since running the SDK in a docker my intercom started to crash from time to time. Is there a way to find out what causes this ? Does it make a lot of calls to the device ?

No, it just listens for events, doesn’t do anything actually… Do you see something strange in logs?

Guys, you never know who will come in handy.
In the absence of little knowledge in the installation of IP telephony and complicated, at least for me, Asterisk.
I solved my own two-way audio problem on my KV6113 using the go2rtc integration and its internal WebTorrent setup. Which allows you to open an https link on any device with support for two-way audio.
Do not judge strictly if it’s off topic.

1 Like

No, i set it to debug logging now to see if something pops up.
I did change an automation that rejects the call when opening the front door. Maybe that will help.
Thanks for the reply

hmm, reject is no issue, i use it every day :slight_smile:

Hi! I configured the cardreader in my Hikvision DS-KV6113-WPE1(B). When I scan the card in the SDK log I find:

| INFO     | event:video_intercom_event:98 - Video intercom event from doorbell
| WARNING  | mqtt:video_intercom_event:212 - Unhandled eventType: 5

Would it be able to expose this to mqtt and use it as a switch?

Event type 5 is an illegal card swipe event? Not sure if this is usefull?

All other open door events with good cards or keys are already an event, you can also see the number as an attribute on the door switch

https://open.hikvision.com/hardware/structures/NET_DVR_VIDEO_INTERCOM_EVENT.html

Hi. Any news when release version stable not Beta ?

Not yet, still struggling with Mqtt when its an external Mqtt broker, once that’s finished , it will go out beta

Hi there,

I’m having difficulties setting up the trunk connection to a RasPBX (FreePBX on Raspberry Pi).

My indoor station is - DS-KH6320-WTE1, v2.28 Build 230219, ip address 192.168.254.12 and FreePBX is 192.168.0.64.

I’ve added the extension as detailed using ivms and serial number Q12345678

pjsip_custom.conf looks like this - apart from ip address and password a straight copy/paste

[mytrunk-auth]
type=auth
auth_type=userpass
password=LamePassword
username=10000000005

[mytrunk-aor]
type=aor
contact=sip:192.168.254.12:5065

[mytrunk-registration]
type=registration
outbound_auth=mytrunk-auth
server_uri=sip:192.168.254.12:5065
client_uri=sip:[email protected]:5065
retry_interval=10
contact_user=10000000005
expiration=600

[mytrunk]
type=endpoint
context=default
disallow=all
allow=ulaw,alaw
allow=h264,vp8
outbound_auth=mytrunk-auth
aors=mytrunk-aor
rewrite_contact=yes
from_domain=mydomain.com

[mytrunk]
type=identify
endpoint=mytrunk
match=192.168.254.12

I took a wireshark trace and seeing 404 not found coming back from FreePBX when trying to register. Here’s the output:

REGISTER sip:192.168.254.12:5065 SIP/2.0
Via: SIP/2.0/UDP 192.168.0.64:5060;rport;branch=z9hG4bKPjbc34c054-c30f-4ab0-8ca4-1d677755cb39
From: <sip:[email protected]>;tag=6f81dc53-2c59-441c-889c-590d26855198
To: <sip:[email protected]>
Call-ID: 1897e851-9acb-4d72-b573-9761865c0783
CSeq: 22431 REGISTER
Contact: <sip:[email protected]:5060>
Expires: 600
Allow: OPTIONS, REGISTER, SUBSCRIBE, NOTIFY, PUBLISH, INVITE, ACK, BYE, CANCEL, UPDATE, PRACK, MESSAGE, REFER
Max-Forwards: 70
User-Agent: FPBX-15.0.37(16.13.0)
Content-Length:  0

REGISTER sip:192.168.254.12:5065 SIP/2.0
Via: SIP/2.0/UDP 192.168.0.64:5060;rport=5060;branch=z9hG4bKPjbc34c054-c30f-4ab0-8ca4-1d677755cb39
From: <sip:[email protected]>;tag=6f81dc53-2c59-441c-889c-590d26855198
To: <sip:[email protected]>
Call-ID: 1897e851-9acb-4d72-b573-9761865c0783
CSeq: 22431 REGISTER
Contact: <sip:[email protected]:5060>
Allow: OPTIONS
Allow: REGISTER
Allow: SUBSCRIBE
Allow: NOTIFY
Allow: PUBLISH
Allow: INVITE
Allow: ACK
Allow: BYE
Allow: CANCEL
Allow: UPDATE
Allow: PRACK
Allow: MESSAGE
Allow: REFER
Expires: 600
Max-forwards: 70
User-agent: FPBX-15.0.37(16.13.0)
Content-Length: 0

SIP/2.0 404 Not Found
Via: SIP/2.0/UDP 192.168.0.64:5060;rport=5065;received=192.168.254.12;branch=z9hG4bKPjbc34c054-c30f-4ab0-8ca4-1d677755cb39
Call-ID: 1897e851-9acb-4d72-b573-9761865c0783
From: <sip:[email protected]>;tag=6f81dc53-2c59-441c-889c-590d26855198
To: <sip:[email protected]>;tag=z9hG4bKPjbc34c054-c30f-4ab0-8ca4-1d677755cb39
CSeq: 22431 REGISTER
Server: FPBX-15.0.37(16.13.0)
Content-Length:  0

Also in the FreePBX logs (over and over)

[2023-05-09 22:20:24] WARNING[1241] res_pjsip_registrar.c: AOR '' not found for endpoint 'mytrunk'
[2023-05-09 22:20:24] WARNING[1241] res_pjsip_outbound_registration.c: No response received from 'sip:192.168.254.12:5065' on registration attempt to 'sip:[email protected]:5065', retrying in '10'
[2023-05-09 22:20:34] WARNING[1241] res_pjsip_registrar.c: AOR '' not found for endpoint 'mytrunk'

Seems kind of the same as @Glenn22dv above, but this is a direct to FreePBX, so not sure how I’d be able to use the python script?

Any pointers please?

Cheers
_Stuart

Yeah, indeed, not sure why it gives an 404, can you maybe post a thread on freepbx forum ? I think there is just a small issue with the trunk config, must be… Tag me on the thread also

The trunk config works only on 9510 series, not sure why…

The script works, just try to run it on ssh , it will register, then you can make a trunk config for inbound IP auth as I explained on github

Thanks for quick reply.

Interesting fact - the 9510 series is android based. Wonder if that’s the cause of incompatibilities.

I’ve downloaded/run the python script - getting slightly different error now:

root@raspbx:~# python3 hikvision_register.py --ip 192.168.0.64 --domain 192.168.254.12 --username 10000000005 --extension 10000000005 --name Asterisk --password LamePass --debug
INFO:sip-server:Registering
DEBUG:sip-server:>REGISTER sip:192.168.254.12:5061 SIP/2.0
Via: SIP/2.0/UDP 192.168.0.64:5061;rport
Max-Forwards: 70
Contact: <sip:[email protected]:5061>
To: ""<sip:[email protected]:5065>
From: "Asterisk"<sip:[email protected]:5065>
Call-ID: 6559179837
CSeq: 1 REGISTER
Expires: 600
Allow: NOTIFY, INVITE, ACK, CANCEL, BYE, REFER, INFO, OPTIONS, MESSAGE
Content-Type: text/xml
User-Agent: eXosip/3.6.0
Content-Length: 166

<regXML>
<version>V2.0.0</version>
<regDevName>Asterisk</regDevName>
<regDevSerial>Q12345678</regDevSerial>
<regDevMacAddr>00:0c:29:12:12:12</regDevMacAddr>
</regXML>
DEBUG:sip-server:SIP/2.0 401 Unauthorized
Via: SIP/2.0/UDP 192.168.0.64:5061;rport=5061
From: "Asterisk" <sip:[email protected]:5065>
To: "" <sip:[email protected]:5065>;tag=901593373
Call-ID: 6559179837
CSeq: 1 REGISTER
WWW-Authenticate: Digest realm="Hikvision", nonce="99c088243fe1d9b3bf061e0666673df4", opaque="9a12844fa959108bd011cb49cad6bba7", algorithm=MD5
User-Agent: sipServer
Expires: 600
Content-Length: 0


INFO:sip-server:Handling authentication
DEBUG:sip-server:>REGISTER sip:192.168.254.12:5061 SIP/2.0
Via: SIP/2.0/UDP 192.168.0.64:5061;rport
Max-Forwards: 70
Contact: <sip:[email protected]:5061>
To: ""<sip:[email protected]:5065>
From: "Asterisk"<sip:[email protected]:5065>
Authorization: Digest username="10000000005",realm="Hikvision",nonce="99c088243fe1d9b3bf061e0666673df4",uri="sip:[email protected]:5065",response="4155bc808cddd3bc582bef4083b5627f",algorithm=MD5,opaque="9a12844fa959108bd011cb49cad6bba7"
Call-ID: 6559179837
CSeq: 2 REGISTER
Expires: 600
Allow: NOTIFY, INVITE, ACK, CANCEL, BYE, REFER, INFO, OPTIONS, MESSAGE
Content-Type: text/xml
User-Agent: eXosip/3.6.0
Content-Length: 166

<regXML>
<version>V2.0.0</version>
<regDevName>Asterisk</regDevName>
<regDevSerial>Q12345678</regDevSerial>
<regDevMacAddr>00:0c:29:12:12:12</regDevMacAddr>
</regXML>
DEBUG:sip-server:SIP/2.0 403 Forbidden
Via: SIP/2.0/UDP 192.168.0.64:5061;rport=5061
From: "Asterisk" <sip:[email protected]:5065>
To: "" <sip:[email protected]:5065>;tag=299214106
Call-ID: 6559179837
CSeq: 2 REGISTER
User-Agent: sipServer
Content-Length: 0


INFO:sip-server:We are unauthorized
^CException ignored in: <module 'threading' from '/usr/lib/python3.7/threading.py'>
Traceback (most recent call last):
  File "/usr/lib/python3.7/threading.py", line 1281, in _shutdown
    t.join()
  File "/usr/lib/python3.7/threading.py", line 1032, in join
    self._wait_for_tstate_lock()
  File "/usr/lib/python3.7/threading.py", line 1048, in _wait_for_tstate_lock
    elif lock.acquire(block, timeout):
KeyboardInterrupt
root@raspbx:~# 

_S

indeed, the 9310/9510 is indeed android based
But i have 2 revisions, on rev A i also need script, on rev B i can work witouth script…

I think some models need the REGXML part in the register header, and some do not… And its not possible in Asterisk/FreePBX to send regXML, thats why the script was created…
Anyway, the 403 forbidden i think it just means the password you used is incorrect? Normally when adding the extension with IVMS , you need to define an registration password? it must be the same as the other passwords you used also in indoor/outdoor

Are you using the same ones?

PS: since VOIP is also coming to HA using pyVoip, i already request to have support for REGXML, so the script wont be needed anymore in future, and it should be possible to use HA to register on indoor stations

I backed out all the config and started a fresh, as had been playing so much - looks like you were right and was a password issue.

pjsip_custom.conf now looks like this:

[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.254.12

and showing registered in iVMS.

So going forward, I’d like to have the incoming call directed to a ring group (5150). Could you help with modifying your dialplan? I have handphones with no video, so just audio at this stage.

Hi, thats good indeed!! The scripr you need to run on same host as running your FreePBX, the script runs on port 5061 , you need to run FreePBX on 5060 , seems the invite coming from the indoor station is always hardcoded to 5060 … and running both script on that port doesnt work offcourse

Try calling to 1000000005 from your indoor, you should see the invite coming in?
I dont use groups or follow me … but it should be easy to create in freepbx? i dont use it, i use Asterisk

In asterisk i use dialgroups, as example below , but i use PJSIP instead of SIP
https://wiki.asterisk.org/wiki/display/AST/Function_DIALGROUP

In my example 1 on gitgub, i have a simple example using dialgroups:

edit: seems the example is wrong, let me correct it
edit2 : corrected

I see the incoming connection, but the call immediately drops. Asterisk logs show:

9610	[2023-05-10 09:31:46] VERBOSE[2059] pbx_variables.c: Setting global variable 'SIPDOMAIN' to '192.168.0.64'	
9611	[2023-05-10 09:31:46] VERBOSE[2064][C-00000001] pbx.c: Executing [10000000005@default:1] Playback("PJSIP/hikvision-00000000", "vm-goodbye") in new stack	
9612	[2023-05-10 09:31:46] VERBOSE[2064][C-00000001] file.c: <PJSIP/hikvision-00000000> Playing 'vm-goodbye.ulaw' (language 'en')	
9613	[2023-05-10 09:31:47] VERBOSE[2064][C-00000001] pbx.c: Executing [10000000005@default:2] NoOp("PJSIP/hikvision-00000000", "ERROR: FreePBX Does not use the [default] context, confguration error") in new stack	
9614	[2023-05-10 09:31:47] VERBOSE[2064][C-00000001] pbx.c: Executing [10000000005@default:3] Macro("PJSIP/hikvision-00000000", "hangupcall") in new stack	
9615	[2023-05-10 09:31:47] WARNING[2064][C-00000001] app_macro.c: Macro() is deprecated and will be removed from a future version of Asterisk.	
9616	[2023-05-10 09:31:47] WARNING[2064][C-00000001] app_macro.c: Dialplan should be updated to use Gosub instead.	
9617	[2023-05-10 09:31:47] VERBOSE[2064][C-00000001] pbx.c: Executing [s@macro-hangupcall:1] GotoIf("PJSIP/hikvision-00000000", "1?theend") in new stack	
9618	[2023-05-10 09:31:47] VERBOSE[2064][C-00000001] pbx_builtins.c: Goto (macro-hangupcall,s,3)	
9619	[2023-05-10 09:31:47] VERBOSE[2064][C-00000001] pbx.c: Executing [s@macro-hangupcall:3] ExecIf("PJSIP/hikvision-00000000", "0?Set(CDR(recordingfile)=)") in new stack	
9620	[2023-05-10 09:31:47] VERBOSE[2064][C-00000001] pbx.c: Executing [s@macro-hangupcall:4] Hangup("PJSIP/hikvision-00000000", "") in new stack	
9621	[2023-05-10 09:31:47] VERBOSE[2064][C-00000001] app_macro.c: Spawn extension (macro-hangupcall, s, 4) exited non-zero on 'PJSIP/hikvision-00000000' in macro 'hangupcall'	
9622	[2023-05-10 09:31:47] VERBOSE[2064][C-00000001] pbx.c: Spawn extension (default, 10000000005, 3) exited non-zero on 'PJSIP/hikvision-00000000'	
9623	[2023-05-10 09:31:47] VERBOSE[2064][C-00000001] pbx.c: Executing [h@default:1] Playback("PJSIP/hikvision-00000000", "vm-goodbye") in new stack	
9624	[2023-05-10 09:31:47] VERBOSE[2064][C-00000001] file.c: <PJSIP/hikvision-00000000> Playing 'vm-goodbye.ulaw' (language 'en')	
9625	[2023-05-10 09:31:47] VERBOSE[2064][C-00000001] pbx.c: Executing [h@default:2] NoOp("PJSIP/hikvision-00000000", "ERROR: FreePBX Does not use the [default] context, confguration error") in new stack	
9626	[2023-05-10 09:31:47] VERBOSE[2064][C-00000001] pbx.c: Executing [h@default:3] Macro("PJSIP/hikvision-00000000", "hangupcall") in new stack	
9627	[2023-05-10 09:31:47] VERBOSE[2064][C-00000001] pbx.c: Executing [s@macro-hangupcall:1] GotoIf("PJSIP/hikvision-00000000", "1?theend") in new stack	
9628	[2023-05-10 09:31:47] VERBOSE[2064][C-00000001] pbx_builtins.c: Goto (macro-hangupcall,s,3)	
9629	[2023-05-10 09:31:47] VERBOSE[2064][C-00000001] pbx.c: Executing [s@macro-hangupcall:3] ExecIf("PJSIP/hikvision-00000000", "0?Set(CDR(recordingfile)=)") in new stack	
9630	[2023-05-10 09:31:47] VERBOSE[2064][C-00000001] pbx.c: Executing [s@macro-hangupcall:4] Hangup("PJSIP/hikvision-00000000", "") in new stack	
9631	[2023-05-10 09:31:47] VERBOSE[2064][C-00000001] app_macro.c: Spawn extension (macro-hangupcall, s, 4) exited non-zero on 'PJSIP/hikvision-00000000' in macro 'hangupcall'	
9632	[2023-05-10 09:31:47] VERBOSE[2064][C-00000001] pbx.c: Spawn extension (default, h, 3) exited non-zero on 'PJSIP/hikvision-00000000'	

Not sure if this is just because there is nowhere to route the call, or some other error?