"Alive item", Regular (planned) reboots

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
User avatar
Tom Bombadil
New user
Posts: 3
Joined: 13 Dec 2018, 17:24
Location: Potsdam, Germany

"Alive item", Regular (planned) reboots

#1 Post by Tom Bombadil » 13 Dec 2018, 17:58

Hi,

for the time being, I am having a bunch of D1mini and NodeMCU devices, reporting Temp/Hum/Pres values to my home automation System through UDP as follows:

Sensors ----> UDP Controller in ESPEasy --> Backend ( smarthomeNG ) ---> Frontend ( smartVISU ).

In general, this is working fine and smooth. However, I am having issues with some of the ESP's (hourly reboots, sometimes an ESP hangs without being noticed, etc). Just this week I had one device offline for 3 days, and didn't notice it.

Besides the sensor values, my backend also stores date/time for 'value last updated' and 'value last changed' for each submitted item. So I am thinking about introducing a new 'alive' dummy value for each of the ESP's, that is frequently sending an update to the backend. If the dummy value hasn't been updated for like 30 minutes or so, I know the device is offline and needs a reboot. This status could easily be displayed in the frontend by a separate bool item next to the temp/hum/pres values as a 'traffic light' red/green.

So far all is clear, I am just not sure what would be the best / most reliable way to configure ESP Easy (I am still pretty much a noob on rules etc). Also, I read somewhere that ESP Easy Controllers only send protocols once a value has changed (so: no sending for unchanged values). The following two rule sets came into my mind, but before bringing this 'live' I wanted to ask if someone else has some hints or a better solution for this, or if maybe someone has done something similar before:

Code: Select all

//?on System#Boot do?//
on Time#Initialized do
  TaskValueSet 3,2,1          // set dummy 'alive' item to 1
  timerSet,1,900              // wait for 15 mins
endon

on Rules#Timer=1  do
  TaskValueSet 3,2,0          // set dummy 'alive' item to 0
  timerSet,2,900              // wait for 15 mins
endon

on Rules#Timer=2  do
  TaskValueSet 3,2,1          // set dummy 'alive' item to 1
  timerSet,1,900              // wait for 15 mins
endon

on Clock#Time=All,03:00 do     // every day at 03:00
  Reboot
endon
Alternatively:

Code: Select all

//?on System#Boot do?//
on Time#Initialized do
  TaskValueSet 3,2,%unixtime%  // write seconds into dummy item
  timerSet,1,900               // wait for 15 mins
endon

on Rules#Timer=1  do
  TaskValueSet 3,2,%unixtime%  // write seconds into dummy item
  timerSet,1,900               // wait for 15 mins
endon

on Clock#Time=All,03:00 do     // every day at 03:00
  Reboot
endon
Thanks for your comments and suggestions!

/tom

User avatar
grovkillen
Core team member
Posts: 3621
Joined: 19 Jan 2017, 12:56
Location: Hudiksvall, Sweden
Contact:

Re: "Alive item", Regular (planned) reboots

#2 Post by grovkillen » 13 Dec 2018, 18:32

I'd do it like this:

Code: Select all

on System#Boot do
  timerSet,1,30
endon

on Rules#Timer=1 do
  //Whatever you want to do
  TimerSet,1,30
endon
ESP Easy Flasher [flash tool and wifi setup at flash time]
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you :idea: :idea: :idea:

User avatar
Tom Bombadil
New user
Posts: 3
Joined: 13 Dec 2018, 17:24
Location: Potsdam, Germany

Re: "Alive item", Regular (planned) reboots

#3 Post by Tom Bombadil » 13 Dec 2018, 19:09

Thanks - looks pretty much straightforward. Wasn't sure if I could activate a timer from itself. Only System#Boot seems too early, it is delivering a 2-digit value (like '16') to the dummy item, representing the seconds from Jan-01-1970. So I will stick to Time#Initialized, which delivers a 'real-world' %unix_time%.

What makes me wonder - I set the interval of the timer to '15' (seconds), but the value is only changing like every 2 minutes or so (investigating details right now):

Code: Select all

on Rules#Timer=1  do
  TaskValueSet 3,2,%unixtime%  // write seconds into dummy item
  timerSet,1,15                // wait for 15 secs
endon
Bug or feature?

/tom

User avatar
grovkillen
Core team member
Posts: 3621
Joined: 19 Jan 2017, 12:56
Location: Hudiksvall, Sweden
Contact:

Re: "Alive item", Regular (planned) reboots

#4 Post by grovkillen » 13 Dec 2018, 19:57

TaskValueSet doesn't "trigger" the task to be re-read. You have to make a TaskRun after the task value is being set for it to "trigger". So your dummy is then only checked more infrequently if you do not do that TaskRun command.
ESP Easy Flasher [flash tool and wifi setup at flash time]
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you :idea: :idea: :idea:

User avatar
Tom Bombadil
New user
Posts: 3
Joined: 13 Dec 2018, 17:24
Location: Potsdam, Germany

Re: "Alive item", Regular (planned) reboots

#5 Post by Tom Bombadil » 15 Dec 2018, 23:43

Thanks the help again! Quick update - got it running well with the following rules:

Code: Select all

on Sensor#Temperature do
  TaskValueSet,3,1,%c_dew_th%([Sensor#Temperature],[Sensor#Humidity])
endon

on Time#Initialized do
  TaskValueSetAndRun 3,2,%unixtime%  // write seconds into dummy item
  TimerSet,1,600                     // wait for 15 mins
endon

on Rules#Timer=1 do
  TaskValueSetAndRun 3,2,%unixtime%  // write seconds into dummy item
  TimerSet,1,600                     // wait for 15 mins
endon

on Clock#Time=All,03:00 do           // every day at 03:00
  Reboot
endon
Nice side effect - the hardware watchdog reboots seem to have disappeared, or at least delayed by >100% (not sure yet). Before no uptime >4 hours, now all sensors lasting since >8hrs already. Only other thing I changed besides the rules is the BME280 reading time 30s --> 120s.

/tom

Post Reply

Who is online

Users browsing this forum: Bing [Bot], Semrush [Bot] and 46 guests