Rules don´t work if wifi not present

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
User avatar
chromo23
Normal user
Posts: 821
Joined: 10 Sep 2020, 16:02
Location: germany

Rules don´t work if wifi not present

#1 Post by chromo23 » 15 May 2021, 15:44

I experienced it twice now that my rules doesn´t work when there is no wifi present.
Unfortunately there is no log i can provide since i had no equipment with me to get one.
E.g.
I made an automated chicken coop door for a friend. A button to open and close manually and a ldr for automatic mode.
So i tested it at home for a while and it worked perfectly.
Then i added a fallback ssid in case the internet at the friends place is strong enough to reach the esp. Otherwise i would configured it in ap mode. (release: mega-20210503)
So i brought it to the friend and installed it. and it did not work. It seemed, that the rules are beeing simply ignored. I also got no AP and the Wifi there was to weak. (powercycling did not work)
So i had to uninstall the electronics and bring it closer to the Router. And then it connected and everything worked as expected.
Even when i brought it back to its place it it worked and switched into AP mode.
I am pretty sure i had this once with the previous release to.
What could this be? And how to circumvent this issue?

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

Re: Rules don´t work if wifi not present

#2 Post by TD-er » 15 May 2021, 17:15

That should not happen.
The only thing I can imagine is that you base your rules on a system time and as long as the node does not have a time set, the clock events may not occur.

I do have planned to add support for an RTC timer IC soon, so I guess that may be your fix here.

To test this hypothesis, I guess you could set the time in the rules on system#boot via a command.
Just to some time, which makes it easy for you to test if this is the true cause here.

User avatar
chromo23
Normal user
Posts: 821
Joined: 10 Sep 2020, 16:02
Location: germany

Re: Rules don´t work if wifi not present

#3 Post by chromo23 » 15 May 2021, 17:26

I don´t use the time at any point nor is ntp activated...

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

Re: Rules don´t work if wifi not present

#4 Post by TD-er » 15 May 2021, 17:31

Can you then see if the node maybe reboots (for whatever reason. should also not happen) before the rules can be executed?
Do you have some example part (or complete) of the rules?

User avatar
chromo23
Normal user
Posts: 821
Joined: 10 Sep 2020, 16:02
Location: germany

Re: Rules don´t work if wifi not present

#5 Post by chromo23 » 15 May 2021, 17:33

but i do remember now, that the relay worked but the timing was not correct..
so if the door opens the relay is switching for x milliseconds on..

...but it switched for several seconds. in a way it was totally not expected.

