Open jmnovak50 opened 2 years ago
Hello. I will try to help you. Can you provide sip doorbell model?
Hi @spbroot!! Thank you so much for your help! It is a Hikvision DS-KV6113-WPE1(B).
Generally API support fairly decent, however, this area is pretty weak.
Thanks so much!
Best Regards,
Jason
Hi. About ALSA: On Raspbian and Ubuntu, I didn't install anything for ALSA. I think you can test ALSA run command "aplay -l" and "arecord -l" If Loopback Device added, you shoud get something like that:
pi@homebridge:~ $ aplay -l List of PLAYBACK Hardware Devices card 0: Loopback [Loopback], device 0: Loopback PCM [Loopback PCM] Subdevices: 8/8 Subdevice #0: subdevice #0 Subdevice #1: subdevice #1 Subdevice #2: subdevice #2 Subdevice #3: subdevice #3 Subdevice #4: subdevice #4 Subdevice #5: subdevice #5 Subdevice #6: subdevice #6 Subdevice #7: subdevice #7 card 0: Loopback [Loopback], device 1: Loopback PCM [Loopback PCM] Subdevices: 8/8 Subdevice #0: subdevice #0 Subdevice #1: subdevice #1 Subdevice #2: subdevice #2 Subdevice #3: subdevice #3 Subdevice #4: subdevice #4 Subdevice #5: subdevice #5 Subdevice #6: subdevice #6 Subdevice #7: subdevice #7 card 1: Headphones [bcm2835 Headphones], device 0: bcm2835 Headphones [bcm2835 Headphones] Subdevices: 8/8 Subdevice #0: subdevice #0 Subdevice #1: subdevice #1 Subdevice #2: subdevice #2 Subdevice #3: subdevice #3 Subdevice #4: subdevice #4 Subdevice #5: subdevice #5 Subdevice #6: subdevice #6 Subdevice #7: subdevice #7
About HIKVISION SIP: Looks like hikvision doorbell not support Direct SIP call (P2P SIP). Hikvision works as SIP client. Baresip works as SIP client. For communication Hikvision and Baresip without P2P SIP you need to use SIP server.
For example, you have Asterisk SIP server with IP 192.168.1.201 You need to create 2 SIP account on this asterisk server: 101, 102
You need to configure Hikvision sip account: Register User Name: 101 ... Server address: 192.168.1.201 ... Number: 101 Display User Name: 101
You need to configure Baresip account: <sip:102@192.168.1.201>;auth_pass=ACCOUNT_102_PASSWORD;
Also you need to configure Hikvison:
Configuration -> Intercom -> Press Button to Call
I don't have hikvision doorbell panel for test this function, but i think you need to add number "102" on "SIP1" cell.
Thank you @spbroot!
This is really helpful! I think alsa is setup correctly.
With regards to Hikvision, yes, I realize that now...that they do not support in a P2P manner.
I think recommendation on some other boards to setup fusionPBX w freeswitch.
I just finally installed it and now trying to figure out how to set it up. 1 step forward, 5 steps back, I'm afraid.
Will keep you posted on my progress! Thank you so so much again!
Best Regards,
Jason
Hey @spbroot!
Thank you sooo much! Actually I've progressed to find out that my camera does support 2 Way Audio via local API.
Seems I can do in 4 steps I can open up a 2-way audio connection by issue a PUT to the URL: http://192.168.1.xxx/ISAPI/System/TwoWayAudio/channels/1/open I can get streamed audio data by issuing a GET command to the URL: http://192.168.1.xxx/ISAPI/System/TwoWayAudio/channels/1/audioData I can send streamed audio data by issuing a PUT command to the URL: http://192.168.1.xxx/ISAPI/System/TwoWayAudio/channels/1/audioData and finally, I can close the 2 way audio connection by issuing a PUT to the URL: http://192.168.1.xxx/ISAPI/System/TwoWayAudio/channels/1/close
which seems a bit more simple than going the SIP route??
It looks like you've done maybe something barely similar....Any ideas on approaches how I could accomplish this given my API's??
Any advice you could provide would be extremely appreciated!!
Best Regards,
Jason
I was able to achieve this by using this, make sure your audio file is formatted as 8bit, 8000khz, mulaw and mono channel
import urllib.request
import requests
import socket
import time
from requests.auth import HTTPDigestAuth
class SocketGrabber:
""" A horrible hack, so as to allow us to recover
the socket we still need from urllib """
def __init__(self):
self.sock = None
def __enter__(self):
self._temp = socket.socket.close
socket.socket.close = lambda sock: self._close(sock)
return self
def __exit__(self, type, value, tb):
socket.socket.close = self._temp
if tb is not None:
self.sock = None
def _close(self, sock):
if sock._closed:
return
if self.sock == sock:
return
if self.sock is not None:
self._temp(self.sock)
self.sock = sock
audio_file = "output.wav"
chunksize = 128
sleep_time = 1.0 / 64
req = requests.put(
f"http://192.0.0.65/ISAPI/System/TwoWayAudio/channels/1/open",auth=HTTPDigestAuth('admin', 'password'))
mgr = urllib.request.HTTPPasswordMgrWithDefaultRealm()
mgr.add_password(None, [base], 'admin', 'password')
auth = urllib.request.HTTPDigestAuthHandler(mgr)
opener = urllib.request.build_opener(auth)
audiopath = "http://192.0.0.65/ISAPI/System/TwoWayAudio/channels/1/audioData"
with SocketGrabber() as sockgrab:
req = urllib.request.Request(audiopath, method='PUT')
resp = opener.open(req)
output = sockgrab.sock
def frames_yield(ulaw_data, chunksize=128):
for i in range(0, len(ulaw_data), chunksize):
for x in [ulaw_data[i:i + chunksize]]:
tosend = x + (b'\xff' * (chunksize - len(x)))
time.sleep(sleep_time)
yield tosend
with open(audio_file, 'rb') as file_obj:
ulaw_data = file_obj.read()
for dataframe in frames_yield(ulaw_data, chunksize):
output.send(dataframe)
req = requests.put(
f"http://192.0.0.65/ISAPI/System/TwoWayAudio/channels/1/close",auth=HTTPDigestAuth('admin', 'password'))
hey @jmnovak50 , i also saw you o HA forums, did you manage to get twowayaudio to work ?
@sayan-futurehook , how did you implement this in the baresip client? How are you receiving the call ? Whats your usecase?
The hikvision do run a propertiary SIP protocol for their indoor devices, you can also regeister on it like an indoor station does The problem is, that there is no two way audio, ...
You can register on the doorstation IP, but use port 5065 ... As username use: 10010110001
Hey @pergolafabio. Great to see you over here! Unfortunately, not…was way too complicated…couldn’t get SIP to connect…resorted to Scrypted for what I needed to get done. Still not perfect…TBH I’m trying to rethink my whole Doorbell strategy on using Hikvision altogether and moved on to Reolink. 2-Way audio a problem over there too, however they are making promises to provide connectivity. Waiting for the perfect camera to come up w Matter support…wouldn’t that be nice?
Indeed :-)
I don't know scrypted... What is your use case there? How do you receive calls and talk then if you don't use sip?
My use case is fairly simple. My whole family uses HomeKit. We use the doorbell as a shared camera.
Requirements are: 1) Expose the camera in HomeKit a) ability to talk from HomeKit from the video 2) Ability to Receive Doorbell Notifications from HomeKit 3) Ability to receive motion notifications at the user level 4) Ability for the HomeKit user to view past video captures based on motion detection/doorbell push
How were these points accomplished?
1) Expose the camera in HomeKit a) ability to talk from HomeKit from the video
Leveraged the OOTB Plugin available in Scrypted ( @.***/hikvision). This provides RTSP streaming and 2-Way Talk
2) Ability to Receive Doorbell Notifications from HomeKit
Poll API available from HV doorbell and send messages to MQTT using Node Red Expose a dummy switch in Scrypted to Homekit Expose a MQTT sensor in Scrypted to Homekit Create a script in Scrypted; create a grouped camera with that script in Scrypted and dummy switch Create a rule in Homekit to trigger dummy switch from exposed MQTT Sensor (Im sure there is a better, more efficient way to do this)
3) Ability to receive motion notifications at the user level
Scrypted uses plugins for motion detection, which does the analysis on the stream, which i found to be quite effective. The one i used was OpenCV, which you can configure when you create on the grouped or base camera from Scrypted.
4) Ability for the HomeKit user to view past video captures based on motion detection/doorbell push
Use HSV. The HomeKit plugin on scrypted supplies this.
The only downside to this apparent patchwork Ive thrown together, which Im trying to figure out, and it appears to be problematic on your end as well, is there is no way to stop the doorbell from ringing if you push talk in the homekit feed. Ive tried various APIs in the HV camera (eg. 2-way audio open) you'd think HV would fix, but no such luck (see below).
Why am I shifting to Reolink at some point in the future? My HV camera is the KV-6113 (think v1) which it appears to now be de-supported from firmware updates, so I effectively have taken this as far as i can with HV and the whole reason, for me at least, I chose the HV was that it was the best POE doorbell camera at the time in my pricepoint. Reolink seems to be the new leader now, however, currently, I'm looking at their APIs and ironically, 2-way audio is lacking.
A couple of annoyances with the HV architecture...1) pretty simple leverage a motion detection api from the device. 2) Have the open 2 way audio api stop the ringing on the doorbell side. To me, at least this seems obvious. 3) Throughout my journey w HV, they really havent been transparent on documentation directly. Ive had to source out the documentation in areas like your group conversation in HomeAssistant Seems as if Reolink might be following in their footsteps?
Anyway, Ive gone through lots of digressions here but hopefully that clearly articulates the use cases. Im sure you have more questions (I would!).
Enjoy the day! :)
Best Regards,
J.
On Sat, Feb 11, 2023 at 1:07 AM pergolafabio @.***> wrote:
Indeed :-)
I don't know scrypted... What is your use case there? How do you receive calls and talk then if you don't use sip?
— Reply to this email directly, view it on GitHub https://github.com/spbroot/sipdoorbell/issues/2#issuecomment-1426643023, or unsubscribe https://github.com/notifications/unsubscribe-auth/AS7LHN2ZQZEEMIZPHXCWB6DWW43E5ANCNFSM5KMCUUMQ . You are receiving this because you were mentioned.Message ID: @.***>
Just realized I maybe didnt answer your question directly.... looking at the code the scrypted camera plugin, looks like it uses the 2-way audio open close mechanism or by ONVIF. Since my camera doesnt support onvif it looks like its using the Hikvision apprach to 2-way.
Ok , and all that for a doorbell :-)
Well, actually, I want the same... The issue was indeed to drop the callsignal, I included that event in my addon, I can now answer / reject the call..
Next step is indeed activate isapi with two way audio
No kidding, right?
Originally, I thought of maybe having a simple branch flow in Node Red on making that call a few seconds after someone pushes the doorbell. I'll give callSignal a try.
Definitely have a look into the code of the Hikvision plugin. That should give you a good steer.
Great work on the addon BTW!
Hope that helps!
Best Regards,
Jason
On Sat, Feb 11, 2023 at 3:19 PM pergolafabio @.***> wrote:
Ok , and all that for a doorbell :-)
Well, actually, I want the same... The issue was indeed to drop the callsignal, I included that event in my addon, I can now answer / reject the call..
Next step is indeed activate isapi with two way audio
— Reply to this email directly, view it on GitHub https://github.com/spbroot/sipdoorbell/issues/2#issuecomment-1426878751, or unsubscribe https://github.com/notifications/unsubscribe-auth/AS7LHN2N3BNOLTOZX6P2FA3WW7667ANCNFSM5KMCUUMQ . You are receiving this because you were mentioned.Message ID: @.***>
Will do , thnx!
Hi @spbroot!
Thank you so much for providing this SIP solution. I've been struggling to find a 2-way SIP audio connection point into the camera ffmpeg extension as it appears that my doorbell manufacturer only allows 2 way audio via sip right now, unfortunately.
I am starting to go through your documentation on this and I'm stuck at the following:
With regards to Alsa....
I'm supposed to create an asound.conf, however, are there any pre-requisite packages I need?? I'm not 100% sure I have those??
The second question is:
Add a SIP account to the file /home/pi/.baresip/accounts
I'm assuming i need to setup 2 accounts, correct?
On the 2nd one, I'm guessing this is the one I need to set my doorbell to?
SIP config on my doorbell looks like this...![hiksipss](https://user-images.githubusercontent.com/79606711/146683982-b233e677-a9cc-441b-86e9-7283cffca456.jpg)
Or am I getting this completely wrong?? Sorry for the dumb questions, SIP protocol is new territory for me.
Any help would be greatly appreciated!
Best Regards,
Jason