Smart Office Example: Doorbird integration with Home Assistant

We’re in the progress of setting up our smart office and we just got the integration for our doorbird video doorbells set up.

After some internal deliberations we came up with the following requirements:

  • Upon ringing, push the live camera picture to the frontend and allow users to open the door or ignore the ring
  • Support multiple door cameras (we have multiple entrence doors to the building)
  • Do not store any images in the cloud or have dependencies on the cloud
  • Remove the live camera image upon action or after 3 minutes with no action

We decided to use Home Assistant to sit at the center of the Gordian Knot that will be our IOT installation.

Of course, I wanted to share the early progress with the community:

The configuration is as follows:

# Setup of the Doorbird integration
doorbird:
  token: !secret doorbird_west_entrance_token
  devices:
    - host: !secret doorbird_west_entrance_ip
      username: !secret doorbird_west_entrance_user
      password: !secret doorbird_west_entrance_password
      hass_url_override: !secret doorbird_west_entrance_url_override
      name: Doorbell West Entrance
      monitored_conditions:
        - doorbell
        - motion
        - relay      
        
camera:
  - platform: doorbird
  
switch:
  - platform: doorbird

# Input_boolean is used for conditional card in lovelace frontend to only show camera entity
# and door opening buttons after a visitor presses the ring button
input_boolean:
  visitor_ring:
    name: Visitor at West entrance!
    initial: off

automation:
# Event Catcher Automation to trigger showing Door UI in frontend via conditional card
- alias: Doorbird Ring
  initial_state: 'true'
  trigger:
    platform: event
    event_type: doorbird_doorbell_west_entrance_button
  action:
  - service: homeassistant.turn_on
    data:
      entity_id: input_boolean.visitor_ring
  - service: persistent_notification.create
    data:
      message: "Visitor at the West Entrance"
      title: Doorbell Ringing
# Cancel Automation to reset input_boolean when no action was taken for 3 minutes
- alias: Cancel Ring after 30 seconds
  initial_state: 'true'
  trigger:
    platform: state
    entity_id: input_boolean.visitor_ring
    from: "off"
    to: "on"
    for: '00:03:00'
  action:
    - service: homeassistant.turn_off
      data_template:
        entity_id: input_boolean.visitor_ring

script:
  # Script for opening the door and resetting input_boolean when door was opened via frontend
  open_west_door:
    sequence:
    - service: homeassistant.toggle
      data_template:
        entity_id: switch.doorbell_west_entrance_relay_1
    - service: homeassistant.turn_off
      data_template:
        entity_id: input_boolean.visitor_ring

# Lovelace frontend setup:
# card:
#   cards:
#     - entity: camera.doorbell_west_entrance_live
#       type: picture-entity
#     - cards:
#         - entity: switch.doorbell_west_entrance_relay_1
#           hold_action:
#             action: none
#           icon: 'mdi:door-open'
#           name: Open Door
#           tap_action:
#             action: call-service
#             service: script.turn_on
#             service_data:
#               entity_id: script.open_west_door
#           theme: Backend-selected
#           type: entity-button
#         - entity: input_boolean.visitor_ring
#           hold_action:
#             action: none
#           icon: 'mdi:cancel'
#           name: Ignore
#           tap_action:
#             action: toggle
#           theme: Backend-selected
#           type: entity-button
#       type: horizontal-stack
#   type: vertical-stack
# conditions:
#   - entity: input_boolean.visitor_ring
#     state: 'on'
# type: conditional

The video doesn’t show me hitting the door button and I waited for the camera to pan back to the screen before hitting it. The latency is as close to instantaneous as to be indistinguishable for a human.

Components used:

  • Home Assistant 0.90.2 running on HassOS on an Intel NUC i3 box
  • Doorbird D2101V
  • Raspberry Pi 3b+ and Iiyama T2454MSC Touchscreen running Raspbian with Chromium in Kiosk mode

We’ll have further updates as there’s quite a bit more we need to set up.

15 Likes

This is really awesome and exactly what I’m looking for. Curious to see the further progress :slight_smile:

