Door bell being trigger multiple times

Hi guys,

Wondering, my current doorbell work like a charm however I believe at the moment it will create an error when someone presses the bell more than once. I there a way to make it so that once press it will trigger the automation but not multiple actions within a certain time period before it can be triggered again?

automation:
  - alias: Notification Doorbell activated
    id: 1803ef21-f8c9-4aed-a7c2-d7d2694e33e7
    description: Notification doorbell being pushed
    trigger:
      - platform: state
        entity_id: switch.sonoff_1000ca0c17
        to: 'on'
    action:
      - service: camera.snapshot
        target:
          entity_id: camera.front_garage_cam
        data:
          filename: '/config/www/tmp/snapshot_garage.jpg'

Add a condition-

  - condition: template
    value_template: >-
      {{ (as_timestamp(now())-as_timestamp(state_attr('automation.notification_doorbell_activated', 'last_triggered') | default(0)) | int > 5) }}

Change 5 (in second) to the desired value.

Or even simpler:

automation:
  - alias: Notification Doorbell activated
    id: 1803ef21-f8c9-4aed-a7c2-d7d2694e33e7
    description: Notification doorbell being pushed
    trigger:
      - platform: state
        entity_id: switch.sonoff_1000ca0c17
        to: 'on'
    action:
      - service: camera.snapshot
        target:
          entity_id: camera.front_garage_cam
        data:
          filename: '/config/www/tmp/snapshot_garage.jpg'
      - delay:
          seconds: 6    # change this to the time you want between activations
mode: single            # only run one instance of this automation
max_exceeded: silent    # don't log errors if attempting to run more than one instance

Also I moved your post as this is about configuration of home assistant. The development topic is for questions about developing new integrations and such.

1 Like