Home Assistant Automation for monitor ESPHome board availability

Hi all
I’ve had an issue on my POE Esp32 and it was offline for a while, so I decided to create an automation to monitor all my esp32.
You could identify any sensor in esphome device, I created a text sensor with esp32 board type/vendor and used it for monitoring.
So, you could add to your esphome yaml config file:

substitutions:
  esphome_name: "esp-box"
  esp32_board: WT32-ETH01    
text_sensor:
  - platform: template # Expose the board type as a sensor
    id: espboard_type
    icon: "mdi:developer-board"
    name: $esphome_name ESPBoard
    update_interval: 3600s
    lambda: |-
      return to_string("${esp32_board}");

Then automation will be:

alias: esphome_board_offline
description: check if esphome (esp32/esp8266) board is offline and then online
trigger:
  - platform: state
    entity_id:
      - sensor.esp32_controsoffitto_espboard
    to: unavailable
    variables:
      title: WARNING
      text: Controsoffitto Esphome Board is offline
  - platform: state
    entity_id:
      - sensor.esp32_controsoffitto_espboard
    from: unavailable
    variables:
      title: NORMAL
      text: Controsoffitto Esphome Board is back online
#add a pair of trigger for each of your esp32 board
condition: []
action:
  - service: notify.persistent_notification
    data:
      message: "{{ text }}"
      title: "{{ title }}"
  - service: notify.family_app
    metadata: {}
    data:
      message: "{{ text }}"
      title: "{{ title }}"
mode: single

I used a ping sensor for each of my ESP’s, that is also an alternative :slight_smile:

Please, could you put some reference?
I’ve discovered that ESPs wifi connected sometime disappear for a while time to time.

You should use static IP-adresses for your ESP’s and use this integration: