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.
Espeasy watchdog
Moderators: grovkillen, Stuntteam, TD-er
Re: Espeasy watchdog
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
-
- New user
- Posts: 1
- Joined: 04 Dec 2017, 14:13
Re: Espeasy watchdog
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?
Re: Espeasy watchdog
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
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
Re: Espeasy watchdog
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:
Maybe someone finds this helpful.
- 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
-
- Normal user
- Posts: 51
- Joined: 15 Sep 2016, 00:20
Re: Espeasy watchdog
Wow, thanks for the tips guys. I will use both example scripts.
Who is online
Users browsing this forum: No registered users and 44 guests