Page 1 of 1

ESPEasy WiFi reconnect Rules

Posted: 08 Apr 2019, 13:11
by Rob Muller
Friends,

After a recent router failure i experienced that ESPEasy would not reconnect to WiFi on its own. A device reboot was required.
All my devices run a stable version of ESPEasy Mega-......
I could not find a script to monitor WiFi without use of plugins not available in the basic stable version, and i try to stay off the {b}leeding edge...

So i cobbled this together, i tested this on many versions and it worked for all Mega....

Code: Select all

on System#Boot do
    Let,1,0                              // set user variable to initial state of 0         
EndOn
 
on Wifi#Disconnected do              	 // if no wifi, wait 3 minutes
  if [VAR#1]=0
    timerSet,1,180
    Let,1,1                              // set user variable 1 to 1 to prevent re-set of var1 on each event.
  endif
endon
 
on Wifi#Connected do     	 	 // if wifi returns, cancel reboot
  timerSet,1,0                    	 // cancel timer
  Let,1,0                                // set user variable 1 to 0
endon
 
On Rules#Timer=1 do                    	 // if still no Wifi, reboot
  reboot
endon
I hope others will find a use for this.

If you have improvements or a beter idea, share please

Regards,

Rob

Re: ESPEasy WiFi reconnect Rules

Posted: 08 Apr 2019, 14:25
by riker1
Hi

thanks

Was wondering is a

Code: Select all

wificonnect
would solve it ,
doing a reboot is more save?

Re: ESPEasy WiFi reconnect Rules

Posted: 08 Apr 2019, 19:17
by Rob Muller
Riker1,

I tried that and could not get it to work reliably, but a reboot worked 100% of the time.
maybe a reboot clears something in memory that prevents re-connection.

I tested using the following method, as i have only one wifi network and cannot switch that off if i want to live (Wife!!)

Testing method:
connect to iPhone personal hotspot
open serial connection
switch off personal hotspot and observe reconnect in serial console

thanks for your reaction

Rob

Re: ESPEasy WiFi reconnect Rules

Posted: 09 Apr 2019, 07:53
by riker1
thanks Rob

Re: ESPEasy WiFi reconnect Rules

Posted: 09 Apr 2019, 13:29
by 1CM69
Rob Muller wrote: 08 Apr 2019, 13:11 Friends,

After a recent router failure i experienced that ESPEasy would not reconnect to WiFi on its own. A device reboot was required.
All my devices run a stable version of ESPEasy Mega-......
I could not find a script to monitor WiFi without use of plugins not available in the basic stable version, and i try to stay off the {b}leeding edge...

So i cobbled this together, i tested this on many versions and it worked for all Mega....

Code: Select all

on System#Boot do
    Let,1,0                              // set user variable to initial state of 0         
EndOn
 
on Wifi#Disconnected do              	 // if no wifi, wait 3 minutes
  if [VAR#1]=0
    timerSet,1,180
    Let,1,1                              // set user variable 1 to 1 to prevent re-set of var1 on each event.
  endif
endon
 
on Wifi#Connected do     	 	 // if wifi returns, cancel reboot
  timerSet,1,0                    	 // cancel timer
  Let,1,0                                // set user variable 1 to 0
endon
 
On Rules#Timer=1 do                    	 // if still no Wifi, reboot
  reboot
endon
I hope others will find a use for this.

If you have improvements or a beter idea, share please

Regards,

Rob
Nice, thanks

Re: ESPEasy WiFi reconnect Rules

Posted: 04 Aug 2019, 21:21
by hoeby
Would like to use the script, but have some question about it

The script uses

Code: Select all

VAR#1
Do i need to make a dummy device (or something else) to store the value.
Or is VAR a default function in espeasy?

Re: ESPEasy WiFi reconnect Rules

Posted: 04 Aug 2019, 22:05
by ThomasB
Do i need to make a dummy device (or something else) to store the value.
Or is VAR a default function in espeasy?
VARs (VAR#1 - VAR#16, alias %v1% - %v16%) are Custom Variables that are separate from those used in the dummy plugin. They are built-in/default, so a plugin is not needed to use them. Some details:
viewtopic.php?t=6288

Useful Things to know:
- Unlike Dummy plugin defined variables, the %v% variables are lost (reset to zero) on a warm reboot. So choose a Dummy for values that must survive ESPEz's pandemic random reboots.
- For debugging, you can see the values of all the %v% on the Tools=>SystemVariables page.

- Thomas

Re: ESPEasy WiFi reconnect Rules

Posted: 01 Dec 2019, 08:51
by mpolet
Thanks!

Had exactly the same; the wemos itself was alive for 8 days but not connecting to my AP. The 'configesp' AP was visible from my laptop though. After rebooting it (via that configesp) it was connecting to my AP again.

I now implemented your script in it, see how it will perform now.

Re: ESPEasy WiFi reconnect Rules

Posted: 01 Dec 2019, 13:19
by TD-er
Maybe also use a more recent build.
A few weeks ago I addressed some logic issues in when to reconnect, when to start the AP etc.

Re: ESPEasy WiFi reconnect Rules

Posted: 04 Jan 2020, 18:57
by Rob Muller
@TDer

i run ESPEasy mostly on sonoff Basics, with 1M Memory.
Upgrading those via OTA using the two step process has been less than successful for me, requiring me to dig them up and reflash them manually.
So i decided to pick a somewhat stable release and stick with that, and dealing with he issues that i encounter. The power failure issue was the only major one, prompting me to publish the solution i crafted.

thanks for investing your time into ESPEasy

Re: ESPEasy WiFi reconnect Rules

Posted: 05 Jan 2020, 01:29
by TD-er
One of the more recent newly added features in the core lib is to allow to flash compressed images.
I have not yet tested it myself, but my hope is that it will make 1M updates less difficult.

So let's hope it will indeed be easier to perform OTA updates in the future.