Service Restored Alert Question about how

Afternoon All,

I am now using Home Assistant at work on a RPI3 and I have a load of binary ping sensors added to check switches around campus as well as physical and virtual servers. I had these all pinging at 30 second intervals but found the due to the amount being pinged it would occasionaly miss packets and trigger an “offline alert” to us.

To combat this my automation for offline alerts states this:

from: 'on'
to: 'off'
for:
  minutes: 1
  seconds: 30

This works fairly well however I have an “up alert” to indicate to us when it comes back online. The only problem is if it fails a ping and goes from on to off and then back to on before 1 minute 30 it triggers an up alert even though we never received a down alert.

Can anyone thing of a simple way to combat this without me having to add another whole load of sensors, maybe toggles for each thing I am monitoring.

Thank in advance!

Can you please show the full automations for the up and down alert? Do you have one automation per sensor or one combined for all sensors?

It is per sensor as I don’t know of any other way of doing it. Although while typing that I just thought about groups!

Here is the automation for offline alert:

- id: '1579126062579'
  alias: HP Core Offline
  description: Triggers an alert when the HP Core goes offline
  trigger:
  - entity_id: binary_sensor.hp_core
    platform: state
    from: 'on'
    to: 'off'
    for:
      minutes: 1
      seconds: 30
  condition:
    - condition: state
      entity_id: input_boolean.maint_mode
      state: 'off'
  action:
    - service: notify.it_team
      data:
        message: The HP Core Stack appears to be offline for 2 attempts!
        title: 'Offline Alert: HP Core Stack'
    - service: notify.it_sms
      data:
        message: The HP Core Stack appears to be offline for 2 attempts!
        title: 'Offline Alert: HP Core Stack'
    - service: rest_command.network_alert
      data:
        msg: "HP Core Stack Offline"

Here is the code for the online alert:

- id: '1579126062579O'
  alias: HP Core Restored
  description: Triggers an alert when the HP Core is Restored
  trigger:
  - entity_id: binary_sensor.hp_core
    platform: state
    from: 'off'
    to: 'on'
  action:
    - service: notify.it_team
      data:
        message: The HP Core Stack appears to be Restored!
        title: 'Restored: HP Core Stack'
    - service: rest_command.network_warn
      data:
        msg: "HP Core Stack Restored"

What count value are you using in your ping sensors?

5

I tried 1 and 2 but 5 seems to have less false positives.