Reduce rate of notification

Hi,

I currently have this automoation setup to notify me via pushover when my WeMo motion detects movement when nobody is home.

automation 3:
  alias: Monitor Home
  trigger:
- platform: state
  entity_id: binary_sensor.hallway_motion
  to: 'on'
  condition:
condition: state
entity_id: group.all_devices
state: not_home
  action:
- service: notify.notifyap
  data:
    message: Motion Detected at Home

This works exactly as I expect it to do so. However, is there a way to only notify me at a maximum rate… I.e. a maximum of once per min. At the moment, if it detects movement I would get a rush of a bout 5 or 6 notifications within a few seconds.

The issue I’m currently facing, is the location is not updating quick enough to know that i’m at home. I’m in the process of resolving this with an iBeacon, but would be good to know if the above can be done.

Thanks

My not be the smoothest way to do it but a template condition to only trigger if the automation was not run in the past X seconds may work. Can’t find the thread where someone helped me with this code but it should be a cookbook to get you going.

- condition: template
  value_template: '{% if states.automation.turn_off_away_when_home.attributes.last_triggered  %} {{(as_timestamp(now())-as_timestamp(states.automation.turn_off_away_when_home.attributes.last_triggered)) > 600 }}  {% else %}  true {% endif %}'

Test replace the automation name with your automation ie monitor home and test it in the dev tool. From there you can trigger the automation and see how it changes. It should let the automation trigger on true and not trigger on false.

1 Like

I do this with a rain notification I’m using. Like @silvrr says, mine also may not be the smoothest way but it works. I just toggle the automation, add a delay and then toggle it back on again.

# Rain Alert

- alias: 'Raining'
  trigger:
    platform: state
    entity_id: sensor.dark_sky_precip_intensity
    from: '0'
  action:
    - service: tts.google_say
      entity_id: media_player.living_room_home
      data_template:
        message: 'Excuse me Robert, but is currently {{ states.sensor.dark_sky_precip.state }}ing and it is {{ states.sensor.dark_sky_temperature.state | int }}degrees outside.  Forecast says {{ states.sensor.dark_sky_minutely_summary.state }}.'
        cache: false
    - service: automation.turn_off
      entity_id: automation.raining
    - delay: 00:30:00
    - service: automation.turn_on
      entity_id: automation.raining

Great, thank you both for the quick reply and options. I’ll give them a go.

Thanks