ESPHome Watchdog

This implements a watchdog script with complementing the scripts `on_setup` and `refresh_wifi_icon` to be checking the components every minute and taking proper actions (when possible).
Solves #1464
This commit is contained in:
Edward Firmo
2023-12-27 13:57:16 +01:00
parent 29fface258
commit 4ad5457b0f
13 changed files with 302 additions and 370 deletions

View File

@@ -9,7 +9,7 @@ Program.s
int api=0 // 0 = disconnected from HA, 1 = connected to HA
int is_entities=0,is_qrcode=0,is_notification=0
int brightness=100,brightness_dim=40,brightness_sleep=0
int display_mode=2 // 1 = EU, 2 = US, 3 = US landscape
int display_mode=2 // 1 = EU, 2 = US, 3 = US landscape, 4 = blank
int charset=1 // 1 = International (original), 2 = CJK
//bauds=115200//Configure baudrate
recmod=0//Serial data parsing mode:0-Passive mode;1-Active mode

View File

@@ -13,53 +13,23 @@ Page boot
Events
Preinitialize Event
sendme
dim=0
dim=100
vis bt_reboot,0
covx baud,baud_rate.txt,0,0
baud_rate.txt+=" bps"
covx display_mode,aux2.txt,0,0
covx charset,aux3.txt,0,0
nspanelevent.txt="{\"page\": \"boot\", \"event\": \"pagechanged\", \"version\": \""+tft_version.txt+"\", \"display_mode\": \""+aux2.txt+"\", \"charset\": \""+aux3.txt+"\"}"
printh 92
prints "localevent",0
printh 00
prints nspanelevent.txt,0
printh 00
printh FF FF FF
Page Exit Event
dim=0
Variable (int32) counter
Attributes
ID : 12
ID : 11
Scope: local
Value: 0
Variable (string) aux1
Attributes
ID : 13
Scope : local
Text :
Max. Text Size: 10
Variable (string) nspanelevent
Attributes
ID : 14
Scope : local
Text :
Max. Text Size: 150
Variable (string) aux2
Attributes
ID : 15
Scope : local
Text :
Max. Text Size: 10
Variable (string) aux3
Attributes
ID : 21
ID : 12
Scope : local
Text :
Max. Text Size: 10
@@ -131,7 +101,7 @@ Text tft_version
Dragging : 0
Send Component ID : on press and release
Associated Keyboard: none
Text : 4.2dev.2
Text : 4.2dev.3
Max. Text Size : 9
Text esph_version
@@ -156,7 +126,7 @@ Text bluep_version
Text baud_rate
Attributes
ID : 18
ID : 14
Scope : local
Dragging : 0
Send Component ID : on press and release
@@ -166,7 +136,7 @@ Text baud_rate
Text framework
Attributes
ID : 20
ID : 15
Scope : local
Dragging : 0
Send Component ID : on press and release
@@ -184,85 +154,44 @@ Dual-state Button bt_reboot
Text : Reboot
Max. Text Size : 6
Timer timer
Attributes
ID : 11
Scope : local
Period (ms): 65534
Enabled : yes
Events
Timer Event
counter.val++
covx counter.val,aux1.txt,0,0
covx display_mode,aux2.txt,0,0
nspanelevent.txt="{\"page\": \"boot\", \"event\": \"timeout\", \"value\": "+aux1.txt+", \"version\": \""+tft_version.txt+"\", \"display_mode\": \""+aux2.txt+"\"}"
bluep_version.txt="Retry: "+aux1.txt
printh 92
prints "nspanelevent",0
printh 00
prints nspanelevent.txt,0
printh 00
printh FF FF FF
Timer wakeup_timer
Attributes
ID : 16
Scope : local
Period (ms): 50
Enabled : yes
Events
Timer Event
if(dim<100)
{
dimdelta=100-dim
dimdelta/=25
if(dimdelta<1)
{
dimdelta=1
}
dim+=dimdelta
}else
{
wakeup_timer.en=0
}
Timer tm_esphome
Attributes
ID : 17
ID : 13
Scope : local
Period (ms): 30000
Enabled : yes
Events
Timer Event
if(baud==115200)
counter.val++
if(counter.val>60)
{
bauds=921600
}else
rest
}
sendme
printh 91
prints "display_mode",0
printh 00
prints display_mode,0
printh FF FF FF
printh 91
prints "charset",0
printh 00
prints charset,0
printh FF FF FF
printh 92
prints "tft_version",0
printh 00
prints tft_version.txt,0
printh 00
printh FF FF FF
covx counter.val,aux1.txt,0,0
esph_version.txt="Retry #"+aux1.txt
sys0=counter.val%10
if(sys0==0)
{
bauds=115200
baud=115200
}
covx baud,baud_rate.txt,0,0
baud_rate.txt+=" bps"
Timer tm_pageid
Attributes
ID : 19
Scope : local
Period (ms): 2500
Enabled : yes
Events
Timer Event
covx display_mode,aux2.txt,0,0
covx charset,aux3.txt,0,0
nspanelevent.txt="{\"page\": \"boot\", \"event\": \"pagechanged\", \"version\": \""+tft_version.txt+"\", \"display_mode\": \""+aux2.txt+"\", \"charset\": \""+aux3.txt+"\"}"
printh 92
prints "localevent",0
printh 00
prints nspanelevent.txt,0
printh 00
printh FF FF FF