So back for a quick update: We’re close to done with this project now. So there will be a couple of posts coming soon with added setup.

As this post is only about the Doorbird setup, we have now fully installed two Doorbirds for the two main building entrances as well as set up multiple Doorbird Chimes throughout the building. Any visitors ringing also trigger a call via SIP to a group of people responsible for accepting packages or guiding visitors. Not surprisingly the most difficult task was pulling cable to where we needed it.

Could you finish your setup successfully?
I am very interested in the config…

Here’s the config:

# Setup of the Doorbird integration
doorbird:
  devices:
    - host: !secret doorbird_west_entrance_ip
      username: !secret doorbird_west_entrance_user
      password: !secret doorbird_west_entrance_password
      hass_url_override: !secret doorbird_west_entrance_url_override
      token: !secret doorbird_west_entrance_token
      name: Doorbell West Entrance
      events:
        - button
        #- unit_1_button
        #- movement
        #- relay_1
        #- lock_relay
        - rfid_card_scanned
    - host: !secret doorbird_south_entrance_ip
      username: !secret doorbird_south_entrance_user
      password: !secret doorbird_south_entrance_password
      hass_url_override: !secret doorbird_south_entrance_url_override
      token: !secret doorbird_south_entrance_token
      name: Doorbell South Entrance
      events:
        - button
        #- unit_1_button
        #- movement
        #- relay_1
        #- lock_relay        
        - rfid_card_scanned

camera:
  - platform: doorbird
  
switch:
  - platform: doorbird

# Input_boolean is used for conditional card in lovelace frontend to only show camera entity
# and door opening buttons after a visitor presses the ring button
input_boolean:
  visitor_ring_west:
    name: Visitor at West entrance!
    initial: off
  visitor_ring_south:
    name: Visitor at South entrance!
    initial: off

# Event Catcher Automation to trigger showing Door UI in frontend via conditional card
automation:
# West Door
- alias: Doorbird West Ring
  initial_state: 'true'
  trigger:
    platform: event
    event_type: doorbird_doorbell_west_entrance_button
  action:
  - service: homeassistant.turn_on
    data:
      entity_id: input_boolean.visitor_ring_west
  - service: camera.snapshot
    data_template:
      entity_id: camera.doorbell_west_entrance_live
      filename: /config/www/community/camera.doorbell_west.jpg
  #- service: persistent_notification.create
  #  data:
  #    message: Visitor at the West Entrance ![image](/local/snapshots/camera.doorbell_west.jpg?{{now().microsecond}}{{now().second}})
  #    title: Ding! Dong!
  #    notification_id: doorbell-west
  - service: notify.html_push
    data:
      title: "Ding! Dong!"
      message: '{{ now().strftime("%Y-%m-%d %H:%M") }}: Visitor at the West Entrance'
      data:
        ttl: 180
        tag: doorbell-west
        image: 'https://my-ha.duckdns.org:8123/community_plugin/camera.doorbell_west.jpg?{{now().microsecond}}{{now().second}}'
        actions:
          - action: open_west
            title: Open Door
          - action: ignore
            title: Ignore
  - service: notify.ios
    data:
      title: "Ding! Dong!"
      message: "{{ now().strftime('%Y-%m-%d %H:%M') }}: Visitor at the West Entrance"
      data:
        attachment:
          content-type: jpeg
          url: https://my-ha.duckdns.org:8123/community_plugin/camera.doorbell_west.jpg
          #hide-thumbnail: false
        push:
          category: open_west
          thread-id: "doorbell"
        apns_headers:
          apns-collapse-id: 'doorbell'

