Page 1 of 1

Reboot tracking

Posted: 13 Jun 2021, 20:28
by marstu
Hi all,

I have a new idea, and would like to track the reboots of my ESPs on a daily basis (clear variable right before midnight) in a dummy device due to this rule, which is working very well:

Code: Select all

on System#Boot do
  timerSet,1,60  // Set timer 1
endon

on WiFi#Disconnected do
  timerSet,1,60  // Set timer 1
endon

on WiFi#Connected do
  timerSet,1,0  // Clear timer 1
endon

On Rules#Timer=1 do
  Reboot
endOn
My idea was the following:

Code: Select all

on Clock#Time=All,23:59 do //will run once a day at noon
 Let,16,0
endon

On System#Boot do 
  TaskValueSet 6,1,[var#16]+1 //will this survive a reboot?
endon
I guess there is a slight mistake and this

Code: Select all

On System#Boot do 
should ready as

Code: Select all

On System#Reboot do 
Please correct me if I am wrong?


Merci already and kind regards
marstu

Re: Reboot tracking

Posted: 13 Jun 2021, 20:38
by TD-er
Variables do not survive a reboot, but task variables do.
So you could store something in a dummy task and try to read it at boot.

N.B. This is somewhat unreliable on ESP32, but on ESP8266 it does work, as long as you don't power cycle the node.

Re: Reboot tracking

Posted: 13 Jun 2021, 20:58
by marstu
TD-er wrote: 13 Jun 2021, 20:38 Variables do not survive a reboot, but task variables do.
So you could store something in a dummy task and try to read it at boot.
Ok, again not thought out correctly. Next try is something like that:

Code: Select all

on Clock#Time=All,23:59 do //will run once a day at noon
 TaskValueSet 6,1,0
endon
On System#Boot do 
  TaskValueSet 6,1,[Reb_Count#Reboots]+1 //will this survive a reboot?
endon
But how can I increase this task variable after each reboot? I guess I need something different to [var#16]+1, but what is exactly required? [Reb_Count#Reboots]+1 might this be an idea?
TD-er wrote: 13 Jun 2021, 20:38 N.B. This is somewhat unreliable on ESP32, but on ESP8266 it does work, as long as you don't power cycle the node.
It is a ESP8266, I am not yet into ESP32s.

Re: Reboot tracking

Posted: 13 Jun 2021, 21:05
by marstu
marstu wrote: 13 Jun 2021, 20:58

Code: Select all

on Clock#Time=All,23:59 do //will run once a day at noon
 TaskValueSet 6,1,0
endon
On System#Boot do 
  TaskValueSet 6,1,[Reb_Count#Reboots]+1 //will this survive a reboot?
endon
Tested and it is working as expected, thanks for the helpful hint.