WIP - DoorDroid - Smart Doorbell with Lovelace integration, video and 2-way audio, without cloud

WIP warning!: this is a work in progress! I think I can bring this to a good end but I already faced quite some battles on both hard-and software side. Code and more will be posted once I get to a beta version…

Summary
In the quest to find a smart doorbell that integrates with HomeAssistant, I finally developed DoorDroid. What is it? It is an old Android smartphone I had lying around which I will use (off course without the screen) as my smart doorbell. It provides free 2-way audio calling and a video feed.
This project is inspired by DoorPi but will hopefully have better call quality.

Requirements

  • Old Android Phone supporting SIP running DoorDroid
  • Asterisk SIP server with correct configuration
  • One of:
    • an always on tablet showing HomeAssistant with the DoorDroid custom card
    • a smart phone supporting SIP calling

How does it work
I run my HomeAssistant setup within Docker via docker-compose and I now added Asterisk, a SIP server which supports two way audio calling.
In a 3D printed/laser cut box, the Android smartphone will be placed outside at the door. The smartphone has one app running on it all the time, DoorDroid. The app has the following features:

  • it runs an embedded HTTP server which can stream the phone’s camera
  • it can call a default SIP number or any SIP number registered in Asterisk server

Next to the smartphone is an ESP8266/32 with one or more physical hardware buttons attached to it.

If someone pushes the doorbell button, a script is launched in homeassistant:

  • using @thomasloven excellent browser-commander, my wall-attached Android Panel showing HomeAssistant all the time, switches to the Doorbell tab
  • a Sonos TTS message is played
  • the DoorDroid app receives an HTTP call to initiate a SIP call to my always-on tablet (if I’m away to my smartphone)
  • On my tablet, I can accept the call and start chatting. The DoorDroid custom card also shows the videofeed of whom is at my door. Off course, I can also reject the call

Screenshot love
P.s. no comments on the pics please :laughing:


Code and Installation
DoorDroid android App - available on GitHub: https://github.com/rdehuyss/DoorDroid
DoorDroid integration in HomeAssistant - see wiki: https://github.com/rdehuyss/DoorDroid/wiki

15 Likes

Tested on the following phones:

  • Moto G5
  • Google Pixel 2
2 Likes

Wow sounds amazing! I am definetly following this! Wondering if it’s possible to connect the phone to a dumb doorbell and have it inside my flat (I live in an apartment so I can’t install a phone outside of the front door) and get only a “normal” voice call when I’m not home to open the door for the post delivery or the cleaning lady.
Maybe your idea should get integrated in theAndroid (alpha) app of Home Assistant
Thumbs up for this project!

I created a first version and updated my initial post.

Code and Installation
DoorDroid android App - available on GitHub: https://github.com/rdehuyss/DoorDroid/releases
DoorDroid integration in HomeAssistant - see wiki: https://github.com/rdehuyss/DoorDroid/wiki

2 Likes

Great job! I’ll try to port this to my SIP door intercom.

Hi @jiiins, do note that I had problems in the end. The audio from the microphone wasn’t loud enough on my indoor station. I went for this solution in the end: https://community.home-assistant.io/t/diy-smart-doorbell-with-android-notifications

Thanks man! I have this expensive 2N SIP intercom attached to a Control4 system and I want to integrate it with HASS as it works just fine (mic levels and all). So if I can substitute DoorDroid with the 2N it might just work.

Hello,
I am more or less in @jiiins situation. I have a built-in SIP doorbell (GDS3710 grandstream). I am therefore interested on the client side. Can you detail what you have installed on the tablet to receive the call? I assume you are using what is there https://github.com/rdehuyss/DoorDroid but I don’t understand what to do.
It seems you are using the jssip library. So, in theory, it should be in the browser of the android phone? Am I correct?
Thanks for the hints and sharing your project.
GV

So, my indoor station (an in-wall Android Tablet) is running standard Lovelace in Chrome (= browser of the Android phone in your words). I created a custom lovelace component which was called by the DoorDroid application (in your case the GDS3710 grandstream). It indeed used jssip and asterisk.

Have you taken a look at the wiki? Everything is described there…

1 Like

I did!! But " * Download and install the Android app from the releases page of this repository" from the wiki is not clear to me.
What do you need to install on the android phone? I need (somehow?) to build an apk?
In my understanding with the sipjs library everything was in the browser from the client side. So, in theory, nothing to install on the phone/tablet… Or at least that was my understanding. Hence, my confusion :slight_smile:
Thanks
GV

