Template Binare Sensor Motion Doorbird

Hallo,

I am trying to build a Template Sensor for my DoorBird Doorbell. But I am not sure how to use the Template with a event. In the DoorBird docs is just an exempel for Automations. https://www.home-assistant.io/components/doorbird/

Exempel from the docs:

- alias: Doorbird Ring
  trigger:
    platform: event
    event_type: doorbird_side_entry_button
  action:
    service: light.turn_on
      entity_id: light.side_entry_porch

I tried this config but it doesn’t work.

- platform: template
  sensors:
    haustuer_bewegung:
      friendly_name: "Haustür Bewegung"
      device_class: motion
      value_template: >- {{ event.doorbird_haustur_motion }

Thanks!

An event is a transient thing. It happens, but there’s no persistence to it. (I.e., it doesn’t, itself, record anything in the state machine.) You can use it to trigger an automation, that’s about it. If you want to have something that shows that the event happened, then you could use an automation (triggered by the event) to create some sort of notification, or possibly change an input_boolean. It depends on what you want to do or see when the event happens. If you could elaborate on what you’d like to see or happen when the event occurs, I’d be happy to help further.

One possible use case is to use the event to turn an input_boolean on, which you can see in the frontend. Then you can click on it to turn it off. E.g.:

input_boolean:
  doorbird_doorbell_pushed:
    initial: false

automation:
  - alias: DoorBird Doorbell
    trigger:
      platform: event
      event_type: doorbird_haustur_motion
    action:
      service: input_boolean.turn_on
      entity_id: input_boolean.doorbird_doorbell_pushed

I don’t know what the actual name of the event is, but based on what you wrote, I assumed it is doorbird_doorbell_pushed.

For those interested, I made it with a template BINARY sensor, and an input boolean. An automation catches the event from Doorbird and sets the input boolean to on (initial is off), then a delay of 5 seconds, then sets it back to off. The template binary sensor (type: motion) is linked to the input boolean value.
And it works. Would be great to have it by default in the Doorbird integration, IMHO.

Hi @Friedrieck !
Can you show me how you set this in your yaml file?
thanks in advance

Hi @itssam,
I will assume you have set up, in your config and in the Doorbird app, the event for motion as described in the documentation, obvious prerequisite.
First, the code for an input boolean (could be a variable if you have this HACS integration).

input_boolean:
  doorbird_motion:
    name: Doorbird mouvement
    initial: off
    icon: mdi:motion-sensor #for fun, because this control is not necessary in the UI

Then, the template binary sensor (to use in your UI and automations):

- platform: template
  sensors:
    doorbird_motion_sensor:
      friendly_name: "Mouvement devant"
      device_class: motion
      value_template: "{{ is_state('input_boolean.doorbird_motion', 'on') }}"

Finally, the automation:

- id: 'whateveruniqueID'
  alias: Mouvement devant
  trigger:
  - event_data: {}
    event_type: doorbird_entree_principale_motion #to adapt to your event name (based on Doorbird integration name in your config)
    platform: event
  condition: []
  action:
  - data:
      entity_id: input_boolean.doorbird_motion
    service: input_boolean.turn_on
  - delay: 00:00:05
  - data:
      entity_id: input_boolean.doorbird_motion
    service: input_boolean.turn_off

Voilà !

1 Like

For those who, like me, come across this thread to implement the motion sensor and bell events in HA, here are two tips that took me a few hours of trial and error:

The documentation explains how the http-call arrives in HA. I have overlooked several times that doorbird_ must be placed before the device name. Example:

Device name in the HA integration: Doorbird Eingang

Event name in the configuration options of the device in HA: Bewegung

Event type in Automation: doorbird_doorbird_eingang_Bewegung

For the template sensor you would have to specify binary_sensor instead of sensor, otherwise you cannot set the device_class motion:

doorbird_sensors:
  binary_sensor:
    - platform: template
      sensors:
        eingang_haustur_bewegung:
          unique_id: eingang_haustur_bewegung
          friendly_name: "Eingang Haustür Bewegung"
          device_class: motion
          value_template: "{{ is_state('input_boolean.eingang_haustur_bewegung_schalter', 'on') }}"

        eingang_haustur_klingel:
          unique_id: eingang_haustur_klingel
          friendly_name: "Eingang Haustür Klingel"
          value_template: "{{ is_state('input_boolean.eingang_haustur_klingel_schalter', 'on') }}"

Have fun.

1 Like