Hik-Connect

Thank you, it helped. Specifically this post by Ivan1985: Hikvision FIRMWARE TOOLS - change language, extract files and create own firmware | Page 44 | IP Cam Talk

But he share old version of FW… 1.5.0, newer is 1.5.1

1 Like

But you can compile it yourself

Probably file in post this is for you with latest FW 1.5.1

Hi guys,
I have two doorbells who managed by some company in my block of flats,
Can I integrate their in my homeassistant if their not in my local network ?
Best case for me → when call doorbell → show picture in picture stream on apple tv / iPhone → option for unlock door.
just now I’m added it but without video stream only for unlock-option using your integration with hik-connect

Hello, I have the same setup. If you don’t have LAN access to doorbells, the only option left is to pull video stream over Hikconnect service. This is feature everyone wants, but nobody was able to implement it yet: Add live view from Hik-Connect connected cameras · Issue #6 · tomasbedrich/home-assistant-hikconnect · GitHub Another option –maybe, if you have intercom with Wifi, you can connect directly to it.

1 Like

yes I’ll connect my DS-KH8350-WTE1 to home wifi network and I’ll try to add it to homeassistant and HomeKit, thank you
but, I don’t want to get two different integration, first with video streaming and second integration for unlocking doorbell

have you tried that hikkup to intercept traffic?

No, hikkup cannot work for me. There is nothing to intercept. From its README:

… After this, power your wifi doorbell and make sure it connects to the same network as your PC resides in …

In my setup neither doorbell nor intercom is connected to my network.

1 Like

