Retriggering of Automation

Dear All, Let me explain my automation
I have a sonoff sv connected in parallel to my mechanical door bell switch. Sonoff sv runs on tasmota and integrated to HA. When anyone presses the bell switch, automation is triggered; i.e the HA Notify component takes a snapshot from my CCTV and sends an actionable notification to my phone, with the image of the person at the gate, and a button that allows me to open my gate.
Since it’s a bell switch, people tend to press multiple times, and this is triggering the automation multiple times and sending to my phone. My question is, how do i tell HA to run the automation only once and pause for 30sec and then allow again. My automation code is as below:

- id: '157300'
  alias: Gate CCTV
  description: ''
  trigger:
  - entity_id: switch.door_bell
    from: 'off'
    platform: state
    to: 'on'
  condition: []
  action:
  - data:
      data:
        actions:
        - action: open_gate
          title: Open Gate
        image: https://mycctv.image.url
      message: Someone is at the door
    service: notify.android

Take a look here.

Thanks, I added this to my existing code. It didn’t work. Is there any value in the code that I need to change to suit my entity values?

- id: '1573031030992'
  alias: Gate CCTV
  description: ''
  trigger:
  - entity_id: switch.door_bell
    from: 'off'
    platform: state
    to: 'on'
  condition:
    condition: template
    value_template: "{{ (as_timestamp(now()) - as_timestamp(state_attr('automation.doorbell_alert', 'last_triggered') | default(0)) | int > 7)}}"
  action:
  - data:
      data:
        actions:
        - action: open_gate
          title: Open Small Gate
        image: https://cctv.camera.com
      message: Someone is at the door
    service: notify.android

It didn’t work because you used the template verbatim. It contains a reference to automation.doorbell_alert. Your automation is called automation.gate_cctv. Use that in the template.

  condition:
    condition: template
    value_template: "{{ now().timestamp() - as_timestamp(state_attr('automation.gate_cctv', 'last_triggered') | default(0)) | int > 7)}}"
1 Like