How to create an automation that sends a notification if a espHome sensor(door and Temp) goes offline

Hi All,

I wanted to create an automation if my esHome fridge sensor is not reacheble (and maybe the power is out).

when I create an Automation I only see temparature and door which I added into ESPhome.

Any idea how to do that?

alias: New Automation
description: ''
mode: single
trigger:
  - platform: state
    entity_id: sensor.your-sensor
    to: 'unavailable '

This trigger works for a couple of automations I use.

Is there any way to add to the message for how many minutes the sensor was unavailable(from the trigger to Unavailable):

alias: Chest Freezer Not Available
description: ''
trigger:
  - platform: state
    entity_id:
      - sensor.chest_frezer_temperature_2
    to: unavailable
    for:
      hours: 0
      minutes: 30
      seconds: 0
  - platform: state
    entity_id:
      - binary_sensor.chest_freezer_door_2
    to: unavailable
    for:
      hours: 1
      minutes: 0
      seconds: 0
  - platform: state
    entity_id:
      - sensor.chest_frezer_temperature_2
    to: unavailable
    for:
      hours: 2
      minutes: 0
      seconds: 0
  - platform: state
    entity_id:
      - binary_sensor.chest_freezer_door_2
    to: unavailable
    for:
      hours: 3
      minutes: 0
      seconds: 0
condition: []
action:
  - service: telegram_bot.send_message
    data:
      message: Chest freezer not available for X minutes.
  - service: tts.google_translate_say
    data:
      entity_id: all
      message: Chest freezer not available for X minutes.
mode: single


action:

  • service: telegram_bot.send_message
    data:
    message: Chest freezer not available for {{ trigger.for }}
  • service: tts.google_translate_say
    data:
    entity_id: all
    message: Chest freezer not available for {{ trigger.for }}
    mode: single

Hi all
I’ve created this Home Assistant automation in order to see if a esphome board is unavailable (sending a notification) or is back available (another notification).
I could be useful for you.

automation:
  - id: "1705770025551"
    alias: irrigation_board_offline
    description: "check if irrigation board is offline and then online"
    mode: single
    trigger:
      - platform: state
        entity_id:
          - sensor.irrigation_espboard
        from: null
        to: unavailable
        id: unavailable
      - platform: state
        entity_id:
          - sensor.irrigation_espboard
        to: null
        from: unavailable
        id: available
    condition: []
    action:
      - choose:
          - conditions:
              - condition: trigger
                id:
                  - unavailable
            sequence:
              - service: notify.persistent_notification
                data:
                  message: Irrigation Board is offline
                  title: WARNING
              - service: notify.family_app
                metadata: {}
                data:
                  message: Irrigation Board is offline
                  title: WARNING
          - conditions:
              - condition: trigger
                id:
                  - available
            sequence:
              - service: notify.persistent_notification
                data:
                  message: Irrigation Board is back online
                  title: NORMAL
              - service: notify.family_app
                metadata: {}
                data:
                  message: Irrigation Board is back online
                  title: NORMAL

notify.family_app is a group (manual entry in config.yaml file):

notify:
  - name: family_app
    platform: group
    services:
      - service: mobile_app_sm_g981b #andrea
      - service: mobile_app_sm_a530f #giordy