beele / homebridge-unifi-protect-camera-motion

Camera & Motion sensor support for Unifi Protect cameras in Homekit via Homebridge
Apache License 2.0
103 stars 12 forks source link

Two way audio with the doorbell? #39

Closed crxporter closed 2 years ago

crxporter commented 4 years ago

I just scored a G4 doorbell on the beta store.

The API should have everything needed for motion and button alerts. I'm pretty well set there.

When it comes I'm planning to get working on two way audio ... does anyone have any pointers or tips on this? I'm unsure whether HAP-nodejs and/or homebridge has completely figured out two way audio. Also unsure how the two way audio works on the doorbell. It'll certainly be a project to figure out.

Does anyone around here have a micro g3? I know those have two way audio features...

If you'd like, let's use this issue to discuss our findings. If this is out of scope for this project just let me know and I'll look for help elsewhere.

beele commented 4 years ago

I saw a thread on reddit recently about a homebridge plugin that has working two way audio, I'll try to look that up and see what might be useful for implementing this here.

crxporter commented 4 years ago

Awesome, if you can find/share that reddit link I’d appreciate it!

beele commented 4 years ago

https://www.reddit.com/r/homebridge/comments/glo74p/homebridgering_now_supports_2way_audio/
and
https://github.com/dgreif/ring/issues/237#issuecomment-629861348

beele commented 4 years ago

I've had a very quick look and looks to be in https://github.com/dgreif/ring/blob/master/homebridge/camera.ts I'll have an in depth look later ;)

crxporter commented 4 years ago

My doorbell came today. The API is about what I expected except nothing new in the talkback settings. That doesn’t change even if I’m using the app to do 2-way audio.

The 'lastRing' field is updated with “now” every time the button is pressed so button press alerts will be really easy. It’ll be a programmable switch event. Based on previous testing, a payload of 0 to programmable switch linked to doorbell will create a rich alert for the Home app.

I don’t know where to go next for two way audio. If anyone has ideas of things to try I’ll get right on it!

crxporter commented 4 years ago

I spent some time this afternoon trying to get audio playing on the doorbell without much luck. I was working with some guys from the link I referenced above (Feature request: audio stream #232)

We are trying to play audio on the bell from a video file "bunny.mp4". This is where things are with the command:

ffmpeg -i bunny.mp4 -f mpegts -acodec aac -ar 22050 -b:a 64k -strict experimental -ac 1 -map 0:a udp://10.0.1.4:7004

The endpoint with port 7004 is what shows in the talkbackSettings output on the API. The doorbell led turns blue and the screen shows "Talking" - but no audio plays. I'm pretty sure there's something missing or we are sending a filetype that the bell doesn't like.

Any and all thoughts will be appreciated and considered! I assume the doorbell and G3 Micro cameras have the same 2-way audio setup once we figure it out... I can't find anyone who's figured out the G3 Micro though.

Edit: port 7004 is also confirmed via wireshark at that IP address to be receiving traffic during talkback.

mikestecker commented 4 years ago

Just received and installed mine today... watching.

crxporter commented 4 years ago

Update from my setup: doorbell button presses are 100% reliable and extremely fast. I usually get a snap of the person still reaching towards the bell on my rich notification.

That’s the good news. Bad news is I haven’t gotten back to more digging for 2-way audio. If anyone has pointers please share! I’ll get back to my digging eventually but probably not till mid August or so.

beele commented 4 years ago

homebridge-unifi-protect-camera-motion@0.4.1-Beta.5 now supports the doorbell functionality and manual triggering. No two way audio though.

Add: "enable_doorbell": true to the config to enable it

beele commented 4 years ago

Doorbell support is now released in 0.4.1 Two way audio will remain on the backlog until progress is made and a POC becomes available elsewhere so I can implement it here.

mikestecker commented 4 years ago

@beele just FYI looks like the homebridge-camera-ffmpeg plugin has two-way audio (experimentally) working starting with their v2.6.0 release: https://github.com/Sunoo/homebridge-camera-ffmpeg/commit/2c00cab8b7b5d22b8527c7f81be3bdbb7ec15b80

Maybe have a look at what they are doing when you have time

crxporter commented 4 years ago

It's happening guys! Two way audio is on the horizon!

Advertised working here: https://github.com/hjdhjd/homebridge-unifi-protect2/blob/master/docs/Doorbell.md#doorbell-twoway

beele commented 4 years ago

I'll be looking into that when I get back from my holiday ;)

beele commented 4 years ago

@crxporter @mikestecker Can you try with the latest beta, I've added support for two way audio. sudo npm i -g --unsafe-perm=true homebridge-unifi-protect-camera-motion@0.4.3-beta.8

Note that it is untested since I do not own a camera that can do this.

beele commented 2 years ago

Tested this with an unifi g3 instant and this works