Configure ESP8266 Plug For Failsafe Power Toggle

Today for the first time in ages my HomeAssistant totally locked up (still diagnosing) and it got me thinking that I should have a failsafe for this type of thing in case I’m out of town.

I have a Kauf PLF plug using the minimal firmware and I thought I could have it ping my HA server periodically and if there is no response then turn the plug off (that HA would be connected to) and then back on after 30 seconds.

I’m not sure the code to do this as I’ve only done a handful of ESP’s and they’ve mostly been doing pretty stock things. Can someone give me a good example of how that might work? The code for my device is in the link above, I believe it’s just toggling the GPIO so I need to have something that pings periodically.