Automation notification limit

I’m having some troubles when I try to limit how often I can get a notification.

I’m trying to get notified if there’s trouble with processor, memory, disk or temperature. Here’s my automation:

alias: PI har det ikke godt
description: ''
trigger:
  - platform: numeric_state
    entity_id: sensor.processor_use_percent
    above: '80'
    for: '01:00'
  - platform: numeric_state
    entity_id: sensor.memory_use_percent
    above: '80'
    for: '01:00'
  - platform: numeric_state
    entity_id: sensor.disk_use_percent
    above: '80'
    for: '01:00'
  - platform: numeric_state
    entity_id: sensor.processor_temperature
    above: '80'
    for: '01:00'
condition:
  - condition: template
    value_template: >-
      {{ (as_timestamp(now()) -
      as_timestamp(states.automation.pi_har_det_ikke_godt.attributes.last_triggered
      | default(0)) | int > 300)}}
action:
  - service: notify.mobile_app_redmi_note_9s
    data:
      title: Raspberry PI does not feel well!
      message: |-
        {% if trigger.entity_id == states('sensor.processor_use_percent') %}
          CPU Usage is {{ trigger.to_state.state }} percent
        {% elif trigger.entity_id == states('sensor.memory_use_percent') %}
          Memory usage is {{ trigger.to_state.state }} percent
        {% elif trigger.entity_id == states('sensor.disk_use_percent') %}
          Disk usage is {{ trigger.to_state.state }} percent
        {% elif trigger.entity_id == states('sensor.processor_temperature') %}
          Processor temperature is {{ trigger.to_state.state }} degrees
        {% else %}
          Dont know which entity trigged this alarm.
        {% endif %}
mode: single

If I try to execute the automation it keeps doing the action part and sending me notifications - I want it to be limited to 1 notification per 5 minutes as a start. Can anyone help me?

As you are using “single” mode, adding a delay of 5 minutes will prevent the automation firing again in 5 minutes.

alias: PI har det ikke godt
description: ''
trigger:
  - platform: numeric_state
    entity_id: sensor.processor_use_percent
    above: '80'
    for: '01:00'
  - platform: numeric_state
    entity_id: sensor.memory_use_percent
    above: '80'
    for: '01:00'
  - platform: numeric_state
    entity_id: sensor.disk_use_percent
    above: '80'
    for: '01:00'
  - platform: numeric_state
    entity_id: sensor.processor_temperature
    above: '80'
    for: '01:00'
action:
  - service: notify.mobile_app_redmi_note_9s
    data:
      title: Raspberry PI does not feel well!
      message: |-
        {% if trigger.entity_id == states('sensor.processor_use_percent') %}
          CPU Usage is {{ trigger.to_state.state }} percent
        {% elif trigger.entity_id == states('sensor.memory_use_percent') %}
          Memory usage is {{ trigger.to_state.state }} percent
        {% elif trigger.entity_id == states('sensor.disk_use_percent') %}
          Disk usage is {{ trigger.to_state.state }} percent
        {% elif trigger.entity_id == states('sensor.processor_temperature') %}
          Processor temperature is {{ trigger.to_state.state }} degrees
        {% else %}
          Dont know which entity trigged this alarm.
        {% endif %}
  - delay:
      minutes: 5
mode: single

@tom_l - thanks man , seems to be working just fine :slight_smile: