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

You are correct.

I updated my github with my latest version of the DoorDroid Card.

And indeed, without https, webrtc refuses to work except for localhost.

Thanks !!
Will try that when I am back home.
If I can achieve what I want I will “Share my project” with a lot of credit to you :slight_smile:
Next (last ?) episode tonight :wink:
GV

Hourrah !! It works. Thank you for your help.
I have (kind of) took some bits of the new version provided yesterday with the previous one. I don’t need the part with the “everywhere” or not :slight_smile:
After this first success, I have continued my investigations. When the call is accepted I would like to turn on an input_boolean in hass to do further action.
I thought it would be straightforward. It is not. At least for me.
Here is what I have done:

                session.on("peerconnection", () => {
                    session.connection.addEventListener("addstream", (e) => {
                        console.log('adding audiostream')
                        // set remote audio stream (to listen to remote audio)
                        // remoteAudio is <audio> element on page
                        const remoteAudio = document.createElement('audio');
                        //const remoteAudio = droidCard.getElementById('audio-player');
                        remoteAudio.srcObject = e.stream;
                        remoteAudio.play();
                        hass.callservice('input_boolean', 'turn_on', { entity_id: 'input_boolean.portail' });
                    })

The callservice at the end of the function…

I can’t see the change in lovelace. The input_boolean.portail stays off :frowning:
Is there something else to do?

How do I debug this? I don’t even know in the developer console if the callservice is called or not.

GV

Have you tried debugging it? Just place a breakpoint and see if it is hit. I’m also not sure whether hass is known as you are in a callback.

Debugging it will tell you…

I was able to “fix” my code. In another post https://community.home-assistant.io/t/sip-client/60964 I am giving a status.
Thanks for your help and providing 99% of the work for making this possible :slight_smile:
GV

1 Like

Hello,
I still have some issues with my setup and I was wondering if you could help!
My (tweaked) version of doodroid.js is running in a view that is not always displayed. Sometimes the tablet falls asleep. As a consequence the webrtc connexion is dropped.

However, by looking at the code I can see:

set hass(hass) {
        if(this.notYetInitialized()) {
            this.initJsSIPIfNecessary(hass);
            this.initCameraView(hass);
        } else if(this.cameraEntityHasNewAccessToken(hass)) {
            this.updateCameraView(hass);
        }
        this.initDoorbellRinging(hass)
    }

and below:

    notYetInitialized() {
        return window.JsSIP && !this.sipPhone && this.config;
    }

My understanding of javascript gives me the feeling that when the tablet is back on and the doordroid view is displayed, the webrtc connexion is not restarted as it has been Initialized once.

To be on the safe side, wouldn’t it be better to “initialize” again the webrtc phone when the doordroid view is displayed? What would be the best way to do that?

As explained above, JS and I are not the best friends. So, I may miss something here!!

Thanks.

GV

My tablet was always on so I did not have the problem.

I checked the docs of JsSip and found this: https://jssip.net/documentation/3.3.x/api/ua/

You could check if this.sipPhone.isConnected(). So, it would be something like:

   notYetInitialized() {
        return window.JsSIP  && this.config && !this.sipPhone && !this.sipPhone.isConnected();
    }

Do note that I did not test this so you will need to investigate a bit (and my head can’t process that much booleans right now) :smile: .

Thanks. I have tried that

    notYetInitialized() {
        return window.JsSIP && !this.sipPhone && this.config && !this.sipPhone.isConnected();
    }

but:

Uncaught TypeError: Cannot read property 'isConnected' of undefined
    at HTMLElement.notYetInitialized (doordroid-card.js?v=0.1.14.10:81)
    at HTMLElement.set hass [as hass] (doordroid-card.js?v=0.1.14.10:11)
    at HTMLElement.value (hui-root.ts:599)
    at a (hui-root.ts:437)

In the javascript debug console…

So the idea is (probably) good but the code need something different :slight_smile:
If you have an idea. Otherwise, I will start working on this hint.

GV

It was not too hard (even for me!)

    notYetInitialized() {
      if ( this.sipPhone )
        return window.JsSIP && this.config && !this.sipPhone.isConnected();
      else {
        return window.JsSIP && this.config;
      }
    }

Not sure it is the cleanest of the code. But, at least, no insult in the debug console!

GV

1 Like

Would it be possible to adapt this project to allow calling between Lovelace UIs. I would love to be able to be able to answer the front door cam in addition to calling in-between the home assistant tablets mounted in different rooms. Preferably with video but just audio would be ok as well.

1 Like

I can’t see why it wouldn’t be doable. Not easy though… Create one extension per tablet. Make sure that each tablet only starts its own webrtc (eg. using custom header to mask views based on the client) and tweak the code :slight_smile:
GV

The 2N doorphone should be easy to integrate to HA. They have an open API to use.
And if you have the enchanced integration licens you also have the Automation part in 2N which rocks!
I work as a tech support at a copmany that are a reseller for 2N, and i LOVE that product! the most flexible door phone on the market!

Would your project also work with the following system?

https://voip.world/Akuvox-E21V-IP-Video-Intercom-flush-mount

If “you” is me (!), then, very likely. It is another sip doorbell. So, you could replace the grandstream gds3710 with this one.
The GDS has also a keyboard and an rfid reader for almost the same price…
GV

1 Like

Christian and jiiins, i have a 2n ip verso with the enhanced license… but i just cant get it integrated in my home automation… I especially want that if somebody rings and im away, that the video pops up on the iphone and communication is possible… can you help me out? thx

I also have 2N IP, but without license. What then integration can be done with HA?

Evening All,

I hope you can help, I’m struggling to install this in home assistant, I keep getting the following error when trying to create the cards in lovelace

Custom element doesn't exist: doordroid-card.

this is the location of the folder

\\homeassistant.local\config\www\doordroid

folder contains two files as expected
“doordroid-card.js” and “jssip-3.3.6.min.js”

my raw configuration has the following

            resources:
              - type: js
                url: /doordroid/jssip-3.3.6.min.js
              - type: module
                url: /doordroid/doordroid-card.js?v=0.0.1

i have also tried

            resources:
              - type: js
                url: /local/doordroid/jssip-3.3.6.min.js
              - type: module
                url: /local/doordroid/doordroid-card.js?v=0.0.1

I cant see where the issue is, any advise would be much appreciated, have i missed an important step :frowning:

many thanks

That error can occur for a number of reasons, even if the resource can be found. One possible source is mis-configuration of the card that uses the resource, so take a look at your ui-lovelace.yaml and see if there are possible problems with it.

I’m not using ui-lovelace.yaml I’m using the gui to configure the card

Custom element doesn't exist: doordroid-card.

type: 'custom:doordroid-card' 
title: DoorDroid 
camera_entity: camera.doorbell_camera 
  sip_settings: 
    sip_password: secret
    sip_server: pbx.domain.co.uk 
    sip_username: '1003' 
    sip_wss_url: 'wss://pbx.domain.co.uk:8089/ws' 
    title: null

This is my card and I think it looks right

Cheers again

I copied the example from the Wiki here. Check your YAML alignment. For example sip_settings should be aligned with camera_entity. title: null should be aligned with sip_settings. Etc.

  - cards:
      - camera_entity: camera.doorbell_camera
        sip_settings:
          sip_password: test123
          sip_server: 192.168.1.61
          sip_username: '22'
          sip_wss_url: 'wss://192.168.1.61:8089/ws'
        title: null
        type: 'custom:doordroid-card'
    title: DoorDroid