Doorbird video doorbell binding

I’m really interested in this !
Do you have some resources about this ?

In exchange, I can share some informations about audio sink in openhab :wink: :
@mhilbush an audiosink is the other way around : openHAB send audio data to the device.
It seems that the doorbird API has the audio-transmit.cgi path to do this.
It is, as you said it, a u-law codec. I’m not completely sure about this, but I think it’s possible to convert sound file to this codec without much hassle.

I would like to look into it, it seems interesting, but I have a big todo list, so I put an additional information here in case someone is interested and faster than me :
As I made the pulseaudio audio sink, I was confronted to similar conversion difficulty. Here is the conversion code I did (stream to stream)

Changing the TARGET_FORMAT should, maybe, be sufficient ?

Ah, right. I was thinking about it in terms of the Doorbird being an audio source (via audio-receive.cgi). But, yes, it’s the transmit one that would be for a sink.

Hmm. It does look like javax.sound might do the trick. And your pulseaudio implementation looks to be the same stream-to-stream conversion approach that would be needed here.

Yes, me too at the moment.

In the meantime, as a PoC, I suppose someone could try using ffmpeg and curlhttpsink from the command line to prove you can stream some WAV or MP3 content to the Doorbird.

Here’s a link to a guide on how to set up facial recognition in Zoneminder. Though I should add that this system recognises that there is a face in the camera’s view, it doesn’t recognise specific faces. I.e. it can see a that there is a face, not specificially Bill’s face or Sarah’s face.

I have read at least one other guide on how to train systems to recognise particular faces but I don’t have the links to hand at the moment. I’ll have another search later.

The Google Coral TPU can be used to accelerate the image processing and is far faster and more energy efficient than using the CPU.

@higgers Thank you, very interesting !

Even if I should have not (so many things to do !), I did not resist and I did have a look to this audio sink idea.
Aaaaannnd, I failed miserabily, near the end. I send ULAW audio to the doorbird endpoint, and the doorbird device respond with a HTTP 200. But to no avail : no sound.
The result of my work is here, if someone want to check.
I am sorry, but short of idea to make it work !

If only I could have more information from the doorbird. Do we have a way to get more information from it (log maybe?) ?

Thanks for trying this. Unfortunately, I don’t know enough to be able to check what you’ve done. It looks right, but there may be some details about the ulaw stream that might prevent the Doorbird from processing the audio stream.

I’m not aware of any logs that can be pulled from the device.

Hi guys,

as mentioned some month ago, there are some channels shown as NULL for my doorbird devices. Especially the channels of Doorbrid Controller A1081 are all three not reachable, what should be my next project.

I tried a few basic things (re-add channels / thing, restart Controller, restart OH3, …) but still the same.
I set doorbird binding to DEBUG and started with activating one of the relay in the doorbird app. But as there is no action detected in OH since the item is NULL, there was no entry in the log file at all (like expected).
I then deleted the Controller thing an re-added it. There are those 2 lines in the log file:

2022-02-13 19:55:43.588 [DEBUG] [ng.doorbird.internal.api.DoorbirdAPI] - Executing doorbird API request: http://192.168.178.34/bha-api/info.cgi
2022-02-13 19:55:43.588 [DEBUG] [ng.doorbird.internal.api.DoorbirdAPI] - Doorbird returned json response: {"BHA": { "RETURNCODE": "1", "VERSION": [{"FIRMWARE": "000131","BUILD_NUMBER": "16354998","WIFI_MAC_ADDR": "MY_MAC_ADDRESS","RELAYS":["1","ghXXX@1","ghXXX@2","ghXXX@3"],"DEVICE-TYPE": "DoorBird D1101V-S"}]}}

Additionally there is the following entry (not sure whether it comes from creating an item or activating in Doorbird app):

2022-02-13 19:56:12.009 [DEBUG] [d.internal.handler.ControllerHandler] - Got command REFRESH for channel doorbird:a1081:DoorbirdController:openDoor1 of thing doorbird:a1081:DoorbirdController

I don’t see any hint why the channels are not working. Any advice from your side?

P.S.:
IP address and user/pwd in Controller thing’s configuration are from the doorbell not the controller. The mentioned user has all permissions for the Controller, I’ve double-checked that.

Any ideas what to check / where to look at?
@mhilbush maybe you can point me in the right direction?

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)