Page 1 of 1
Help with rules and timer.
Posted: 26 Aug 2021, 13:11
by WhiWhi
I would like help with how to solve a rule in EspEasy.
My thought is that if the temperature is above 24 degrees, it should send an email and then an email should be sent once an hour until the temperature is below 24 degrees.
How should I solve this?
My thought was like this but it does not work.
Code: Select all
on BME280#Temperature do
if [BME280#Temperature] > 24 and !Rules#Timer=1
Notify,1
timerSet,1,3600
endif
endon
Re: Help with rules and timer.
Posted: 26 Aug 2021, 13:18
by TD-er
I think you also need to set a flag, like in a variable.
See the 'let' command.
Then on the temperature event you check this flag if it is above your threshold and if it isn't set, set it and also start a timer like you do now. (just start the initial timer in 1 second)
If the flag is set, leave the timer running.
On the timer event you send a notification and restart the timer.
Since it was initially set to 1 second, you also immediately send a notification.
If the temp is lower than your threshold, clear the flag and clear the timer.
Re: Help with rules and timer.
Posted: 26 Aug 2021, 13:41
by Micha_he
This could work (untestet):
Code: Select all
on BME280#Temperature do
if [BME280#Temperature] > 24
if %v1% = 0 AND %v2% = 0
Notify,1
Let,1,1 // 1h timer is running
Let,2,1 // temp is not lower than limit
timerSet,1,3600
endif
elseif %v2% = 1
Let,2,0
endif
endon
on Rules#Timer=1
Let,1,0
endon
Edit: 'elseif' added
I read the first post again... And if you resend it after one hour, this version could work:
Code: Select all
on BME280#Temperature do
if [BME280#Temperature] > 24
if %v1% = 0 // not paused
Notify,1
Let,1,1
timerSet,1,3600
endif
else
Let,1,0
timerSet,1,0
endif
endon
on Rules#Timer=1
Let,1,0
endon
Re: Help with rules and timer.
Posted: 26 Aug 2021, 14:08
by TD-er
I think it can be simpler
Code: Select all
on BME280#Temperature do
if [BME280#Temperature] > 24
if %v1% = 0 // not paused
Let,1,1
timerSet,1,1
endif
else
Let,1,0
timerSet,1,0
endif
endon
on Rules#Timer=1
timerSet,1,3600
notify,1
endon
Re: Help with rules and timer.
Posted: 26 Aug 2021, 18:24
by WhiWhi
I will test your suggestions. I managed to solve it myself after your first post. But it is not as nice as your solutions but works.
Code: Select all
on BME280#Temperature do
if [BME280#Temperature] > 24 and %v1%=0
let,1,1
timerSet,1,3600
timerSet,2,1
endif
endon
On Rules#Timer=2 do
Notify,1
timerSet,2,0
endon
On Rules#Timer=1 do
if [BME280#Temperature] > 24 and %v1%=1
Notify,1
timerSet,1,3600
else
let,1,0
timerSet,1,0
endon
Re: Help with rules and timer.
Posted: 26 Aug 2021, 20:51
by TD-er
Well the most important thing to realize is that you managed to do it yourself, and thus now know how it works