# South door
- alias: Doorbird South Ring
  initial_state: 'true'
  trigger:
    platform: event
    event_type: doorbird_doorbell_south_entrance_button
  action:
  - service: homeassistant.turn_on
    data:
      entity_id: input_boolean.visitor_ring_south
  - service: camera.snapshot
    data_template:
      entity_id: camera.doorbell_south_entrance_live
	  # I'm using the HACS community folder as this has the no cacheing directive which solves issues around 
	  # HTML5 notifications loading snapshots from browser cache. This has been more reliable than adding a 
	  # random ?number string to the end.
      filename: /config/www/community/camera.doorbell_south.jpg
  - service: persistent_notification.create
    data:
      message: Visitor at the South Entrance \n ![image](/community_plugin/camera.doorbell_south.jpg?{{now().second}})
      title: Ding! Dong!
      notification_id: doorbell-south
  - service: notify.html_push
    data:
      title: "Ding! Dong!"
      message: '{{ now().strftime("%Y-%m-%d %H:%M") }}: Visitor at the South Entrance'
      data:
        ttl: 180
        tag: doorbell-south
        image: 'https://my-ha.duckdns.org:8123/community_plugin/camera.doorbell_south.jpg?{{now().second}}'
        actions:
          - action: open_south
            title: Open Door
          - action: ignore
            title: Ignore
  - service: notify.ios
    data:
      message: "{{ now().strftime('%Y-%m-%d %H:%M') }}: Visitor at the South Entrance"
      title: "Ding! Dong!"
      data:
        attachment:
          content-type: jpeg
          url: https://my-ha.duckdns.org:8123/community_plugin/camera.doorbell_south.jpg
          #hide-thumbnail: false
        push:
          category: open_south
          thread-id: "doorbell"
        apns_headers:
          'apns-collapse-id': 'doorbell'      


# Cancel Automation to reset input_boolean when no action was taken for 3 minutes
# West door
- alias: Cancel West Ring after 30 seconds
  initial_state: 'true'
  trigger:
    platform: state
    entity_id: input_boolean.visitor_ring_west
    from: "off"
    to: "on"
    for: '00:03:00'
  action:
    - service: homeassistant.turn_off
      data_template:
        entity_id: input_boolean.visitor_ring_west
    - service: persistent_notification.dismiss
      data:
        notification_id: "doorbell-west"
    - service: notify.html5_dismiss
      data_template:
        data:
          tag: doorbell-west

# South door
- alias: Cancel South Ring after 30 seconds
  initial_state: 'true'
  trigger:
    platform: state
    entity_id: input_boolean.visitor_ring_south
    from: "off"
    to: "on"
    for: '00:03:00'
  action:
    - service: homeassistant.turn_off
      data_template:
        entity_id: input_boolean.visitor_ring_south
    - service: persistent_notification.dismiss
      data:
        notification_id: "doorbell-south"
    - service: notify.html5_dismiss
      data_template:
        data:
          tag: doorbell-south
        
# Automation to disarm Office Alarm when authorized user enters office.
- alias: Disable Office Alarm via authorized Event
  initial_state: 'true'
  trigger:
    - platform: event
      event_type: doorbird_doorbell_west_entrance_rfid_card_scanned
    - platform: event
      event_type: doorbird_doorbell_south_entrance_rfid_card_scanned
  condition:
    - condition: state
      entity_id: alarm_control_panel.office_alarm
      state: 'armed_away'
  action:
  - data:
      code: !secret office_alarm_code
      entity_id: alarm_control_panel.office_alarm
    service: alarm_control_panel.alarm_disarm

# Script for opening the door and resetting input_boolean when door was opened via frontend
script:
  # West door
  open_west_door:
    sequence:
    - service: homeassistant.toggle
      data_template:
        entity_id: switch.doorbell_west_entrance_relay_1
    - service: homeassistant.turn_off
      data_template:
        entity_id: input_boolean.visitor_ring_west
    - service: notify.html5_dismiss
      data_template:
        data:
          tag: doorbell-west
    - service: persistent_notification.dismiss
      data:
        notification_id: "doorbell-west"
  
  # South door
  open_south_door:
    sequence:
    - service: homeassistant.toggle
      data_template:
        entity_id: switch.doorbell_south_entrance_relay_1
    - service: homeassistant.turn_off
      data_template:
        entity_id: input_boolean.visitor_ring_south
    - service: notify.html5_dismiss
      data_template:
        data:
          tag: doorbell-south
    - service: persistent_notification.dismiss
      data:
        notification_id: "doorbell-south"
