Doorbird video doorbell binding

As I understand the Doorbird API, if a relay is activated through the Doorbird app, there’s no feedback of that action through the API. So it’s not possible for the binding to know about any relay activations made through the app.

Ok, puh. That is an explanation why I don’t get any response. Thank you for this information. But that means the Controller thing is completely whithout function or is there anything which could be done in OH with it?

You should be able to use OH to activate the relays.

Makes sense, you are right. Thanks Mark!

Were you able to figure out the work around example? The API documentation for the door bird has said that http commands for keypad events have been coming soon…for the last 2 or so years at least. My understanding is that the only way to get them is through udp.

Yes, just define a http call on your doorbird (yourIP is the IP adress of your Node-RED instance):
grafik

and link it to a “Keypad code”:

On Node-RED it can look like this. The sample shows a http get node, which is direktly linked to a switch item through “node-red-contrib-openhab2”. The msg node is only for debugging:
grafik

Good news - after hours of fiddling I’ve found a straightforward way to transmit audio to the doorbird, at least if you’re running linux.

First, convert your audio file to a G.711 µ-law 8000hz wav file:

ffmpeg -f -i YOURAUDIOFILE -codec:a pcm_mulaw -ac 1 -ar 8000 output.wav

Then use gstreamer to send to the doorbird:

gst-launch-1.0 filesrc location=output.wav ! wavparse ! curlhttpsink location="http://IP-ADDRESS/bha-api/audio-transmit.cgi?http-user=USERNAME&http-password=PASSWORD"

Easy!

(Yes, in principle gstreamer should be able to do the conversion itself, but I just couldn’t get this to work, and ffmpeg is so fast we lose nothing from the extra step)

1 Like

Hi, just if you want to change it: this should be the command in one call just via gstreamer (tested):

gst-launch-1.0 filesrc location=YOUR_FILE.mp3 ! decodebin ! audioresample ! audioconvert ! audio/x-raw,format=S16LE,rate=8000 ! mulawenc ! curlhttpsink location="http://ADDRESS/bha-api/audio-transmit.cgi?http-user=USERNAME&http-password=PASSWORD"

interestingly that doesn’t work for me - gstreamer thinks it sent the file, but the doorbird plays clicks/corrupted noises.

I should have added that my solution isn’t perfect - you get clicks every half second or so whilst the audio is playing. But it is intelligible, which is something!

Hi @ dalgwen and @ mhilbush
I think the code which you provided here [doorbird] Add audiosink · dalgwen/openhab-addons@11e9693 · GitHub is close to be working. But you need to provide the stream in chunks and wait in between to simluate streaming.

I tested parts of your code without openhab just in plain java and made some changes and it works:

DeferredContentProvider content = new DeferredContentProvider();

ContentResponse contentResponse = client.POST(url)
	.header("Content-Type", "audio/basic")
	.header("Content-Length", "9999999")
	.header("Authorization", "Basic " + auth.getAuthorization())
	.header("Connection", "Keep-Alive")
	.header("Cache-Control", "no-cache")
	.content(content)
	.send();

byte[] data = new byte[160];	
while(audioInputStream.available() > 0) {
	audioInputStream.read(data);
	content.offer(ByteBuffer.wrap(data));
	Thread.sleep(20);
}

Maybe you can try that, I successfully played a static ulaw file with that code.

I tested it with that mp3 file: https://filesamples.com/samples/audio/mp3/Symphony%20No.6%20(1st%20movement).mp3

Is this also not working for you?

interestingly it doesn’t - I just get some clicks.

Different gstreamer version? Mine is GStreamer 1.16.2 running on ubuntu

Dan

I also had some clicking at the beginning, then changed the command. Could you try that one (added a few parameters from the api documentation)?

gst-launch-1.0 filesrc location=YOUR_FILE.mp3 ! decodebin ! audioresample ! queue ! audioconvert ! "audio/x-raw,format=S16LE,rate=8000" ! mulawenc ! curlhttpsink location="http://ADDRESS/bha-api/audio-transmit.cgi?http-user=USERNAME&http-password=PASSWORD" content-type="audio/basic" use-content-length=true

This does not have any clicking sound for me. It just needs a short time until the sound starts.
By the way, I am using an older GStreamer version, but it should not make a difference (1.14.5)

Interesting, thank you !
I’m on holidays right now, I will try to check it next week.
Could you please provide me with your ulaw test file ?
Doorbird seems to be very picky about format.

This is the ulaw file: File-Upload.net - symph.raw
It is the same one like the MP3 file which I used for the gstreamer test, just converted it with Audacity with the following steps:

  • Import the MP3
  • Set project frequency at the bottem left to 8000
  • In the top menu: tracks → Mix → Stereo to Mono
  • File → Export → Audio → Select “other uncmpressed types” and in the format options: Header: RAW, Encoding: U-Law

But I think your code would at least play some noise if you add my changes there instead of just giving you a 200. The main issue is, that you post the whole file at once instead of streaming it.

weird that we both have such different results. On my ubuntu system, the addition of ‘use-content-length=true’ results in “ERROR: from element /GstPipeline:pipeline0/GstCurlHttpSink:curlhttpsink0: HTTP response error: (received: 400)”

on my raspberry pi with an older gstreamer (1.14.4), I don’t get the error, but I get corrupted audio.

If I add ‘use-content-length=true’ to my simple wav streaming pipeline, it again fails with a 400 error on the ubuntu system, but works perfectly (and without clicking!) on my raspberry pi.

So I now have the world’s most hacky audio system, with openhab converting an MP3 to wav using FFMPEG, then SCPing the result to the raspberry pi, and then running gstreamer on the pi using SSH. But it is better than it was before - so thank you!

Just to add: same results on two doorbirds - D101S, latest firmware 000134, D1101V (latest firmware 000131). So seems certain it’s weirdness in different gstreamer installations.

So, with the hint from @BerndZ (thank you !), I made some progress, and I have now a beta version with audio sink capability for the doordbird binding.

I’m not 100% satisfied, because :

  • The sound is not very good ? (would like your opinions on this)
  • Sometimes it doesn’t work. The audio is sent, the response is OK, but the Doorbird produces no sound. Does it also happen to you ?

Here is the snapshot to download. Beta tester welcome !

Only WAV files are supported (PCM, or ULAW). You shouldn’t have to worry about frequency, channel, sample rate or whatever, etc, as the code should convert it on the fly. If it doesn’t work, say it here and post the file you used.

I could add support for MP3 (as I did on the pulseaudio binding), but then I would have to add a dependency to another library (@mhilbush do you have an opinion ?)

By the way, @mhilbush, when (and if) it is ready, how do you usually proceed for merging code from another contributor ? Should I make a pull request to you ? Or directly to the openhab repository and you will review it ?

If it is satisfying, on the long term, I think it should be possible to add an audio source as well.
And with this, the doorbird could become a vocal assistant/conversation agent. So much fun to be a geek :rofl:

1 Like

The more libraries there are, the more to maintain by keeping libraries up to date. I’d suggest focusing on making sure the WAV version works consistently and reliably.

Normally you would just make a PR to the openhab-addons repo.

@mhilbush
Ever thought about asking Bird Home Automation GmbH (the DoorBird manufacturer) to add openHAB to their DoorBird Connect partners (see Video door intercom and video doorbell for iOS, Android, iPhone, iPad, Smartphone and Tablet)?
I am asking, because FHEM and ioBroker are listed there as well and improving visibility is always good.

No, I hadn’t considered it, but it’s a very good idea. Thanks.

1 Like