error if and ife
Moderators: grovkillen, Stuntteam, TD-er
error if and ife
hello, on esp8266 i have do a error , i have put ife instead if
now , i've no access
is there any way to get the access back?
thank you
now , i've no access
is there any way to get the access back?
thank you
Re: error if and ife
Where did you put that 'ife'?
If that's in rules, it should be ignored, as that's an unknown command, it would be strange if that could block access to the ESP.
Do you have access to the serial log?
If that's in rules, it should be ignored, as that's an unknown command, it would be strange if that could block access to the ESP.
Do you have access to the serial log?
/Ton (PayPal.me)
Re: error if and ife
yes in the rules , i've no access at serial log
Re: error if and ife
What is happening if the lines after the wrong ife statement are executed?
In what eventhandler is that code?, for a specific sensor, every minute using the on Clock#time=all,**:** do, or a system event like on system#boot do ?
In what eventhandler is that code?, for a specific sensor, every minute using the on Clock#time=all,**:** do, or a system event like on system#boot do ?
/Ton (PayPal.me)
Re: error if and ife
When the ESP may enter some kind of "boot loop" and thus never really completes a boot, it will start disabling tasks one by one.
Then controllers and as last resort disable all tasks and all controllers and the rules.
So if it has entered such a boot loop, it should after some time become available again with some parts disabled.
N.B. this will only be disabled in memory, so unless something is being saved, the process will be repeated the next time the ESP will reboot.
Then controllers and as last resort disable all tasks and all controllers and the rules.
So if it has entered such a boot loop, it should after some time become available again with some parts disabled.
N.B. this will only be disabled in memory, so unless something is being saved, the process will be repeated the next time the ESP will reboot.
Re: error if and ife
in Clock#time=all,**:** do
it reboot , reboot .....
it reboot , reboot .....
Re: error if and ife
Ah that's indeed something that won't be detected by that algorithm.
Do you know what it tries to do to make it crash?
Tweaking the boot loop detection is for sure something I need to do, but maybe it is better to actually fix the crash reason
Do you know what it tries to do to make it crash?
Tweaking the boot loop detection is for sure something I need to do, but maybe it is better to actually fix the crash reason

