MQTT heartbeat from Home Assistant to sensor?

Hello. My ESPhome mqtt sensor sometimes gets stuck and I do not know. I monitor logs and it freezes at random points. It may be just communication and the sensor may still be alive.

In case that it is just communication that does not work, but sensor itself is still working, I would like to implement a check of mqtt heartbeat received from Home Assistant server and if it stops coming, then sensor would restart itself. I would like to do check of mqtt message rather than ping.

Is there any standard method, or has anyone tried this approach?

1 Like