to bad i have no log of it... :(

maybe i build a test setup for recreating the error

User avatar
chromo23
Normal user
Posts: 821
Joined: 10 Sep 2020, 16:02
Location: germany

Re: Rules don´t work if wifi not present

#6 Post by chromo23 » 15 May 2021, 17:35

Code: Select all

On System#Boot do
TimerSet,4,10
let,3,1
endon

On licht#Analog do
if [licht#Analog] >600 //300
  if [var#2]=0
    Let,2,1
    event,testauf
  endif
elseif [licht#Analog] <500 //240
  if [var#2]=1
    Let,2,0
    event,testauf
  endif
endif
endon


on auf do
gpio,2,0
gpio,0,1
taskvalueset,5,1,1
TimerSet_ms,1,3500
endon

on zu do
gpio,0,0
gpio,2,1
taskvalueset,5,1,0
TimerSet_ms,1,3500
endon

On Rules#Timer=1 do
 if [var#1]=1
let,1,0
else
let,1,1
endif
gpio,2,1
gpio,0,1
let,3,1
endon

On Rules#Timer=4 do
SendToHTTP api.thingspeak.com,80,/update?api_key=******&field7=[licht#Analog]&field8=[aufzu#Dummy]
TimerSet,4,300
endon

On testauf do
 if [var#2]=1
TimerSet,2,600
TimerSet,3,0
 elseif [var#2]=0
TimerSet,3,600
TimerSet,2,0
endif
endon

On Rules#Timer=2 do
if [var#2]=1 and [aufzu#Dummy]=0
event,auf
endif
endon

On Rules#Timer=3 do
if [var#2]=0 and [aufzu#Dummy]=1
event,zu
endif
endon


on Button#State=1 do
   if [var#1]=1 and [var#3]=1
event,auf
let,3,0
elseif [var#1]=0 and [var#3]=1
event,zu
let,3,0
endif
endon

User avatar
chromo23
Normal user
Posts: 821
Joined: 10 Sep 2020, 16:02
Location: germany

Re: Rules don´t work if wifi not present

#7 Post by chromo23 » 15 May 2021, 17:42

TD-er wrote: 15 May 2021, 17:31 Can you then see if the node maybe reboots (for whatever reason. should also not happen) before the rules can be executed?
no i couldn´t when it wasn´t connected to anything and before and after that there where no unexpected reboots.
Powersource is fine and as i said i tested it for quite a while before moving....

the thing in common with the last project where it happend was the moving the esp to another place with the fallback ssid entered (for the wifi at its destination). So i had this feeling, that this might be an issue...

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

Re: Rules don´t work if wifi not present

#8 Post by TD-er » 15 May 2021, 17:54

chromo23 wrote: 15 May 2021, 17:42 [...]
Powersource is fine and as i said i tested it for quite a while before moving....
[...]
Don't underestimate my powers in making bugs... It is not always the power source, sometimes it is just the source written by the powers-that-be ;)

User avatar
chromo23
Normal user
Posts: 821
Joined: 10 Sep 2020, 16:02
Location: germany

Re: Rules don´t work if wifi not present

#9 Post by chromo23 » 15 May 2021, 17:59

Don't underestimate my powers in making bugs... It is not always the power source, sometimes it is just the source written by the powers-that-be ;)

:lol:

User avatar
Ath
Normal user
Posts: 3417
Joined: 10 Jun 2018, 12:06
Location: NL

Re: Rules don´t work if wifi not present

#10 Post by Ath » 15 May 2021, 20:06

In timer 4 eventhandler you are using SendToHTTP, isn't that causing issues, like blocking time-outs or watchdog reboots, when WiFi is down/unavailable?
/Ton (PayPal.me)

User avatar
chromo23
Normal user
Posts: 821
Joined: 10 Sep 2020, 16:02
Location: germany

Re: Rules don´t work if wifi not present

#11 Post by chromo23 » 15 May 2021, 20:20

Ath wrote: 15 May 2021, 20:06 In timer 4 eventhandler you are using SendToHTTP, isn't that causing issues, like blocking time-outs or watchdog reboots, when WiFi is down/unavailable?
Do you think this blocks everything when not able to finish....hmmmm... I'll test this but i find it unlikely..

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

Re: Rules don´t work if wifi not present

#12 Post by TD-er » 15 May 2021, 20:59

Ath wrote: 15 May 2021, 20:06 In timer 4 eventhandler you are using SendToHTTP, isn't that causing issues, like blocking time-outs or watchdog reboots, when WiFi is down/unavailable?
It should test for WiFi connected.

User avatar
chromo23
Normal user
Posts: 821
Joined: 10 Sep 2020, 16:02
Location: germany

Re: Rules don´t work if wifi not present

#13 Post by chromo23 » 24 May 2021, 14:28

And it happend again.... this time i had my serial monitor attached.
I was working at a place with weak wifi and realized, that with the loss of the connection the esp did not repond anymore to inputs nor worked the rules.
How do i attach the serial log since it is to big to post?

Here is the rule:

Code: Select all

on rotary#Counter do
if [rotary#Counter] > [count#Value] and [count#Dummy] < 30
Taskvalueset,6,1,[count#Dummy]+0.5
elseif [rotary#Counter] < [count#Value] and [count#Dummy] > 10
Taskvalueset,6,1,[count#Dummy]-0.5
endif
if [count#Dummy] < 10       
[display2].7dtext," [count#Dummy]"
elseif [count#Dummy] > 9 and [count#Dummy] < 100       
[display2].7dtext,"[count#Dummy]"
elseif [count#Dummy] > 99
[display2].7dtext,"[count#Dummy]"
endif
Taskvalueset,6,2,[rotary#Counter]
endon

on licht#Analog do
Let,6,[sensor#Temperature]*10
Let,7,[int#6]-[sensor#Temperature#F]*10
 if [var#7] < 5
       [display2].7dtext," [sensor#Temperature#F]^"
      else
       [display2].7dtext," [sensor#Temperature#F]!"
      endif
endon

on button#State=0 do
Taskvalueset,6,1,0      
[display2].7dtext,"  [count#Dummy]"
endon

on licht#Analog do
if [licht#Analog] >300
[display1].7db,15
[display2].7db,10
elseif [licht#Analog] >70 and [licht#Analog] <=250
[display1].7db,10
[display2].7db,6
elseif [licht#Analog] >= 10 and [licht#Analog] <=60
[display1].7db,0
[display2].7db,0
elseif [licht#Analog] <5 
[display1].7doff
[display2].7doff
endif
endon
here the device overview:
Bildschirmfoto 2021-05-24 um 14.26.11.png
Bildschirmfoto 2021-05-24 um 14.26.11.png (290.55 KiB) Viewed 7817 times

the rest is standard. no special config

EDIT: just disabled task nr.12 and removed it from the rules to rule that out...
EDIT2: disabled ntp to rule this out too.... and as log as the wifi scan is in progress nothing works

User avatar
chromo23
Normal user
Posts: 821
Joined: 10 Sep 2020, 16:02
Location: germany

Re: Rules don´t work if wifi not present

#14 Post by chromo23 » 24 May 2021, 14:50

I am not 100% sure right now but it seems, that disabling "Periodical Scan WiFi" solve the issue....

User avatar
Ath
Normal user
Posts: 3417
Joined: 10 Jun 2018, 12:06
Location: NL

Re: Rules don´t work if wifi not present

#15 Post by Ath » 24 May 2021, 15:10

You can attach such big log as an attachment.

You have quite complex code to fill the value nicely on the display:

Code: Select all

 if [count#Dummy] < 10       
  [display2].7dtext," [count#Dummy]"
 elseif [count#Dummy] > 9 and [count#Dummy] < 100       
  [display2].7dtext,"[count#Dummy]"
 elseif [count#Dummy] > 99
  [display2].7dtext,"[count#Dummy]"
 endif
Instead of that you can use the formatting features in the replacement of [task#variable(#formatting(#justification))], so your code could be replaced by this:

Code: Select all

 [display2].7dtext,"[count#Dummy#d3]"
/Ton (PayPal.me)

User avatar
chromo23
Normal user
Posts: 821
Joined: 10 Sep 2020, 16:02
Location: germany

Re: Rules don´t work if wifi not present

#16 Post by chromo23 » 24 May 2021, 16:14

Ath wrote: 24 May 2021, 15:10 You can attach such big log as an attachment.
Wich format it has to be. I tried a simple txt file but it is not supported.
You have quite complex code to fill the value nicely on the display:

Code: Select all

 if [count#Dummy] < 10       
  [display2].7dtext," [count#Dummy]"
 elseif [count#Dummy] > 9 and [count#Dummy] < 100       
  [display2].7dtext,"[count#Dummy]"
 elseif [count#Dummy] > 99
  [display2].7dtext,"[count#Dummy]"
 endif
Instead of that you can use the formatting features in the replacement of [task#variable(#formatting(#justification))], so your code could be replaced by this:

Code: Select all

 [display2].7dtext,"[count#Dummy#d3]"
Thank you for that! :)
Last edited by chromo23 on 24 May 2021, 16:26, edited 1 time in total.

User avatar
chromo23
Normal user
Posts: 821
Joined: 10 Sep 2020, 16:02
Location: germany

Re: Rules don´t work if wifi not present

#17 Post by chromo23 » 24 May 2021, 16:26

Disabling Periodical Scan WiFi didn’t solve it. :(

User avatar
Ath
Normal user
Posts: 3417
Joined: 10 Jun 2018, 12:06
Location: NL

Re: Rules don´t work if wifi not present

#18 Post by Ath » 24 May 2021, 17:05

chromo23 wrote: 24 May 2021, 16:14 Wich format it has to be. I tried a simple txt file but it is not supported.
You can zip that .txt file, you should be able to attach that.
/Ton (PayPal.me)

User avatar
chromo23
Normal user
Posts: 821
Joined: 10 Sep 2020, 16:02
Location: germany

Re: Rules don´t work if wifi not present

#19 Post by chromo23 » 24 May 2021, 17:24

Ahhh... here you go:
serial.txt.zip
(17.51 KiB) Downloaded 168 times
And btw...how would you do this:

Code: Select all

[display2].7dtext,"[count#Dummy#d3#F]^"
:shock:
Edit: probably like this

Code: Select all

Let,1,[count#Dummy#F]
[display2].7dtext,"[var#1#d3]^"
:D

Here you can see the device in action:
IMG_8788.GIF
IMG_8788.GIF (2.31 MiB) Viewed 7778 times

User avatar
Ath
Normal user
Posts: 3417
Joined: 10 Jun 2018, 12:06
Location: NL

Re: Rules don´t work if wifi not present

#20 Post by Ath » 24 May 2021, 18:44

chromo23 wrote: 24 May 2021, 17:24 And btw...how would you do this:

Code: Select all

[display2].7dtext,"[count#Dummy#d3#F]^"
:shock:
Edit: probably like this

Code: Select all

Let,1,[count#Dummy#F]
[display2].7dtext,"[var#1#d3]^"
:D
What's that #F supposed to mean? It is not a supported formatting or justification character, AFAIK.
/Ton (PayPal.me)


User avatar
Ath
Normal user
Posts: 3417
Joined: 10 Jun 2018, 12:06
Location: NL

Re: Rules don´t work if wifi not present

#22 Post by Ath » 24 May 2021, 19:08

Ah, yes, because of the layout it is a bit obscured.

The way you have used is the only way to achieve that, as you can only use 1 formatting option in such statement.
/Ton (PayPal.me)

Post Reply

Who is online

Users browsing this forum: No registered users and 27 guests