The apk is on the releases page.

In your case you don’t need to install an apk since your doorbell already supports SIP.

You need to:

  • setup asterisk for SIP Call Management (as in WIKI)
  • configure your GDS3710 grandstream station to call the SIP account you will use at your indoor station
  • Add the lovelace card to your home assistant
  • That should be it, I think

Missed that… Sorry! Nevertheless, the question on sipjs remains. In theory, it should be possible to run everything in the browser, and not requiring an apk.
We had an exchange on this page https://community.home-assistant.io/t/sip-client/60964.
GV

Would be great!! I’ll try that. It is going to keep me busy this week-end :slight_smile:
In your setup, why do you need the apk? What is the purpose of the app?
GV

The APK is running on a phone which is mounted at my door, so the equivalent of your GDS3710 grandstream.

OK. Thanks. Will try that and if I have some issues I’ll ask :slight_smile:
GV

I don’t know if I should report here or on github…
Line 36 of doorpi-camera-view.js is :

imgEl.src = 'https://192.168.1.66:9090/stream/video.mjpeg';

It should be a reference to the settings in doordroid.yaml. The mjpeg settings:

mjpeg_url: https://192.168.1.66:9090/stream/video.mjpeg

No?
GV

Hello,
Some report on my progress so far. I have installed doordroid and jssip on my HA box. I have created the extension on my asterisk serevr to register by able to register the “card” of doordroid.
Up to that point all good.
When I open lovelace and go to the view with the webrtc phone I can see the phone registering on asterisk.
When I call the webrtc extension, the two additional buttons are displayed. However when I click on “accept call” buttons I have an error message in the developper console. See below.

Loading SIPPhone                                 doordroid-card.js?v=0.0.1:80 
initialized camera view                               doordroid-card.js?v=0.0.1:151: 
SIPPhone registered with SIP Server             doordroid-card.js?v=0.0.1:100: 

jssip-3.3.6.min.js:9 Uncaught INVALID_STATE_ERROR: Invalid status: 5
    at t.value (http://192.168.0.150:8123/local/plugins/jssip-3.3.6.min.js:9:117457)
    at HTMLElement.<anonymous> (http://192.168.0.150:8123/local/plugins/doordroid-card.js?v=0.0.1:131:71)
r @ jssip-3.3.6.min.js:9
t @ jssip-3.3.6.min.js:9
value @ jssip-3.3.6.min.js:9
(anonymous) @ doordroid-card.js?v=0.0.1:131
doordroid-card.js?v=0.0.1:121 

And I am stuck!! Any suggestion where to look at and what to try?

Thanks,
GV

1 Like

To be honest, I don’t use this setup anymore as mentioned above. So, it may be that the code contains bugs/errors.

I did Google your error and found this: https://github.com/versatica/JsSIP/issues/527

Are you answering the call twice?

Hello,
Thanks for your answer.
In fact, my “SSL” setup (for hassio, asterisk,…) was not correct and webrtc seems to be very picky when it comes to connection over unsecured channel. So, once HTTPS, WSS was ok, it when well.
In your doordroid-card.js I have added:

        JsSIP.debug.enable('JsSIP:*');

which helped greatly!

I believe that my configuration is OK (SIP extensions, asterisk,…) the only missing bit is incoming audio from the SIP contact. And I believe, I understand why, even if I can’t see what to do…

In my setup the SIP extensions calls the webrtc endpoint. I can accept the call and it can be seen in the debug console:

JsSIP:RTCSession receiveRequest() +14ms
jssip-3.3.6.min.js:9 JsSIP:RTCSession session confirmed +1ms
jssip-3.3.6.min.js:9 JsSIP:RTCSession emit "confirmed" +0ms
doordroid-card.js?v=0.0.4:124 call confirmed
jssip-3.3.6.min.js:9 JsSIP:WebSocketInterface received WebSocket message +13s

However, looking at the code, the next event should be:

             session.on("addstream", (e) => {

the event addstream AFAIK doesn’t exist any more in the JSSIP 3. It was part of the API in 2.X.

With my (extremely) limited understanding of JS and JSSIP, I can’t figure out what should be the final (?) step to “link” the RTP audio (seen in the wireshark capture) with the audio of my PC.

Any suggestion?

Thanks,

GV

1 Like