Indeed, you don’t have acces to it :+(

Too bad indeed

Could you please share this sip.py script? I’m very interested to try the SIP approach with Hikvision Indoor Station. Thank you.

here you go… it can be used as a shell command
or you can just use asterisk and register a trunk on the indoor station
Remember, video doesnt forward to the softphone, i dont know why…

Thank you for sharing the script. The indoor station model I have is DS-KH8520-WTE1:

https://www.hikvision.com/en/products/Video-Intercom-Products/IP-Series/Pro-Series/ds-kh8520-wte1/

I did try the Asterisk add-on configured with trunk settings, according the instructions at your GitHub.

Unfortunately, this indoor station seems to not have the UDP port 5065 open, therefore Asterisk logs just show connection error.

There is any other configuration to be made using iVMS-4200? (besides the screenshot at your GitHub page)

Once again thank you for your help. Truly appreciated.

Hmm, no, no extra settings needed, by default normally 5065 should be open…

Do you perhaps have 2 indoor stations, otherwise you could Wireshark it…
Have you tried to run a portscan on the device ? Maybe it’s another port

The UDP port 5065 is actually open! I got confuse with the log message “No response received from ‘sip:10.9.4.2:5065’ on registration attempt”, sorry about that.

But not got working yet, hopefully you can help.

IP Addresses:

Asterisk IP: 10.9.1.2
Indoor Station IP: 10.9.4.2

Here is how the Intercom → Extension Settings are configured (via iVMS-4200):

Device Type: Indoor Extension
Serial No.: EXTENSION
IP Address: 10.9.1.2
Gateway: 10.9.0.1
Subnet Mask: 255.255.0.0
Password: ThePassword
SIP No.: 10000000002
No.: 2

And here is the pjsip_custom.conf (Asterisk Trunk):

[siptrunk-auth]
type=auth
auth_type=userpass
username=10000000002
password=ThePassword

[siptrunk-aor]
type=aor
contact=sip:10.9.4.2:5065

[siptrunk-registration]
type=registration
outbound_auth=siptrunk-auth
server_uri=sip:10.9.4.2:5065
client_uri=sip:[email protected]:5065
contact_user=10000000002
retry_interval=10
expiration=600

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

[siptrunk-identify]
type=identify
endpoint=siptrunk-endpoint
match=10.9.4.2

Asterisk logs:

[Oct 24 10:44:33] WARNING[361]: res_pjsip_registrar.c:1166 find_registrar_aor: AOR '' not found for endpoint 'siptrunk-endpoint' (10.9.4.2:5065)
[Oct 24 10:44:33] WARNING[361]: res_pjsip_registrar.c:1166 find_registrar_aor: AOR '' not found for endpoint 'siptrunk-endpoint' (10.9.4.2:5065)
[Oct 24 10:44:34] WARNING[361]: res_pjsip_registrar.c:1166 find_registrar_aor: AOR '' not found for endpoint 'siptrunk-endpoint' (10.9.4.2:5065)
[Oct 24 10:44:36] WARNING[361]: res_pjsip_registrar.c:1166 find_registrar_aor: AOR '' not found for endpoint 'siptrunk-endpoint' (10.9.4.2:5065)
[Oct 24 10:44:40] WARNING[361]: res_pjsip_registrar.c:1166 find_registrar_aor: AOR '' not found for endpoint 'siptrunk-endpoint' (10.9.4.2:5065)
[Oct 24 10:44:44] WARNING[361]: res_pjsip_registrar.c:1166 find_registrar_aor: AOR '' not found for endpoint 'siptrunk-endpoint' (10.9.4.2:5065)
[Oct 24 10:44:48] WARNING[361]: res_pjsip_registrar.c:1166 find_registrar_aor: AOR '' not found for endpoint 'siptrunk-endpoint' (10.9.4.2:5065)
[Oct 24 10:44:52] WARNING[361]: res_pjsip_registrar.c:1166 find_registrar_aor: AOR '' not found for endpoint 'siptrunk-endpoint' (10.9.4.2:5065)
[Oct 24 10:44:56] WARNING[361]: res_pjsip_registrar.c:1166 find_registrar_aor: AOR '' not found for endpoint 'siptrunk-endpoint' (10.9.4.2:5065)
[Oct 24 10:45:00] WARNING[361]: res_pjsip_registrar.c:1166 find_registrar_aor: AOR '' not found for endpoint 'siptrunk-endpoint' (10.9.4.2:5065)
[Oct 24 10:45:04] WARNING[361]: res_pjsip_registrar.c:1166 find_registrar_aor: AOR '' not found for endpoint 'siptrunk-endpoint' (10.9.4.2:5065)
[Oct 24 10:45:05] WARNING[361]: res_pjsip_outbound_registration.c:908 schedule_retry: No response received from 'sip:10.9.4.2:5065' on registration attempt to 'sip:[email protected]:5065', retrying in '10'

TCPDump:

10:44:33.684339 IP (tos 0x0, ttl 64, id 48139, offset 0, flags [DF], proto UDP (17), length 571)
    10.9.1.2.sip > 10.9.4.2.5065: [bad udp cksum 0x1b4e -> 0x2f93!] SIP, length: 543
        REGISTER sip:10.9.4.2:5065 SIP/2.0
        Via: SIP/2.0/UDP 10.9.1.2:5060;rport;branch=z9hG4bKPj5c9dc0a8-eca3-489c-ab5d-c05509fe598d
        From: <sip:[email protected]>;tag=52909919-953e-445e-ab79-f05f9c10853a
        To: <sip:[email protected]>
        Call-ID: 3512cd47-2d92-4e60-b5e1-ec5a13a51dda
        CSeq: 4585 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: Asterisk PBX 18.14.0
        Content-Length:  0

10:44:33.686966 IP (tos 0x0, ttl 64, id 43241, offset 0, flags [DF], proto UDP (17), length 659)
    10.9.4.2.5065 > 10.9.1.2.sip: [udp sum ok] SIP, length: 631
        REGISTER sip:10.9.4.2:5065 SIP/2.0
        Via: SIP/2.0/UDP 10.9.1.2:5060;rport=5060;branch=z9hG4bKPj5c9dc0a8-eca3-489c-ab5d-c05509fe598d
        From: <sip:[email protected]>;tag=52909919-953e-445e-ab79-f05f9c10853a
        To: <sip:[email protected]>
        Call-ID: 3512cd47-2d92-4e60-b5e1-ec5a13a51dda
        CSeq: 4585 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: Asterisk PBX 18.14.0
        Content-Length: 0
                                ...
10:44:33.687453 IP (tos 0x0, ttl 64, id 48142, offset 0, flags [DF], proto UDP (17), length 442)
    10.9.1.2.sip > 10.9.4.2.5065: [bad udp cksum 0x1acd -> 0x6ca9!] SIP, length: 414
        SIP/2.0 404 Not Found
        Via: SIP/2.0/UDP 10.9.1.2:5060;rport=5065;received=10.9.4.2;branch=z9hG4bKPj5c9dc0a8-eca3-489c-ab5d-c05509fe598d
        Call-ID: 3512cd47-2d92-4e60-b5e1-ec5a13a51dda
        From: <sip:[email protected]>;tag=52909919-953e-445e-ab79-f05f9c10853a
        To: <sip:[email protected]>;tag=z9hG4bKPj5c9dc0a8-eca3-489c-ab5d-c05509fe598d
        CSeq: 4585 REGISTER
        Server: Asterisk PBX 18.14.0
        Content-Length:  0

Not sure what is happening, it seems the the AOR is not being found for the endpoint.

Note: I did not configure any dialplan for the trunk, not sure if is this needed.

Thank you.

hi, see my config below, with ivms i added a second indoor station with NO “5”, it creates then: 10000000005, and i gave it some fake SN…
192.168.0.17 is Asterisk, 192.168.0.71 is the indoorstation , in my screenshot below .72 is some other real indoor station, but not related

[mytrunk-auth]
type=auth
auth_type=userpass
password=XXX
username=10000000005
 
[mytrunk-aor]
type=aor
contact=sip:192.168.0.71:5065

[mytrunk-registration]
type=registration
outbound_auth=mytrunk-auth
server_uri=sip:192.168.0.71: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=XXX.com
 
[mytrunk]
type=identify
endpoint=mytrunk
match=192.168.0.71

It seems your indoor device is not finding the asterisk I think, therefore the 404?
Do you also setup the indoor device with 255.255.0.0 and correct gateway? Maybe as a test , setup asterisk on the same subnet?? Maybe those Hikvision devices are not smart enough to handle other IP ranges :slight_smile:

HA and the Indoor Station are in the same subnet.

I did some troubleshooting based in your script. First emulated the REGISTER request from asterisk, the indoor station replied the same way (basically the reply is a plain copy of the request, this is why all the errors on the Asterisk logs).

After that I just added the following XML body to the request (along with the corresponding Content-Length):

<regXML>
<version>V2.0.0</version>
<regDevName>Asterisk</regDevName>
<regDevSerial>Q12345678</regDevSerial>
<regDevMacAddr>02:11:32:29:12:A4</regDevMacAddr>
</regXML>

The indoor station replied 401, asking for authentication (as expected).

So I added the Authorization header the same way as in your script and got 200 OK!!! :slight_smile: Checking on iVMS-4200 the extension indeed got registered.

It seems my indoor station needs the xml body, I am now trying to figured out how to inject this xml to the Asterisk register request.

Any suggestion are welcome.

Thanks.

Hi , well, that’s not possible … You can’t modify the register request in asterisk, it’s not possible to add those headers … But normally it’s not needed if you have added the device first with ivms…
It works for me… Should also work on your device

Another road , if the script works, just run the script in background on HA start with an automation (the script doest have a RE-REGISTER every xx min)…
Then just setup a trunk on asterisk , but based on IP auth, not on user pass, because its already registered, it will forward the call to asterisk… (invite)

I also have a pjsip example of that, it’s an easy one…v , just launch the script from the same IP where asterisk is running, your script does the REGISTER, on INVITE Asterisk will accept it:

; ########################################  TRUNK HIKVISION RELAY

;[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.0.71

Is there a reason why you want the approach based on registering on indoor? Because only advantage is that you can see the early preview on all indoor panels…

Also, where/how did you modify the script? Because I was already sending the regxlm part with content length? It was already included? I indeed started with the script, but after testing I found out that the regxlm was not needed at all, if you add the device first with ivms