Why does this rule stop working ?

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
DaveS
Normal user
Posts: 25
Joined: 12 Feb 2018, 17:35

Why does this rule stop working ?

#1 Post by DaveS » 11 Apr 2019, 19:23

Hi Chaps,

I am using version mega-20190305
This is a home brew beer fermentation chamber controller.
I need a 15 minute timeout after the fridge compressor turns off before it gets turned on again.
The rules below work once after boot when the temp rises above 18 degrees but once the temperature drops below 18 degrees the fridge turns off and never turns on again when temperature rises.

Code: Select all

On System#Boot do     //Not sure if this needed ? - Used to set timer expired flag 10 seconds after boot
timerSet,1,10
endon

On Fermenter_Temp#Fermenter_Temperature<17 do     // turn on heater
gpio,12,0
gpio,14,1
Publish /FermoStat/gpio/14,1
endon

On Fermenter_Temp#Fermenter_Temperature do 
if [Fermenter_Temp#Fermenter_Temperature]>18 and [Rules#Timer]=1      //=1 checks if timer has expired then turn on fridge
gpio,14,0
gpio,12,1
Publish /FermoStat/gpio/12,1
endif
endon

On Fermenter_Temp#Fermenter_Temperature>17 do     // turn off heater
gpio,14,0
Publish /FermoStat/gpio/14,0
endon

On Fermenter_Temp#Fermenter_Temperature<18 do     // turn off fridge
gpio,12,0
Publish /FermoStat/gpio/12,0
timerSet,1,900                     //set timer 1 for 900 seconds (15 minutes)
endon
Any idea why rule stops working or is there a better way to implement this ?

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

Re: Why does this rule stop working ?

#2 Post by ThomasB » 11 Apr 2019, 21:54

Hmm. I don't believe a timer event is designed to be used in a conditional expression, as seen in this statement:

Code: Select all

if [Fermenter_Temp#Fermenter_Temperature]>18 and [Rules#Timer]=1 
Instead, have the Timer set a variable. This variable will be used in your conditional rule to replace the "[Rules#Timer]=1." The rules will need to also restart the timer and clear the variable.

Also, to streamline the code you could have just one "On Fermenter_Temp#Fermenter_Temperature" event and put all the temperature related conditions within it. Just food for thought.

- Thomas

DaveS
Normal user
Posts: 25
Joined: 12 Feb 2018, 17:35

Re: Why does this rule stop working ?

#3 Post by DaveS » 23 Apr 2019, 19:25

Will have the timer set a variable,
Thanks for the info.
Regards Dave

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot] and 41 guests