Here's a smart outlet watchdog for Home Assistant server

I have been trying for months to figure out why my Home Assistant/Frigate native OS installation on Intel hardware occasionally halts. The logs simply have been of no help. As ugly as it might sound, turning the system off and back on is the only way I have found (so far) to get HA running again. I can’t have the system going down when I am away without a way for it to reboot itself.

Now there have been other discussions about this but I did not find any that offered a full solution. Here is what I have come up with using a Kauf Plug PLF12, flashed to Tasmota. This is my first Tasmota project and I encountered a few glitches along the way (noted below along with the workarounds).

In the spirit of paying forward all the help this forum has provided to me, here is a detailed tutorial.

In simple terms, this “custom” outlet

  1. Turns on the outlet and the blue LED. The red LED starts flashing slowly.
  2. After a delay of about 1 minute, to the computer to start, a web query of the Home Assistant UI is attempted. (set your own IP address in the Rule). I chose to use the web query over just a ping as a ping goes to the NIC and not specifically to the Home Assistant instance.
  3. If the web query fails, the interval between inquiries is doubled and the red led begins flashing more rapidly. The outlet and blue LED are turned off for 3 seconds and then back on. After the web query interval elapses, the web query in step 2 is repeated. The web query interval is capped at 16 minutes.
  4. When the web query is successful, the flashing of the red LED is stopped and the web query interval is set back to 1 minute.

Here are the detailed steps which are, hopefully, written for anyone with as little familiarity of Tasmota as I had when I started…

Here is a blow-by-blow walk through of the Tasmota rule.

And here is the rule all on one line:

Rule1 ON system#boot DO backlog Power1 1; Power3 1; Var1 1; BlinkTime 6; BlinkCount 32000; Power2 Blink ENDON ON Var1#State>16 DO Var1 16 ENDON ON Time#Minute|%var1% DO backlog BlinkTime 3; BlinkCount 32000; Power2 Blink; WebQuery http://192.168.1.220:8123/ GET 100 ENDON ON WebQuery#Data$!Done DO backlog Mult1 2; Power1 0; Power3 0; Delay 30; Power1 1; Power3 1 ENDON ON WebQuery#Data=Done DO backlog Var1 1; Power2 BlinkOff; Power2 0; Power1 1; Power3 1 ENDON

From the Tasmota console for the smart plug:
1. Copy and paste the full rule on a single line to enter it into the processor.
2. Enter “Rule1 1” to initiate the rule.
3. Enter “Restart 1” to restart the smart plug. (this is necessary since we need a “boot” event for the first steps of the rule)

NOTE: There must be a natural route between the WiFi of the smart plug and the Home Assistant server. Make sure you don’t have any firewall or zone rules that would prevent that traffic (or punch a hole in those rules to allow this specific traffic).

NOTE: Home Assistant host bios must be set to power on after power loss.