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
Turns on the outlet and the blue LED. The red LED starts flashing slowly.
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.
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.
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…
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.
I soon realized that if I have to reboot my router, I don’t want the Home Assistant/Frigate server rebooting. So… here is a version that, if the HA server can’t be reached, we test the router and only if the router is up do we then reboot the HA server. Here is that code in commented form and on one line.
// Var1 interval
// Var2 0 = Testing Home Assistant 1 = Testing Router
// Power1 Outlet
// Power2 Red LED
// Power3 Blue LED
Rule1
ON system#boot DO backlog Power1 1; Power3 1; Var1 1; BlinkTime 10; BlinkCount 0; Power2 Blink; Var2 0 ENDON // Outlet on, Blue LED on, Red LED slow flash (appears purple)
ON Var1#State>16 DO Var1 16 ENDON // limit interval to 16 minutes
ON Time#Minute|%var1% DO backlog Var2 0; BlinkTime 5; Power2 Blink; WebQuery http://192.168.1.220:8123/ GET 100 ENDON // clear flags, check Home Assistant, more rapid Red LED flash (flashes purple)
// Step 2: Handle Home Assistant result and if down, test Router
ON WebQuery#Data=Done DO IF (%var2%==0) Var1 1; Power2 BlinkOff; Power1 1; Power2 0; Power3 1 ENDON // HA connected, no need to test Router
ON WebQuery#Data$!Done DO IF (%var2%==0) Var2 1; WebQuery http://192.168.1.1/ GET 100 ENDIF ENDON // HA not connected, test Router
// Step 3: Handle Router result
ON WebQuery#Data=Done DO IF (%var2%!=0) RuleTimer1 1 ENDIF ENDON // HA down, Router Up: trigger RuleTimer 1 Use RuleTimer since we need to use backlog to sequence the delay
ON WebQuery#Data$!Done DO IF (%var2%!=0) BlinkTime 2 // (HA Down), Router down: Flash more rapidly (minimum BlinkTime value is 2)
ON Rules#Timer=1 DO backlog Mult1 2; Power1 0; Power3 0; Delay 30; Power1 1; Power3 1 ENDON
on one line
Rule1 ON system#boot DO backlog Power1 1; Power3 1; Var1 1; BlinkTime 10; BlinkCount 0; Power2 Blink; Var2 0 ENDON ON Var1#State>16 DO Var1 16 ENDON ON Time#Minute|%var1% DO backlog Var2 0; BlinkTime 5; Power2 Blink; WebQuery http://192.168.1.220:8123/ GET 100 ENDON ON WebQuery#Data=Done DO IF (%var2%==0) Var1 1; Power2 BlinkOff; Power1 1; Power2 0; Power3 1 ENDIF ENDON ON WebQuery#Data$!Done DO IF (%var2%==0) Var2 1; WebQuery http://192.168.1.1/ GET 100 ENDIF ENDON ON WebQuery#Data=Done DO IF (%var2%!=0) RuleTimer1 1 ENDIF ENDON ON WebQuery#Data$!Done DO IF (%var2%!=0) BlinkTime 2 ENDIF ENDON ON Rules#Timer=1 DO backlog Mult1 2; Power1 0; Power3 0; Delay 30; Power1 1; Power3 1 ENDON
And further evolution to maintain a count of the number of times that the HA server is restarted.
0: SetOption4 1
1: Use Mem1 to retain restart count so that I can keep the count between restarts. (Mem values are persistent across restarts. Var values are not)
2: Publish a specific topic rather than just Mem1 (which also comes for free apparently). Set up to receive the topic on Home Assistant in configuration.yaml
3: Publish the value of Mem1 to the topic at restart (in Rule 1) and when it changes (in Rule 2). (NOTE, COMMENTS BELOW ARE ONLY FOR EXPLANATION AND CANNOT BE INCLUDED IN THE RULES. SEE THE SINGLE LINE RULE FURTHER DOWN FOR THE UNCOMMENTED VERSION.
Rule1
ON system#boot DO backlog Power1 1; Power3 1; Var1 1; BlinkTime 10; BlinkCount 0; Power2 Blink; Var2 0 ; // Outlet on, Blue LED on, Red LED slow flash (appears purple)
Publish stat/tasmota_HAWatchdog/ResetCount %Mem1% ENDON //Publish persistent value of Mem1
ON Var1#State>16 DO Var1 16 ENDON // limit interval to 16 minutes
ON Time#Minute|%var1% DO backlog Var2 0; BlinkTime 5; Power2 Blink; WebQuery http://192.168.1.220:8123/ GET 100 ENDON // clear flags, check Home Assistant, more rapid Red LED flash (flashes purple)
// Step 2: Handle Home Assistant result and if down, test Router
ON WebQuery#Data=Done DO IF (%var2%==0) Var1 1; Power2 BlinkOff; Power1 1; Power2 0; Power3 1 ENDON // HA connected, no need to test Router
ON WebQuery#Data$!Done DO IF (%var2%==0) Var2 1; WebQuery http://192.168.1.1/ GET 100 ENDIF ENDON // HA not connected, test Router
// Step 3: Handle Router result
ON WebQuery#Data=Done DO IF (%var2%!=0) RuleTimer1 1 ENDIF ENDON // HA down, Router Up: trigger RuleTimer 1 Use RuleTimer since we need to use backlog to sequence the delay
ON WebQuery#Data$!Done DO IF (%var2%!=0) BlinkTime 2 // (HA Down), Router down: Flash more rapidly (minimum BlinkTime value is 2)
ON Rules#Timer=1 DO backlog MULT1 2; Power1 0; Power3 0; Delay 30; Power1 1; Power3 1; ADD3 1 ENDON
Rule2 ON Mem1#State DO Publish stat/tasmota_HAWatchdog/ResetCount %value% ENDON
Here is Rule1 on a single line:
Rule1 ON system#boot DO backlog Power1 1; Power3 1; Var1 1; BlinkTime 10; BlinkCount 0; Power2 Blink; Var2 0; Publish stat/%topic%/Mem1 %value% ENDON ON Var1#State>16 DO Var1 16 ENDON ON Time#Minute|%var1% DO backlog Var2 0; BlinkTime 5; Power2 Blink; WebQuery http://192.168.1.220:8123/ GET 100 ENDON ON WebQuery#Data=Done DO IF (%var2%==0) Var1 1; Power2 BlinkOff; Power1 1; Power2 0; Power3 1 ENDIF ENDON ON WebQuery#Data$!Done DO IF (%var2%==0) Var2 1; WebQuery http://192.168.1.1/ GET 100 ENDIF ENDON ON WebQuery#Data=Done DO IF (%var2%!=0) RuleTimer1 1 ENDIF ENDON ON WebQuery#Data$!Done DO IF (%var2%!=0) BlinkTime 2 ENDIF ENDON ON Rules#Timer=1 DO backlog MULT1 2; Power1 0; Power3 0; Delay 30; Power1 1; Power3 1; Mem1 %Mem1% + 1 ENDON
We can see that both Mem1 and ResetCount get published, but ResetCount is in a form similar to POWER1, etc.
I just stumbled upon your writeup. I may use this concept for a similar issue I’m having with my ISP frequently having outage issues in my area. I need to power cycle the modem and router after the outage for my equipment to work again.
Just curious about your temperamental intel hardware. Are you using proxmox and the e1000e diver for your NIC? If so, search “e1000e diver proxmox” and you might be a victim as I was for this issue. It’s a common issue that I don’t think has been resolved by the proxmox team yet. There’s a helper script out there that seems to be the fix (worked for me)