Hi, I just had the problem that my home assistant rpi4 hang after starting into holiday. I heard about watchdog and heartbeat.
So I think about creating a heartbeat over mqtt (running) and use esphome to check if system is still up. If not I want to turn off/on a Shelly plug.
So is it possible to use esphome to check for the heartbeat and if not getting the ping for x/minutes turn the Shelly plug off and after x/seconds on again so the system can restart.
I heard that home assistant os or rpi4 should have watchdog but because my system crashed (not sure if ha or rpi4 crashed) and not came back alone I plan a hardware switch to cut the power for a restart.
So is that possible or how would you do it or maybe solved it?
So, you want to ping the RPI4 periodically to see if it is dead?
ESPHome devices can’t ping.
I would use an ESP (Wemos D1 Mini) running an Arduino sketch to ping the RPI every few seconds then pulse a relay off\on if it fails two or three pings.
Use a Sonoff R2 or another plug that you can flash with ESPHome. Use the mqtt.connected condition and you’re good to go. Not an ESP and a plug, just flash the plug with ESPHome.
If your Pi isn’t running, the Mosquitto won’t be running as well. And there you go.
EDIT. you don’t even need to check explicitly, ESPHome starts your ESPHome-flashed-plug automatically, if it can’t get a connection for 15 minutes (configurable). So the only thing you need is a plug, that you can flash with ESPHome. The rest is almost automatical.
Do Automations Work Without a Network Connection
YES! All automations you define in ESPHome are executed on the ESP itself and will continue to work even if the WiFi network is down or the MQTT server is not reachable.
There is one caveat though: ESPHome automatically reboots if no connection to the MQTT broker can be made. This is because the ESPs typically have issues in their network stacks that require a reboot to fix. You can adjust this behavior (or even disable automatic rebooting) using the reboot_timeout option in the wifi component and mqtt component. (Beware that effectively disables the reboot watchdog, so you will need to power cycle the device if it fails to connect to the network without a reboot)
This is a very serious thing you need to consider. If you’re running a long update, e.g. because the database needs to be updated, you are pulling the plug from under it potentially destroying your setup. Same if MQTT is down but HA is not, or if you have a valid reason to stop services for some reason.
If you have frequent unexpected downtime you should investigate the cause, not make it worse by adding data corruption into the mix every time it happens. PTP should be a last resort when a graceful shutdown is no longer an option.
Zu beachten: wenn Du zum flashen nicht löten willst, dann muss es bei der Dose die S20 sein, und nicht die S26. Bei den anderen Sonoffs würde ich auf jeden Fall den R2 und nicht den R3 nehmen.
Meine persönliche Meinung: da das eh in der “Computer-Ecke” statt findet, würde ich den R2 nehmen, da kann man gleich mit entsprechenden Kabeln arbeiten, und muss nicht extra Dosen setzen.
The first two links are simply the two devices I’d recommend.
What I’d recommend is to use the S20, because you don’t need to solder (compared to the S26) and the Basic R2 against the R3. I’d use a R2, because you can put it in your setup without using additional power outlets.
I’m an idiot, the mentioned Shelly Plug S is already flashable with ESPHome.