Re: error if and ife
ok , the algorithm is good , it took a long time , I was able to access it and correct the error
thank you very much
thank you very much
Re: error if and ife
Ah, great, the safety measures work as intended.
Can you share the Rules code that caused this boot loop? (if you don't want to publish here, a PM is also fine, for us to learn, and possibly prevent future issues)
Can you share the Rules code that caused this boot loop? (if you don't want to publish here, a PM is also fine, for us to learn, and possibly prevent future issues)
/Ton (PayPal.me)
Re: error if and ife
no problem :
origine :
modif :
origine :
Code: Select all
On System#Boot Do
LoopTimerSet,1,900
Endon
On Rules#Timer=1 Do
If [Var#1]=1
GPIOToggle,14
Else
GPIO,14,1
Endon
On Clock#Time=All,**:** Do
If %syssec_d% > 36000 and %syssec_d% < 68400 //de 10h a 19h
Let,1,0 // 1 = pompe bassin en marche
Else
Let,1,0
Endif
Code: Select all
On System#Boot Do
LoopTimerSet,1,900
Endon
On Rules#Timer=1 Do
If [Var#1]=1
GPIOToggle,14
Else
GPIO,14,1
Endon
On Clock#Time=All,**:** Do
Ife %syssec_d% > 36000 and %syssec_d% < 68400 //de 10h a 19h
Let,1,0 // 1 = pompe bassin en marche
Else
Let,1,0
Endif
Re: error if and ife
There are other issues too...
Missing an "endif" before the "endon"
Missing an "endon"
Also this block doesn't "do" anything as both set the variable to the same value.
Code: Select all
On Rules#Timer=1 Do
If [Var#1]=1
GPIOToggle,14
Else
GPIO,14,1
Endon
Code: Select all
On Clock#Time=All,**:** Do
If %syssec_d% > 36000 and %syssec_d% < 68400 //de 10h a 19h
Let,1,0 // 1 = pompe bassin en marche
Else
Let,1,0
Endif
Also this block doesn't "do" anything as both set the variable to the same value.
Re: error if and ife
yes , hi have missing endif , but it works !!
for this :
I had not put all , i set the variable to the same value , because i stop with 0 or start with 1
this is what I found the best to not put the relay "on" when I don't need it
that's why I had put " ife " instead of "if"
is there any other solution not to run a loop ?
without putting "//" on each line?
Code: Select all
On Rules#Timer=1 Do
If [Var#1]=1
GPIOToggle,14
Else
GPIO,14,1
endif
Endon
Code: Select all
On Clock#Time=All,**:** Do
If %syssec_d% > 36000 and %syssec_d% < 68400 //de 10h a 19h
Let,1,0 // 1 = pump start 0 =pump stop
Else
Let,1,0
Endif
If %syssec_d% > 3600 and %syssec_d% < 28800//de 1h a 8h chaudiere
gpio,4,0
Else
gpio,4,1
Endif
//relais 2 pin 12 fontaine
// if %syssec_d% > 39600 and %syssec_d% < 72000 //de 11h a 20h
// gpio,12,0
// else
// gpio,12,1
// endif
//relais 1 pin 13 sonnette
if %syssec_d% > 28800 and %syssec_d% < 72000 //de 7h a 20h
gpio,13,0
//Publish,actions_bouton,sonnette_status#1
else
gpio,13,1
//Publish,actions_bouton,sonnette_status#2
endif
if [rel2#Value1]=3
gpio,16,0
else
gpio,16,1
endif
endon
this is what I found the best to not put the relay "on" when I don't need it
that's why I had put " ife " instead of "if"
is there any other solution not to run a loop ?
without putting "//" on each line?
Re: error if and ife
There is. You could add a variable check to all your if statements that need to be "switched" and declare this variable somewhere.
Code: Select all
On System#Boot Do
Let,99,1 //change this to 0 to deactivate your statement
Endon
On Clock#Time=All,**:** Do
If [var#99]=1 and %syssec_d% > 36000 and %syssec_d% < 68400 //de 10h a 19h
Let,1,0 // 1 = pump start 0 =pump stop
Else
Let,1,0
Endif
Endon
Last edited by chromo23 on 21 Nov 2022, 10:06, edited 2 times in total.
Re: error if and ife
yes good idea
Re: error if and ife
Disadvantage of that it will always execute the "else" part of the code, that may not be what you want...
Alternative would be to add an extra "if" around the code that is to be excluded.
Alternative would be to add an extra "if" around the code that is to be excluded.
/Ton (PayPal.me)
Re: error if and ife
?? ,example , because i do google translate , my english is very bad
Re: error if and ife
True, but i thought thats what he wanted....
Code: Select all
On Clock#Time=All,**:** Do
If [var#99]=1
If %syssec_d% > 36000 and %syssec_d% < 68400 //de 10h a 19h
Let,1,0 // 1 = pump start 0 =pump stop
Else
Let,1,0
Endif
Endif
Endon
Re: error if and ife
hi , thank you , i've redone my rules for 8 relay
where let variable if 0 = stop , 1 = forced work , automatique work
it's good for you ??
where let variable if 0 = stop , 1 = forced work , automatique work
it's good for you ??
Code: Select all
// relais
//1=13,2=12,3=14,4=16,5=4,6=5,7=3,8=1
Let,1,0
Let,2,0
Let,11,0 // relais 1 > 0 = arret , 1 = marche force , 2 = marche auto
Let,12,0 // relais 2 > 0 = arret , 1 = marche force , 2 = marche auto
Let,13,0 // relais 3 > 0 = arret , 1 = marche force , 2 = marche auto
Let,14,0 // relais 4 > 0 = arret , 1 = marche force , 2 = marche auto
Let,15,0 // relais 5 > 0 = arret , 1 = marche force , 2 = marche auto
Let,16,0 // relais 6 > 0 = arret , 1 = marche force , 2 = marche auto
Let,17,0 // relais 7 > 0 = arret , 1 = marche force , 2 = marche auto
Let,18,0 // relais 8 > 0 = arret , 1 = marche force , 2 = marche auto
On System#Boot Do
LoopTimerSet,1,900 //timer 15 minutes
Endon
On Rules#Timer=1 Do
If [Var#1]=1 // actif suivant heures
GPIOToggle,14 //marche arret 15 minutes
Else
GPIO,14,1
endif
Endon
On Clock#Time=All,**:** Do // boucle suivant horaires
if [Var#11]=2 // relais 1 sonnette
if %syssec_d% > 28800 and %syssec_d% < 72000 //de 7h a 20h
gpio,13,0
else
gpio,13,1
endif
endif
if [Var#12]=2 // relais 2 fontaine auto
if %syssec_d% > 39600 and %syssec_d% < 72000 //de 11h a 20h
gpio,12,0
else
gpio,12,1
endif
endif
if [Var#13]=2 // relais 3 en auto pompe bassin
If %syssec_d% > 36000 and %syssec_d% < 68400 //de 10h a 19h
Let,1,1
Else
Let,1,0
Endif
endif
if [Var#15]=2 //relais 5 en auto chaudiere
If %syssec_d% > 3600 and %syssec_d% < 28800//de 1h a 8h chaudiere
gpio,4,0
Else
gpio,4,1
endif
Endif
Endon
if [Var#11]=0 //relais 1 stop
gpio,13,1
endif
if [Var#11]=1 //relais 1 marche force
gpio,13,0
endif
if [Var#12]=0 //relais 2 stop
gpio,12,1
endif
if [Var#12]=1 //relais 2 marche force
gpio,12,0
endif
if [Var#13]=0 //relais 3 stop
gpio,14,1
endif
if [Var#13]=1 //relais 3 marche force
gpio,14,0
endif
if [Var#14]=0 //relais 4 stop
gpio,16,1
endif
if [Var#14]=1 //relais 4 marche force
gpio,16,0
endif
if [Var#15]=0 //relais 5 stop
gpio,4,1
endif
if [Var#15]=1 //relais 5 marche force
gpio,4,0
endif
if [Var#16]=0 //relais 6 stop
gpio,5,1
endif
if [Var#16]=1 //relais 6 marche force
gpio,5,0
endif
if [Var#17]=0 //relais 7 stop
gpio,3,1
endif
if [Var#17]=1 //relais 7 marche force
gpio,3,0
endif
if [Var#18]=0 //relais 8 stop
gpio,1,1
endif
if [Var#18]=1 //relais 8 marche force
gpio,1,0
endif
Re: error if and ife
You have a lot of these:
I think that can be shorter, and thus faster to process like this:
Also, this part might not always work as intended:
The GPIOToggle will do exactly that, toggle the state from 1 to 0 or from 0 to 1.
What if it is set to 0 elsewhere, then it would turn off when you wouldn't expect it to, so might be better to change that to gpio,14,0
Code: Select all
if [Var#11]=0 //relais 1 stop
gpio,13,1
endif
if [Var#11]=1 //relais 1 marche force
gpio,13,0
endif
Code: Select all
if [Var#11]!=2 // not auto
gpio,13,![Var#11] // Inverted state
endif
Code: Select all
On Rules#Timer=1 Do
If [Var#1]=1 // actif suivant heures
GPIOToggle,14 //marche arret 15 minutes
Else
GPIO,14,1
endif
Endon
What if it is set to 0 elsewhere, then it would turn off when you wouldn't expect it to, so might be better to change that to gpio,14,0
/Ton (PayPal.me)
Re: error if and ife
Not quite.. the last part is outside a ruleblock (on-do-endon)
that will lead to issues..
try this:
Edit: maybe ignore this code. It works only once a minute... so when changing var#11 the change will physically appear worst case 1min after.
Edit: Now i understand your code.. you declare all the values in rules at the beginning.. (and also there you need a ruleblock!) so maybe it doesn’t matter iff the change happens 1min later?
that will lead to issues..
try this:
Code: Select all
On Clock#Time=All,**:** Do // boucle suivant horaires
if [Var#11]=2 and %syssec_d% > 28800 and %syssec_d% < 72000 //auto mode
gpio,13,0
elseif [Var#11]=1 //always on
gpio,13,0
else //always off if var#11 anything is else than 2 or 1 or time is outside you defined area
gpio,13,1
endif
Endon
Edit: Now i understand your code.. you declare all the values in rules at the beginning.. (and also there you need a ruleblock!) so maybe it doesn’t matter iff the change happens 1min later?
Re: error if and ife
ok , i understand
why 1min later?
why 1min later?
Re: error if and ife
This could be it:
Code: Select all
On System#Boot Do
LoopTimerSet,1,900 //timer 15 minutes
//declare the variables ar boot!!!
// relais
//1=13,2=12,3=14,4=16,5=4,6=5,7=3,8=1
Let,1,0
Let,2,0
Let,11,0 // relais 1 > 0 = arret , 1 = marche force , 2 = marche auto
Let,12,0 // relais 2 > 0 = arret , 1 = marche force , 2 = marche auto
Let,13,0 // relais 3 > 0 = arret , 1 = marche force , 2 = marche auto
Let,14,0 // relais 4 > 0 = arret , 1 = marche force , 2 = marche auto
Let,15,0 // relais 5 > 0 = arret , 1 = marche force , 2 = marche auto
Let,16,0 // relais 6 > 0 = arret , 1 = marche force , 2 = marche auto
Let,17,0 // relais 7 > 0 = arret , 1 = marche force , 2 = marche auto
Let,18,0 // relais 8 > 0 = arret , 1 = marche force , 2 = marche auto
Endon
On Rules#Timer=1 Do
If [Var#1]=1 // actif suivant heures
GPIOToggle,14 //marche arret 15 minutes
Else
GPIO,14,1
Endif
Endon
On Clock#Time=All,**:** Do // boucle suivant horaires
If [Var#11]=2 and %syssec_d% > 28800 and %syssec_d% < 72000 //auto mode
GPIO,13,0
Elseif [Var#11]=1 //always on
GPIO,13,0
Else //always off if var#11 anything is else than 2 or 1 or time is outside you defined area
GPIO,13,1
Endif
If [Var#12]=2 and %syssec_d% > 39600 and %syssec_d% < 72000 //de 11h a 20h
GPIO,12,0
Elseif [Var#12]=1
GPIO,12,0
Else
GPIO,12,1
Endif
If [Var#13]=2 and %syssec_d% > 36000 and %syssec_d% < 68400 //de 10h a 19h
GPIO,1,0
Elseif [Var#13]=1
GPIO,1,0
Else
GPIO,1,1
Endif
If [Var#15]=2 and %syssec_d% > 3600 and %syssec_d% < 28800//de 1h a 8h chaudiere
GPIO,4,0
Elseif [Var#15]=1
GPIO,4,0
Else
GPIO,4,1
Endif
Endon
Re: error if and ife
yes ok , but if , by example , i want start relay 6 ( gpio 5 ) with Let variable without time ?,
Re: error if and ife
Code: Select all
On System#Boot Do
Let,16,1 // relais 6 > 0 = arret , 1 = marche force , 2 = marche auto
Endon
On Clock#Time=All,**:** Do // boucle suivant horaires
If [Var#16]=2 and %syssec_d% > 28800 and %syssec_d% < 72000 //auto mode
GPIO,5,0
Elseif [Var#16]=1 //always on
GPIO,5,0
Else //always off if var#11 anything is else than 2 or 1 or time is outside you defined area
GPIO,5,1
Endif
Endon
Re: error if and ife
because this:
Code: Select all
On Clock#Time=All,**:** Do // boucle suivant horaires
Re: error if and ife
Maybe it is also good to explain as good as possible what you want to do. This makes helping you a lot easier. (you can use pseudo code if you want)
Re: error if and ife
ok for 1 minute
but you lost me with toggle
i want start and stop gpio 14 every 15 minutes of 10h am to 7h pm
the code work :
but you lost me with toggle
i want start and stop gpio 14 every 15 minutes of 10h am to 7h pm
the code work :
Code: Select all
On System#Boot Do
LoopTimerSet,1,900
Endon
On Rules#Timer=1 Do
If [Var#1]=1
GPIOToggle,14
Else
GPIO,14,1
Endon
On Clock#Time=All,**:** Do
If %syssec_d% > 36000 and %syssec_d% < 68400 //de 10h a 19h
Let,1,0 // 1 = pompe bassin en marche
Else
Let,1,0
Endif[
endon/code]
Re: error if and ife
Do not forget to close a rulesblock or if-statements!!!!!!
Code: Select all
On Rules#Timer=1 Do
If [Var#1]=1
GPIOToggle,14
Else
GPIO,14,1
ENDIF //important!!!!!!
Endon
Re: error if and ife
ok ,sorry , I had modified in my code, but not in the paste
Re: error if and ife
And this can not work:
because after one minute var#1 will be 0 and this will never happen:
Code: Select all
On Rules#Timer=1 Do
If [Var#1]=1
GPIOToggle,14
Else
GPIO,14,1
Endif
Endon
On Clock#Time=All,**:** Do
If %syssec_d% > 36000 and %syssec_d% < 68400 //de 10h a 19h
Let,1,0 // 1 = pompe bassin en marche
Else
Let,1,0
Endif
Endon
Code: Select all
If [Var#1]=1
GPIOToggle,14
Re: error if and ife
sorry , another bad paste
Code: Select all
On Rules#Timer=1 Do
If [Var#1]=1
GPIOToggle,14
Else
GPIO,14,1
Endif
Endon
On Clock#Time=All,**:** Do
If %syssec_d% > 36000 and %syssec_d% < 68400 //de 10h a 19h
Let,1,1 // 1 = pompe bassin en marche
Else
Let,1,0
Endif
Endon
Re: error if and ife
with the toggle code , this ( with new code ), it's good ?
Code: Select all
if [Var#13]=2 and %syssec_d% > 36000 and %syssec_d% < 68400 //de 10h a 19h
Let,1,1
elseif [Var#12]=1
gpio,14,0
Else
Let,1,0
Endif
endif
Re: error if and ife
You have one endif too many in your piece of code:
N.B. have not looked at what you're trying to do here, only looked at the syntax and matching if/endif
Code: Select all
if [Var#13]=2 and %syssec_d% > 36000 and %syssec_d% < 68400 //de 10h a 19h
Let,1,1
elseif [Var#12]=1
gpio,14,0
Else
Let,1,0
Endif
Re: error if and ife
This will work....bledad wrote: ↑21 Nov 2022, 15:56 sorry , another bad paste
Code: Select all
On Rules#Timer=1 Do If [Var#1]=1 GPIOToggle,14 Else GPIO,14,1 Endif Endon On Clock#Time=All,**:** Do If %syssec_d% > 36000 and %syssec_d% < 68400 //de 10h a 19h Let,1,1 // 1 = pompe bassin en marche Else Let,1,0 Endif Endon
yes, with some minor changes
Code: Select all
If [Var#13]=2 and %syssec_d% > 36000 and %syssec_d% < 68400 //de 10h a 19h
Let,1,1
Elseif [Var#13]=1 //< i guess this should be var#13 instead of var#12
gpio,14,0
Else
Let,1,0
Endif
Re: error if and ife
yes , than you
you can verifier the final code ?
you can verifier the final code ?
Code: Select all
// relais
//1=13,2=12,3=14,4=16,5=4,6=5,7=3,8=1
Let,1,0
Let,2,0
Let,11,0 // relais 1 > 0 = arret , 1 = marche force , 2 = marche auto sonnette
Let,12,0 // relais 2 > 0 = arret , 1 = marche force , 2 = marche auto fontaine
Let,13,0 // relais 3 > 0 = arret , 1 = marche force , 2 = marche auto bassin
Let,14,0 // relais 4 > 0 = arret , 1 = marche force , 2 = marche auto
Let,15,0 // relais 5 > 0 = arret , 1 = marche force , 2 = marche auto chaudiere
Let,16,0 // relais 6 > 0 = arret , 1 = marche force , 2 = marche auto
Let,17,0 // relais 7 > 0 = arret , 1 = marche force , 2 = marche auto
Let,18,0 // relais 8 > 0 = arret , 1 = marche force , 2 = marche auto
On System#Boot Do
LoopTimerSet,1,900 //timer 15 minutes
Endon
On Rules#Timer=1 Do
If [Var#1]=1 // actif suivant heures
GPIOToggle,14 //marche arret 15 minutes
Else
GPIO,14,1
endif
Endon
On Clock#Time=All,**:** Do // boucle suivant horaires
// relais 1 sonnette
if [Var#11]=2 and %syssec_d% > 28800 and %syssec_d% < 72000 //auto mode
gpio,13,0
elseif [Var#11]=1 //always on
gpio,13,0
else //always off if var#11 anything else than 2 or 1
gpio,13,1
endif
//relais 2 fontaine
if [Var#12]=2 and %syssec_d% > 39600 and %syssec_d% < 72000 //de 11h a 20h
gpio,12,0
elseif [Var#12]=1
gpio,12,0
else
gpio,12,1
endif
//relais 3 pompe bassin
if [Var#13]=2 and %syssec_d% > 36000 and %syssec_d% < 68400 //de 10h a 19h
Let,1,1
elseif [Var#13]=1
gpio,14,0
Else
gpio,14,1
Endif
//relais 4
if [Var#14]=2 and %syssec_d% > 3600 and %syssec_d% < 28800//
gpio,16,0
elseif [Var#14]=1
gpio,16,0
Else
gpio,16,1
endif
//relais 5 chaudiere ete hiver
if [Var#15]=2 and %syssec_d% > 3600 and %syssec_d% < 28800//de 1h a 8h chaudiere
gpio,4,0
elseif [Var#15]=1
gpio,4,0
Else
gpio,4,1
endif
//relais 6
if [Var#16]=2 and %syssec_d% > 3600 and %syssec_d% < 28800//
gpio,5,0
elseif [Var#16]=1
gpio,5,0
Else
gpio,5,1
endif
//relais 7
if [Var#17]=2 and %syssec_d% > 3600 and %syssec_d% < 28800//
gpio,3,0
elseif [Var#17]=1
gpio,3,0
Else
gpio,3,1
endif
//relais 8
if [Var#18]=2 and %syssec_d% > 3600 and %syssec_d% < 28800//
gpio,1,0
elseif [Var#18]=1
gpio,1,0
Else
gpio,1,1
endif
Endon
Re: error if and ife
Those let calls at the begin will not be used or executed.
Rules act on events, so have to be in blocks like these:
Rules act on events, so have to be in blocks like these:
Code: Select all
on ... do
....
endon
Re: error if and ife
Maybe this is it?
Code: Select all
On System#Boot Do
// relais
//1=13,2=12,3=14,4=16,5=4,6=5,7=3,8=1
Let,1,0
Let,2,0
Let,11,0 // relais 1 > 0 = arret , 1 = marche force , 2 = marche auto sonnette
Let,12,0 // relais 2 > 0 = arret , 1 = marche force , 2 = marche auto fontaine
Let,13,0 // relais 3 > 0 = arret , 1 = marche force , 2 = marche auto bassin
Let,14,0 // relais 4 > 0 = arret , 1 = marche force , 2 = marche auto
Let,15,0 // relais 5 > 0 = arret , 1 = marche force , 2 = marche auto chaudiere
Let,16,0 // relais 6 > 0 = arret , 1 = marche force , 2 = marche auto
Let,17,0 // relais 7 > 0 = arret , 1 = marche force , 2 = marche auto
Let,18,0 // relais 8 > 0 = arret , 1 = marche force , 2 = marche auto
LoopTimerSet,1,900 //timer 15 minutes
Endon
On Rules#Timer=1 Do
If [Var#1]=2
GPIOToggle,14
Elseif [Var#1]=0
GPIO,14,1
Endif
Endon
On Clock#Time=All,**:** Do // boucle suivant horaires
// relais 1 sonnette
if [Var#11]=2 and %syssec_d% > 28800 and %syssec_d% < 72000 //auto mode
gpio,13,0
elseif [Var#11]=1 //always on
gpio,13,0
else //always off if var#11 anything else than 2 or 1
gpio,13,1
endif
//relais 2 fontaine
if [Var#12]=2 and %syssec_d% > 39600 and %syssec_d% < 72000 //de 11h a 20h
gpio,12,0
elseif [Var#12]=1
gpio,12,0
else
gpio,12,1
endif
//relais 3 pompe bassin
If [Var#13]=2 and %syssec_d% > 36000 and %syssec_d% < 68400 //de 10h a 19h
Let,1,2
Elseif [Var#13]=1 //< i guess this should be var#13 instead of var#12
gpio,14,0
Let,1,1
Else
Let,1,0
Endif
//relais 4
if [Var#14]=2 and %syssec_d% > 3600 and %syssec_d% < 28800//
gpio,16,0
elseif [Var#14]=1
gpio,16,0
Else
gpio,16,1
endif
//relais 5 chaudiere ete hiver
if [Var#15]=2 and %syssec_d% > 3600 and %syssec_d% < 28800//de 1h a 8h chaudiere
gpio,4,0
elseif [Var#15]=1
gpio,4,0
Else
gpio,4,1
endif
//relais 6
if [Var#16]=2 and %syssec_d% > 3600 and %syssec_d% < 28800//
gpio,5,0
elseif [Var#16]=1
gpio,5,0
Else
gpio,5,1
endif
//relais 7
if [Var#17]=2 and %syssec_d% > 3600 and %syssec_d% < 28800//
gpio,3,0
elseif [Var#17]=1
gpio,3,0
Else
gpio,3,1
endif
//relais 8
if [Var#18]=2 and %syssec_d% > 3600 and %syssec_d% < 28800//
gpio,1,0
elseif [Var#18]=1
gpio,1,0
Else
gpio,1,1
endif
Endon
Re: error if and ife
I had thought about it , but i will have to reboot at each variable change ?
Re: error if and ife
Thats why it is so helpful, to give the whole picture of what you want to do...
And if you are not good with code you can always tell us with your own words what should happen/ what you want to achieve .
Re: error if and ife
I did format the code a bit more so it is readable with consistent indents:
But it is a bit unclear to me what you want to do here.
How are the variables being set after the unit boots? Some other events?
You can set variables via commands or other events. No need to reboot for each test.
However, I would like to know what you're trying to achieve here.
Code: Select all
On System#Boot Do
// relais
//1=13,2=12,3=14,4=16,5=4,6=5,7=3,8=1
Let,1,0
Let,2,0
Let,11,0 // relais 1 > 0 = arret , 1 = marche force , 2 = marche auto sonnette
Let,12,0 // relais 2 > 0 = arret , 1 = marche force , 2 = marche auto fontaine
Let,13,0 // relais 3 > 0 = arret , 1 = marche force , 2 = marche auto bassin
Let,14,0 // relais 4 > 0 = arret , 1 = marche force , 2 = marche auto
Let,15,0 // relais 5 > 0 = arret , 1 = marche force , 2 = marche auto chaudiere
Let,16,0 // relais 6 > 0 = arret , 1 = marche force , 2 = marche auto
Let,17,0 // relais 7 > 0 = arret , 1 = marche force , 2 = marche auto
Let,18,0 // relais 8 > 0 = arret , 1 = marche force , 2 = marche auto
LoopTimerSet,1,900 //timer 15 minutes
Endon
On Rules#Timer=1 Do
If [Var#1]=2
GPIOToggle,14
Elseif [Var#1]=0
GPIO,14,1
Endif
Endon
On Clock#Time=All,**:** Do // boucle suivant horaires
// relais 1 sonnette
if [Var#11]=2 and %syssec_d% > 28800 and %syssec_d% < 72000 //auto mode
gpio,13,0
elseif [Var#11]=1 //always on
gpio,13,0
else //always off if var#11 anything else than 2 or 1
gpio,13,1
endif
//relais 2 fontaine
if [Var#12]=2 and %syssec_d% > 39600 and %syssec_d% < 72000 //de 11h a 20h
gpio,12,0
elseif [Var#12]=1
gpio,12,0
else
gpio,12,1
endif
//relais 3 pompe bassin
If [Var#13]=2 and %syssec_d% > 36000 and %syssec_d% < 68400 //de 10h a 19h
Let,1,2
Elseif [Var#13]=1
gpio,14,0
Let,1,1
Else
Let,1,0
Endif
//relais 4
if [Var#14]=2 and %syssec_d% > 3600 and %syssec_d% < 28800//
gpio,16,0
elseif [Var#14]=1
gpio,16,0
Else
gpio,16,1
endif
//relais 5 chaudiere ete hiver
if [Var#15]=2 and %syssec_d% > 3600 and %syssec_d% < 28800//de 1h a 8h chaudiere
gpio,4,0
elseif [Var#15]=1
gpio,4,0
Else
gpio,4,1
endif
//relais 6
if [Var#16]=2 and %syssec_d% > 3600 and %syssec_d% < 28800//
gpio,5,0
elseif [Var#16]=1
gpio,5,0
Else
gpio,5,1
endif
//relais 7
if [Var#17]=2 and %syssec_d% > 3600 and %syssec_d% < 28800//
gpio,3,0
elseif [Var#17]=1
gpio,3,0
Else
gpio,3,1
endif
//relais 8
if [Var#18]=2 and %syssec_d% > 3600 and %syssec_d% < 28800//
gpio,1,0
elseif [Var#18]=1
gpio,1,0
Else
gpio,1,1
endif
Endon
How are the variables being set after the unit boots? Some other events?
You can set variables via commands or other events. No need to reboot for each test.
However, I would like to know what you're trying to achieve here.
Re: error if and ife
You can run the command
Code: Select all
event,system#boot
/Ton (PayPal.me)
Re: error if and ife
You could change the code to this:
Code: Select all
On System#Boot Do
Let,1,0
Let,2,0
LoopTimerSet,1,900 //timer 15 minutes
LoopTimerSet,2,5 //timer 5 seconds
Endon
On Rules#Timer=2 Do
// relais
//1=13,2=12,3=14,4=16,5=4,6=5,7=3,8=1
Let,11,0 // relais 1 > 0 = arret , 1 = marche force , 2 = marche auto sonnette
Let,12,0 // relais 2 > 0 = arret , 1 = marche force , 2 = marche auto fontaine
Let,13,0 // relais 3 > 0 = arret , 1 = marche force , 2 = marche auto bassin
Let,14,0 // relais 4 > 0 = arret , 1 = marche force , 2 = marche auto
Let,15,0 // relais 5 > 0 = arret , 1 = marche force , 2 = marche auto chaudiere
Let,16,0 // relais 6 > 0 = arret , 1 = marche force , 2 = marche auto
Let,17,0 // relais 7 > 0 = arret , 1 = marche force , 2 = marche auto
Let,18,0 // relais 8 > 0 = arret , 1 = marche force , 2 = marche auto
Endon
Last edited by chromo23 on 21 Nov 2022, 17:35, edited 1 time in total.
Re: error if and ife
Re: error if and ife
it's my working 8 relay esp8266
be able to modify the action of each relay , ( on , off , on auto with schedule )
be able to modify the action of each relay , ( on , off , on auto with schedule )
Re: error if and ife
So just to be clear, you only want to switch each relais on or off given some time interval?
For example:
- relais 1
- GPIO 13, inverted logic: "0" is "on"
- When: %syssec_d% > 28800 and %syssec_d% < 72000
There also seems to be some variable # 11, which does seem to indicate the following:
- [Var#11]=0 //always off
- [Var#11]=1 //always on
- [Var#11]=2 //Timer mode
That's what I am reading in this rules code:
Is that what you really intend to do?
For example:
- relais 1
- GPIO 13, inverted logic: "0" is "on"
- When: %syssec_d% > 28800 and %syssec_d% < 72000
There also seems to be some variable # 11, which does seem to indicate the following:
- [Var#11]=0 //always off
- [Var#11]=1 //always on
- [Var#11]=2 //Timer mode
That's what I am reading in this rules code:
Code: Select all
// relais 1 sonnette
if [Var#11]=2 and %syssec_d% > 28800 and %syssec_d% < 72000 //auto mode
gpio,13,0
elseif [Var#11]=1 //always on
gpio,13,0
else //always off if var#11 anything else than 2 or 1
gpio,13,1
endif
Re: error if and ife
For example:
- relais 1
- GPIO 13, inverted logic: "0" is "on"
- When: %syssec_d% > 28800 and %syssec_d% < 72000
- forced on without %syssec_d% > 28800 and %syssec_d% < 72000
- forced off without %syssec_d% > 28800 and %syssec_d% < 72000
and for
- relais 3
- same thing
- add stop and start every 15 min. when %syssec_d% > 36000 and %syssec_d% < 68400
- relais 1
- GPIO 13, inverted logic: "0" is "on"
- When: %syssec_d% > 28800 and %syssec_d% < 72000
- forced on without %syssec_d% > 28800 and %syssec_d% < 72000
- forced off without %syssec_d% > 28800 and %syssec_d% < 72000
and for
- relais 3
- same thing
- add stop and start every 15 min. when %syssec_d% > 36000 and %syssec_d% < 68400
Re: error if and ife
and to clarify
should for better understanding have this annotation
Code: Select all
else //always off if var#11 anything else than 2 or 1
Code: Select all
else //always off if var#11 anything else than 2 or 1 or %syssec_d% is outside the defined area
Re: error if and ife
then the code i send you should work.For example:
- relais 1
- GPIO 13, inverted logic: "0" is "on"
- When: %syssec_d% > 28800 and %syssec_d% < 72000
- forced on without %syssec_d% > 28800 and %syssec_d% < 72000
- forced off without %syssec_d% > 28800 and %syssec_d% < 72000
and for
- relais 3
- same thing
- add stop and start every 15 min. when %syssec_d% > 36000 and %syssec_d% < 68400
can you test it and report?
Edit: here the whole thing with the latest change:
Code: Select all
On System#Boot Do
Let,1,0
Let,2,0
LoopTimerSet,1,900 //timer 15 minutes
LoopTimerSet,2,5 //timer 5 seconds
Endon
On Rules#Timer=2 Do
// relais
//1=13,2=12,3=14,4=16,5=4,6=5,7=3,8=1
Let,11,0 // relais 1 > 0 = arret , 1 = marche force , 2 = marche auto sonnette
Let,12,0 // relais 2 > 0 = arret , 1 = marche force , 2 = marche auto fontaine
Let,13,0 // relais 3 > 0 = arret , 1 = marche force , 2 = marche auto bassin
Let,14,0 // relais 4 > 0 = arret , 1 = marche force , 2 = marche auto
Let,15,0 // relais 5 > 0 = arret , 1 = marche force , 2 = marche auto chaudiere
Let,16,0 // relais 6 > 0 = arret , 1 = marche force , 2 = marche auto
Let,17,0 // relais 7 > 0 = arret , 1 = marche force , 2 = marche auto
Let,18,0 // relais 8 > 0 = arret , 1 = marche force , 2 = marche auto
Endon
On Rules#Timer=1 Do
If [Var#1]=2
GPIOToggle,14
Elseif [Var#1]=0
GPIO,14,1
Endif
Endon
On Clock#Time=All,**:** Do // boucle suivant horaires
// relais 1 sonnette
if [Var#11]=2 and %syssec_d% > 28800 and %syssec_d% < 72000 //auto mode
gpio,13,0
elseif [Var#11]=1 //always on
gpio,13,0
else //always off if var#11 anything else than 2 or 1 or %syssec_d% is outside the defined area
gpio,13,1
endif
//relais 2 fontaine
if [Var#12]=2 and %syssec_d% > 39600 and %syssec_d% < 72000 //de 11h a 20h
gpio,12,0
elseif [Var#12]=1
gpio,12,0
else
gpio,12,1
endif
//relais 3 pompe bassin
If [Var#13]=2 and %syssec_d% > 36000 and %syssec_d% < 68400 //de 10h a 19h
Let,1,2
Elseif [Var#13]=1 //< i guess this should be var#13 instead of var#12
gpio,14,0
Let,1,1
Else
Let,1,0
Endif
//relais 4
if [Var#14]=2 and %syssec_d% > 3600 and %syssec_d% < 28800//
gpio,16,0
elseif [Var#14]=1
gpio,16,0
Else
gpio,16,1
endif
//relais 5 chaudiere ete hiver
if [Var#15]=2 and %syssec_d% > 3600 and %syssec_d% < 28800//de 1h a 8h chaudiere
gpio,4,0
elseif [Var#15]=1
gpio,4,0
Else
gpio,4,1
endif
//relais 6
if [Var#16]=2 and %syssec_d% > 3600 and %syssec_d% < 28800//
gpio,5,0
elseif [Var#16]=1
gpio,5,0
Else
gpio,5,1
endif
//relais 7
if [Var#17]=2 and %syssec_d% > 3600 and %syssec_d% < 28800//
gpio,3,0
elseif [Var#17]=1
gpio,3,0
Else
gpio,3,1
endif
//relais 8
if [Var#18]=2 and %syssec_d% > 3600 and %syssec_d% < 28800//
gpio,1,0
elseif [Var#18]=1
gpio,1,0
Else
gpio,1,1
endif
Endon
Re: error if and ife
You don´t even need
Just put the code from there to
And then it will check everything every 5 seconds...
Code: Select all
On Clock#Time=All,**:** Do
Code: Select all
On Rules#Timer=2 Do
Code: Select all
On System#Boot Do
Let,1,0
Let,2,0
LoopTimerSet,1,900 //timer 15 minutes
LoopTimerSet,2,5 //timer 5 seconds
Endon
On Rules#Timer=1 Do
If [Var#1]=2
GPIOToggle,14
Elseif [Var#1]=0
GPIO,14,1
Endif
Endon
On Rules#Timer=2 Do
// relais
//1=13,2=12,3=14,4=16,5=4,6=5,7=3,8=1
Let,11,0 // relais 1 > 0 = arret , 1 = marche force , 2 = marche auto sonnette
Let,12,0 // relais 2 > 0 = arret , 1 = marche force , 2 = marche auto fontaine
Let,13,0 // relais 3 > 0 = arret , 1 = marche force , 2 = marche auto bassin
Let,14,0 // relais 4 > 0 = arret , 1 = marche force , 2 = marche auto
Let,15,0 // relais 5 > 0 = arret , 1 = marche force , 2 = marche auto chaudiere
Let,16,0 // relais 6 > 0 = arret , 1 = marche force , 2 = marche auto
Let,17,0 // relais 7 > 0 = arret , 1 = marche force , 2 = marche auto
Let,18,0 // relais 8 > 0 = arret , 1 = marche force , 2 = marche auto
// relais 1 sonnette
if [Var#11]=2 and %syssec_d% > 28800 and %syssec_d% < 72000 //auto mode
gpio,13,0
elseif [Var#11]=1 //always on
gpio,13,0
else //always off if var#11 anything else than 2 or 1
gpio,13,1
endif
//relais 2 fontaine
if [Var#12]=2 and %syssec_d% > 39600 and %syssec_d% < 72000 //de 11h a 20h
gpio,12,0
elseif [Var#12]=1
gpio,12,0
else
gpio,12,1
endif
//relais 3 pompe bassin
If [Var#13]=2 and %syssec_d% > 36000 and %syssec_d% < 68400 //de 10h a 19h
Let,1,2
Elseif [Var#13]=1 //< i guess this should be var#13 instead of var#12
gpio,14,0
Let,1,1
Else
Let,1,0
Endif
//relais 4
if [Var#14]=2 and %syssec_d% > 3600 and %syssec_d% < 28800//
gpio,16,0
elseif [Var#14]=1
gpio,16,0
Else
gpio,16,1
endif
//relais 5 chaudiere ete hiver
if [Var#15]=2 and %syssec_d% > 3600 and %syssec_d% < 28800//de 1h a 8h chaudiere
gpio,4,0
elseif [Var#15]=1
gpio,4,0
Else
gpio,4,1
endif
//relais 6
if [Var#16]=2 and %syssec_d% > 3600 and %syssec_d% < 28800//
gpio,5,0
elseif [Var#16]=1
gpio,5,0
Else
gpio,5,1
endif
//relais 7
if [Var#17]=2 and %syssec_d% > 3600 and %syssec_d% < 28800//
gpio,3,0
elseif [Var#17]=1
gpio,3,0
Else
gpio,3,1
endif
//relais 8
if [Var#18]=2 and %syssec_d% > 3600 and %syssec_d% < 28800//
gpio,1,0
elseif [Var#18]=1
gpio,1,0
Else
gpio,1,1
endif
Endon
Re: error if and ife
Why do you need the 5 sec interval timer?
It needs to toggle some relais at 15 min interval.
It needs to toggle some relais at 15 min interval.
Who is online
Users browsing this forum: No registered users and 15 guests