2 Likes

@olbjan - great scripts.

I see you also mention that a doorbird bell push triggers a SIP group call.
Could I ask which platform you use - Asterisk, 3CX etc?
I am doing similar to you and also triggering a sip call on doorbell push to 3CX hosted on AWS.

I can get the doorbird to register ok and have been through the various setups in the Doorbird app.
A ddorbell push triggers a sip call which I can receive and answer, however I can’t seem to get audio working.

Would be great if you can share which SIP platform you are using?

I’ve used an Asterisk based on prem PBX. Just added the doorbirds as regular sip endpoints and have them call a hunt group that forwards the call to the people who do the door stuff. We didn’t have any issues there.

2 Likes

This is really great info, thanks for sharing, I’m always interested in doorbell projects because the devil is in the details and you don’t find out the limitations until long after you invested.

I have one question for you. When you are using the SIP integration, can you still use the Doorbird mobile app to view the feed and answer the door, or would you have to use Hass or another SIP endpoint on mobile to do that?

Also do you have a way to get the 2 way audio to where your hass UI shown in the video is?

Hass doesn’t do audio and we rarely use the audio to be honest.

The doorbirds are also very underpowered, you cannot have more than a single stream off them so we use HA to restream to multiple endpoints. We do not allow anyone to use the doorbird app so that’s easy.

We’ve found that for the vast majority of uses the actionable notifications that get sent to html5 push and mobile apps are sufficient and they also work quicker than the doorbird chime, meaning from the moment someone presses the button HA gets the REST call, the automation takes a snapshot off the video stream and sends notifications out which travel via firebase messaging, apple push notifications and down to clients is quicker than whatever doorbird does to also let the chimes ring - which are in the same subnet as themselves… go figure.

Bummer, this is always where I get tripped up in thinking about doorbells… I want the video displayed in hass as I want hass tablets displaying the video at each floor of my house by the audio stations, but I also want the audio to go to mobile. I don’t really want to buy some proprietary video station for each floor in the house when a hass dashboard is so much more useful. Audio is really a requirement for us.

Why not use the sip feature then? The doorbirds can call any phone number you like so that takes care of the audio. It works very well. Our use case just doesn’t have it be used very often as usually someone has hit the “open door” button on the notifications after glancing at the picture quicker than the doorbird can establish the voip call…

Yes that’s what I’m thinking, but I’m not sure how that interfaces with mobile phones… I don’t want to buy an expensive doorbird system and then realize that I need to use a SIP client that doesn’t allow me to open the door, for instance.

You need a sip number / provider for the doorbirds - I don’t know about you but I get that for free with my internet connection. A small asterisk setup also helps.

From the point of view of the mobile phone what comes in is a very regular phone call that you answer like any other. You can then enter a pin code on your phone to open the door.

You mean it’s a voice call that goes through a SIP to PSTN gateway? What about if I want video too?

Then you’ll need to use the doorbird app.

Hence my original question whether I can use that and SIP at the same time.

Well you can only ever talk from one endpoint but you can ring SIP, app, chimes and whatever takes your fancy. Only one video stream from doorbird to either app or HA though. And I believe except for some Snom VoIP deskphones no video streams to SIP endpoints.

1 Like

Okay, now we are getting somewhere. I wouldn’t want to talk on multiple devices simultaneously. A few questions though:

  1. If someone rang the doorbell, it would simultaneously ring all SIP devices as well as all apps, is that correct? And then whoever picked up would get the audio?

  2. What about the video? Can it be shown on homeassistant before someone picks up?
    And then if someone picks up by app can it go to the app?

  3. What about if someone picks up on audio only SIP endpoint, is the video still shown on hass?

  1. yes
  2. yes
  3. yes
1 Like

Wow, I’m surprised it’s so flexible. Now I just have to decide whether I’m willing to spend that much on a doorbell, thanks for answering all my questions.