Doorbird integration

Did you raised a issue somewhere (eg. github)?

I dived into the code and, it seems like it’s polling the doorbird on: /bha-api/monitor.cgi?check=doorbell. The url is responding with doorbell=0, when pressing the button the url is responding with doorbell=1. But, ONLY WHEN PRESSING the button, there seems no latching/relaxation…
This means that during the press (<1 sec.) Home Assistant needs to poll the doorbird. So you need to poll the doorbird al lot to see the event. In the code I see a update interval variable of 250ms., I’m not quite sure how this works. It sounds like you almost have to DoS your doorbird?

To test my finding I pressed the doorbird button for a longer time (30 sec.), than the event is eventually received by Home Assistant.

I personally don’t like the polling mechanism, a lot unnecessary network traffic. The documentation indicates that there is also a stream available under: /bha-api/monitor.cgi?ring=doorbell. Or, like the proxy is doing, use the notification (push) method.

You’re going to hammer the API if you attempt to do anything more than 1 req. / second. Even DoorBird recommend against this. It ends up forcing a restart (a lot), happened to me more than I wanted. The monitor?check endpoint probably wasn’t devised for this … ever polling it is bad news. The ?ring endpoint is also next to pointless, it doesn’t always give you want or expected on doorbell events, also too flaky. The only stable one to use is the notification API. Pushing to the client works extremely well, its also how they setup cloud to cloud with vendor products e.g. Zipatile. DoorBird mentioned they will probably remove the ?monitor endpoint sometime.

How would you implement it via the notification API?

These guys seem to use HTTP GET for notifications:

Maybe the author (@Klikini) can help us?

When I get time, I was going to set up HA to host endpoints for various state changes, then configure the DoorBird device to call them when the doorbell rings.

I just haven’t had a chance to get my dev environment reset (I’m on Windows, so it’s not easy) and figure out how to host API endpoints in a component.

1 Like

Any news here? I think the Axis component uses endpoints to get notified of events from the binary sensors. Maybe you can check there?

I just pushed new code that registers HA with the device, which then creates an event when the doorbell rings. I’m not sure how to make this useful in the frontend, but any changes needed there should be minimal.

At the moment the Axis component uses RTSP protocol to receive subscribed events. There is work by another community member to add a web endpoint to give support mainly to older devices that doesn’t support the RTSP events.

The last images are not visible anymore (probably due to an firmware upgrade in doorbird?) Did something change here?

Although the api manual states that the history.cgi event param is not mandatory, it however seems like it is!

Test without event param:

➜  ~ curl -u user0001:passwd -v http://192.168.1.9/bha-api/history.cgi\?index\=1
*   Trying 192.168.1.9...
* TCP_NODELAY set
* Connected to 192.168.1.9 (192.168.1.9) port 80 (#0)
* Server auth using Basic with user 'user0001'
> GET /bha-api/history.cgi?index=1 HTTP/1.1
> Host: 192.168.1.9
> Authorization: Basic #hash
> User-Agent: curl/7.50.3
> Accept: */*
>
< HTTP/1.1 204 No Content
< Content-Type: text/plain
< Date: Thu, 28 Dec 2017 19:27:31 GMT
< Server: lighttpd/1.4.45
<
* Curl_http_done: called premature == 0
* Connection #0 to host 192.168.1.9 left intact

Test with event param:

➜  ~ curl -u user0001:passwd -v http://192.168.1.9/bha-api/history.cgi\?index\=1\&event\=doorbell
*   Trying 192.168.1.9...
* TCP_NODELAY set
* Connected to 192.168.1.9 (192.168.1.9) port 80 (#0)
* Server auth using Basic with user 'user0001'
> GET /bha-api/history.cgi?index=1&event=doorbell HTTP/1.1
> Host: 192.168.1.9
> Authorization: Basic #hash
> User-Agent: curl/7.50.3
> Accept: */*
>
< HTTP/1.1 200 OK
< Content-Type: image/jpeg
< Content-Length: 30867
< X-Timestamp: 1514398891
< X-Count: 35
< Date: Thu, 28 Dec 2017 19:33:06 GMT
< Server: lighttpd/1.4.45
<
* Curl_http_done: called premature == 0
* Connection #0 to host 192.168.1.9 left intact

I think DoorBird broke this with a firmware upgrade…
I submitted a issue: https://github.com/Klikini/doorbirdpy/issues/3

With version 0.61 your code is now live. Any thoughts on how to use the doorbell_events? I don’t “get it” yet.

1 Like

What I understand from the code is that when doorbell_events are activated, Home Assistant is opening a API endpoint for the DoorBird and will configure the DoorBird API (on startup) with notifications to call the Home Assistant API.

I will leave some feedback when it’s working, but I still need to upgrade Home Assistant. :stuck_out_tongue:

2 Likes

You can use it in automations, like this one that will add entries to the logbook:

- alias: Doorbell
  trigger:
  - platform: event
    event_type: doorbird_doorbell
  action:
  - service: logbook.log
    data:
      name: Doorbell
      message: rang

More helpful examples of automations are welcome in the component documentation :slight_smile:

1 Like

Curious if you got this working yet and what you think

I’ve tried this automation and get this error:

2018-01-24 14:42:40 WARNING (MainThread) [homeassistant.components.http.ban] Login attempt or request with invalid authentication from “doorbird ip”

I’ve double checked the Doorbird logon details in config.yaml and it’s right, sounds like Doorbird is not auth to HA? Any ideas?

I realize now that I’m an idiot…

My test instance of HA doesn’t have an API/HTTP password, so it worked and I didn’t think to authenticate API calls. I will work on a fix ASAP.

1 Like

Not an idiot at all, easily over looked! Let me know when you a chance to correct it and I’ll test.
Many thanks!

1 Like

I have pushed a fix and created a pull request, so now it’s up to the HA devs to accept it.

1 Like

While I haven’t moved over to this API’s ring notification (still using the proxy version), I have tied this into TTS using Bluetooth speakers with my RPi. I have my Pi connect to my Echos, and they will let me know when someone is ringing the door. There are a few known issues connecting to some Echo devices using RPis, but my Echo dot seems to consistently work. Other ideas may be to flash some lights, send some push notifications, etc.

Here’s my automation converted to use the trigger (but untested). Probably doesn’t make sense to put it in the documentation as I’m using multiple unofficial components to do this.

- id: NotifyDoorbell
  alias: 'Notify of ringing doorbell'
  initial_state: 'on'
  trigger:
    platform: event
    event_type: doorbird_doorbell
  action:
    service: tts.google_say
    data:
      entity_id: media_player.tts_bluetooth_speaker
      message: 'Ding Dong! Someone is at the front door!'
2 Likes

doorbird_doorbell event now works as of 0.63 - thanks @Klikini!
here’s my working config for playing the doorbell on Sonos if anyone needs it:

an automation:

- alias: Doorbell
  trigger:
  - platform: event
    event_type: doorbird_doorbell
  action:
    - service: script.turn_on
      data:
        entity_id: script.doorbell

calls this script:

doorbell:
  alias: Ring Doorbell
  sequence:
    - service: media_player.sonos_snapshot
      data:
        entity_id: media_player.kitchen
    - service: media_player.volume_set
      data:
        entity_id: media_player.kitchen
        volume_level: 0.60
    - service: media_player.play_media
      data:
        entity_id: media_player.kitchen
        media_content_id: http://10.0.26.20/sounds/doorbell.mp3
        media_content_type: music
    - delay:
        seconds: 4
    - service: media_player.sonos_restore
      data:
        entity_id: media_player.kitchen
4 Likes