How to tell if my ESP8266 is still alive?

here you go:

automation:
  - alias: My esp is still alive and well
    trigger:
      - platform: mqtt
        topic: home/sensor1
        payload: alive
      - platform: homeassistant
        event: start
    action:
      - service: timer.start
        entity_id: timer.timer_esp_sensor
  - alias: ESP Sensor dying
    trigger:
      - platform: event
        event_type: timer.finished
        event_data:
          entity_id: timer.timer_esp_sensor
    action:
      - service: notify.html5
        data:
          title: "ESP is dead"
		  message: "Save me! your esp"


timer:
  timer_esp_sensor:
    duration: '00:05:00'

In this example you need to publish an mqtt message on the topic home/sensor1 with the payload “alive” at most every 5 minutes. If this message is not received, an html5 notification is sent.

5 Likes

You rule Touliloup !!!
I understand exactly what I have to do now !
Thank you everybody for your help. Home assistant is really powerful but not easy to tame at first :wink:

1 Like

I had posted something earlier that turns out did not work, but I have tested this. It does in fact work. You just need to have your MQTT sensors publish to a “I’m Alive” topic every 5 minutes or so. I tested it on my humidity sensor. It sends me a message every 10 minutes if the sensors has not checked in for over 5 minutes

- alias: ESP humidity sensor checker
  trigger:
    - platform: time
      minutes: '/10'
      seconds: 0
  action:
    - condition: template
      value_template: '{{as_timestamp(now()) - as_timestamp(states.sensor.outdoor_humidity_keepalive.last_changed) > 300 }}'
    - service: notify.notify
      data:
        message: ESP Humidity Sensor has gone offline!
2 Likes

Hi guys and gals :wink:
I had time (at last) tonight and I tested the solutions posted by touliloup and ericleejoe.
Both works ! My ESP can now die in peace :smiley:
I thank you a lot again !!!

2 Likes

Awesome. Hey listen. I implemented my solution too, but I had a small issue. If I just sent “alive” to the MQTT broker from my ESP8266, HA saw it as never changing. So I had to publish 2 messages a “ping” and “pong” every 5 minutes so HA always saw it as changing.

1 Like

Thanks for this.
After adding pattern it worked great.
Like so…

- platform: time_pattern