milty456
(Rich Smith)
January 23, 2021, 4:53pm
1
openhab 2.5.10
Why does this while loop only run once?
var Number GarageTxtCounter = 1
while(GarageTxtCounter < 10){
mailActions.sendMail("1111111111@vtext.com", "GarageTilt Door Open", "GarageTilt Door Open")
GarageTxtCounter = GarageTxtCounter + 1
}
milty456
(Rich Smith)
January 23, 2021, 5:08pm
2
Tried this too, same result; only runs once
var GarageTxtCounter = 1
while((GarageTxtCounter=GarageTxtCounter+1) < 11){
mailActions.sendMail("1111111111@vtext.com", "GarageTilt Door Open", "GarageTilt Door Open")
GarageTxtCounter = GarageTxtCounter + 1
Thread::sleep(3000)
}
tsmit
(Tom Smit)
January 23, 2021, 7:22pm
3
milty456:
mailActions
Did you define mailActions?
val mailActions = getActions("mail","mail:smtp:989680e0")
I’m on OH3 so I cant test it for you. Also, check your logfiles, there should be some more information about why the rule failed.
milty456
(Rich Smith)
January 24, 2021, 6:27pm
4
Yeah, mail actions is definitely defined. It runs one time.
I don’t see anything in the log as to why it only runs once.
I did figure it out, the lead in to that splice of code was a switch
If (switch == ON)
It didn’t run because it needed .state
if (switch.state ==ON)