ESPEasy WiFi reconnect Rules

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
Rob Muller
Normal user
Posts: 11
Joined: 05 Nov 2018, 17:02

ESPEasy WiFi reconnect Rules

#1 Post by Rob Muller » 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
Thanks for reading,
regards,

Rob

riker1
Normal user
Posts: 344
Joined: 26 Dec 2017, 18:02

Re: ESPEasy WiFi reconnect Rules

#2 Post by riker1 » 08 Apr 2019, 14:25

Hi

thanks

Was wondering is a

Code: Select all

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

Rob Muller
Normal user
Posts: 11
Joined: 05 Nov 2018, 17:02

Re: ESPEasy WiFi reconnect Rules

#3 Post by Rob Muller » 08 Apr 2019, 19:17

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
Thanks for reading,
regards,

Rob

riker1
Normal user
Posts: 344
Joined: 26 Dec 2017, 18:02

Re: ESPEasy WiFi reconnect Rules

#4 Post by riker1 » 09 Apr 2019, 07:53

thanks Rob

1CM69
Normal user
Posts: 18
Joined: 20 Mar 2019, 19:31

Re: ESPEasy WiFi reconnect Rules

#5 Post by 1CM69 » 09 Apr 2019, 13:29

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

hoeby
Normal user
Posts: 33
Joined: 19 Sep 2018, 21:03

Re: ESPEasy WiFi reconnect Rules

#6 Post by hoeby » 04 Aug 2019, 21:21

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?

User avatar
ThomasB
Normal user
Posts: 1064
Joined: 17 Jun 2018, 20:41
Location: USA

Re: ESPEasy WiFi reconnect Rules

#7 Post by ThomasB » 04 Aug 2019, 22:05

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

mpolet
New user
Posts: 1
Joined: 22 Feb 2016, 11:49

Re: ESPEasy WiFi reconnect Rules

#8 Post by mpolet » 01 Dec 2019, 08:51

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.

TD-er
Core team member
Posts: 8643
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: ESPEasy WiFi reconnect Rules

#9 Post by TD-er » 01 Dec 2019, 13:19

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.

Rob Muller
Normal user
Posts: 11
Joined: 05 Nov 2018, 17:02

Re: ESPEasy WiFi reconnect Rules

#10 Post by Rob Muller » 04 Jan 2020, 18:57

@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
Thanks for reading,
regards,

Rob

TD-er
Core team member
Posts: 8643
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: ESPEasy WiFi reconnect Rules

#11 Post by TD-er » 05 Jan 2020, 01:29

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.

Post Reply

Who is online

Users browsing this forum: Google [Bot] and 22 guests