How to get a message when a device is unavailable for 30 seconds

Hello,

I want to receive a message when one of my devices (switch, sensor, ESPHome device,…) is unavailable, as well as when it is available again. However, I only want this when my device has been unavailable for at least 30 seconds.

Unavailable for at least 30 seconds is easy:

trigger:
  - platform: state
    entity_id:
      - sensor.wifi_signal_bed_occupancy
    to: unavailable
    for:
      hours: 0
      minutes: 0
      seconds: 30
    variables:
      trigger_message: ESPHome - Bed-occupancy

Back available :

  - platform: state
    entity_id:
      - sensor.wifi_signal_bed_occupancy
    from: unavailable
    variables:
      trigger_message: ESPHome - Bed-occupancy

But how can I avoid to get a message for a device which only went 10 seconds offline ?

Use the alert integration

Hello Christian,

I have this blueprint available. It is available to use or to look at the code and learn how to do your own version.

HA_Blueprints/Automations/Device_tracker_Monitor_and_Notifier.md at d1c15d75a7b5fa3042d60f7eee2d7633ea8a27a3 · SirGoodenough/HA_Blueprints · GitHub.

I will have a look at it, thanks !