Espeasy watchdog

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
adrianmihalko
Normal user
Posts: 51
Joined: 15 Sep 2016, 00:20

Espeasy watchdog

#1 Post by adrianmihalko » 16 Nov 2017, 00:36

Hi,

I am controlling a heater from EspEasy via a relay (xy/control?cmd=GPIO,14,0 and xy/control?cmd=GPIO,14,1).

It is possible to write a "watchdog" script (rule) on the EspEasy itself? I mean if there is no connection to the Domoticz (or ping an ip address) turn off GPIO port (xy/control?cmd=GPIO,14,0) after XY minutes - to disable heating if there is no connection to the Domoticz server.

User avatar
toffel969
Normal user
Posts: 469
Joined: 03 Jan 2017, 10:58
Location: Germany

Re: Espeasy watchdog

#2 Post by toffel969 » 16 Nov 2017, 07:44

Sure, check the timer section of the rules tutorial: https://www.letscontrolit.com/wiki/inde ... rial_Rules
Domoticz on Raspi 2 -- 14 ESP units (hacked Sonoff,NodeMCUs, Wemos, self-built units) running with RC140- Mega 2.0.0 dev8

brandonsanders
New user
Posts: 1
Joined: 04 Dec 2017, 14:13

Re: Espeasy watchdog

#3 Post by brandonsanders » 04 Dec 2017, 14:46

Thanx for that link. It has helped me too
Hello to everybody here!

dheiss
New user
Posts: 2
Joined: 01 May 2017, 23:51

Re: Espeasy watchdog

#4 Post by dheiss » 10 Dec 2017, 15:52

Same idea as @adrianmihalko, however the current ESPEasy rules do not allow basic TCP functions like ping or get url - or am I missing something? How would you create a watchdog (e.g. restart router if IP 8.8.8.8 is not pingable) with ESPEasy rules?

kimot
Normal user
Posts: 190
Joined: 12 Oct 2017, 20:46

Re: Espeasy watchdog

#5 Post by kimot » 10 Dec 2017, 20:31

adrianmihalko wants check connection with Domoticz.

So he can send commands from Domoticz in certain interval - for example every 1 minute.

Instead of command "?cmd=GPIO,14,0 and xy/control?cmd=GPIO,14,1"

he will send for example " ?cmd=RELAY_OFF and xy/control?cmd=RELAY_ON"

On ESPeasy then rules:

on RELAY_OFF do
gpio,14,0
timerSet,1,180
endon

on RELAY_ON do
gpio,14,1
timerSet,1,180
endon

On Rules#Timer=1 do
Reboot
endon

On System#Boot do
gpio,14,0
timerSet,1,180
endon

When 180s nothing from Domoticz received - reboot ESPeasy

dheiss
New user
Posts: 2
Joined: 01 May 2017, 23:51

Re: Espeasy watchdog

#6 Post by dheiss » 10 Dec 2017, 22:05

I took a slightly different approach as I wanted to use ESPEasy independent from any central server to check if my router is online and do a power cycle if a ping to an IP address fails. I included Neutrinos Ping Plugin http://www.letscontrolit.com/forum/view ... ing#p19815 and then the following configuration:
  • Configure Ping Device with the IP and a 30sec delay as Task #1
  • Configure a Generic Dummy Device to store the number of retries and reboots. The dummy device contains two values Var1 and Var2 and is Task #2
  • Create the following Rule to handle the Ping events

Code: Select all

on System#Boot do
  TaskValueSet 2,1,0 // set Var1 to 0
  TaskValueSet 2,2,0  // set Var2 to 0
endon

on Router#Ping=1 do // Host online, reset retries
  PWM,2,0  // LED on GPIO-2 on
  TaskValueSet 2,1,0
  TaskValueSet 2,2,0
endon

on Router#Ping=0 do // Host offline, dim LED and call retryCounter
  if [Dummy#Var2]<4 // give up after 3 reboots
    event retryCounter
  endif
endon

on retryCounter do
  if [Dummy#Var1]<10 // wait 10 retries before restarting router
    PWM,2,900  // LED on GPIO-2 dim
    TaskValueSet 2,1,[Dummy#Var1]+1
  else
    PWM,2,1020  // LED on GPIO-2 almost off
    TaskValueSet 2,1,0
    TaskValueSet 2,2,[Dummy#Var2]+2
    timerSet,1,5
    // insert GPIO command to switch router off
  endif
endon

on Rules#Timer=1 do
  PWM,2,0
  // insert GPIO command to switch router on
endon
Maybe someone finds this helpful.

adrianmihalko
Normal user
Posts: 51
Joined: 15 Sep 2016, 00:20

Re: Espeasy watchdog

#7 Post by adrianmihalko » 13 Dec 2017, 00:29

Wow, thanks for the tips guys. I will use both example scripts.

Post Reply

Who is online

Users browsing this forum: No registered users and 44 guests